//
// cocos2d::CCTextureCache::snapshotTextures from 0x1800a9ad0 to 0x1800a9d00 (560 bytes)
//
// 2 xrefs:
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b7efc
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
// Hidden C++ exception states: #wind=2
struct cocos2d::CCDictionary *__fastcall cocos2d::CCTextureCache::snapshotTextures(cocos2d::CCTextureCache *this)
{
cocos2d::CCDictionary *v2; // rax
cocos2d::CCDictionary *v3; // r15
cocos2d::CCDictionary *m_pTextures; // rsi
cocos2d::CCDictElement *m_pElements; // rsi
cocos2d::CCDictElement *next; // rbp
size_t v7; // rbx
unsigned __int64 v8; // rdi
size_t v9; // rax
void *v10; // rax
void *v11; // r14
void *v12; // rcx
__int128 v14; // [rsp+28h] [rbp-50h] BYREF
size_t v15; // [rsp+38h] [rbp-40h]
unsigned __int64 v16; // [rsp+40h] [rbp-38h]
v2 = (cocos2d::CCDictionary *)operator new(0x48u);
if ( v2 )
v3 = cocos2d::CCDictionary::CCDictionary(v2);
else
v3 = nullptr;
m_pTextures = this->m_pTextures;
if ( m_pTextures )
{
m_pElements = m_pTextures->m_pElements;
next = m_pElements ? (cocos2d::CCDictElement *)m_pElements->hh.next : nullptr;
if ( m_pElements )
{
while ( 1 )
{
v14 = 0;
v15 = 0;
v16 = 0;
v7 = -1;
do
++v7;
while ( m_pElements->m_szKey[v7] );
if ( v7 > 0x7FFFFFFFFFFFFFFFLL )
std::vector::_Xlen();
v16 = 15;
if ( v7 > 0xF )
break;
v15 = v7;
memcpy(&v14, m_pElements, v7);
*((_BYTE *)&v14 + v7) = 0;
LABEL_26:
cocos2d::CCDictionary::setObject((__int64)v3, m_pElements->m_pObject, (unsigned __int8 *)&v14);
if ( v16 > 0xF )
{
v12 = (void *)v14;
if ( v16 + 1 >= 0x1000 )
{
v12 = *(void **)(v14 - 8);
if ( (unsigned __int64)(v14 - (_QWORD)v12 - 8) > 0x1F )
LABEL_35:
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v12);
}
m_pElements = next;
if ( next )
next = (cocos2d::CCDictElement *)next->hh.next;
else
next = nullptr;
if ( !m_pElements )
goto LABEL_34;
}
v8 = v7 | 0xF;
if ( (v7 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
if ( v8 < 0x16 )
v8 = 22;
if ( v8 + 1 < 0x1000 )
{
if ( v8 == -1 )
v11 = nullptr;
else
v11 = operator new(v8 + 1);
LABEL_25:
*(_QWORD *)&v14 = v11;
v15 = v7;
v16 = v8;
memcpy(v11, m_pElements, v7);
*((_BYTE *)v11 + v7) = 0;
goto LABEL_26;
}
v9 = v8 + 40;
if ( v8 + 40 < v8 + 1 )
Concurrency::cancel_current_task();
}
else
{
v8 = 0x7FFFFFFFFFFFFFFFLL;
v9 = 0x8000000000000027uLL;
}
v10 = operator new(v9);
if ( !v10 )
goto LABEL_35;
v11 = (void *)(((unsigned __int64)v10 + 39) & 0xFFFFFFFFFFFFFFE0uLL);
*((_QWORD *)v11 - 1) = v10;
goto LABEL_25;
}
}
LABEL_34:
cocos2d::CCObject::autorelease(v3);
return v3;
}