//
// sub_10031E1B0 from 0x10031e1b0 to 0x10031e327 (375 bytes)
//
// 1 xrefs:
// > cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile_2 @ 0x10031d1d9
//
// 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
//
__int64 *__fastcall sub_10031E1B0(__int64 **a1, unsigned __int8 *a2, __int64 a3)
{
__int64 *v3; // rax
unsigned int v4; // edi
size_t v5; // rdi
const void *v6; // rbx
__int64 *v7; // r14
__int64 *v8; // rcx
unsigned int v9; // r12d
size_t v10; // r12
const void *v11; // r13
size_t v12; // r14
int v13; // eax
bool v14; // cl
int v15; // eax
bool v16; // cl
__int64 *v17; // rbx
_QWORD *v18; // r15
__int64 *v19; // rax
__int64 *v23; // [rsp+10h] [rbp-30h]
v3 = a1[1];
if ( v3 )
{
v4 = *a2;
if ( (v4 & 1) != 0 )
{
v5 = *((_QWORD *)a2 + 1);
v6 = *((const void **)a2 + 2);
}
else
{
v5 = v4 >> 1;
v6 = a2 + 1;
}
while ( 1 )
{
while ( 1 )
{
v9 = *((unsigned __int8 *)v3 + 32);
v23 = v3;
if ( (v9 & 1) != 0 )
{
v10 = v3[5];
v11 = (const void *)v3[6];
}
else
{
v10 = v9 >> 1;
v11 = (char *)v3 + 33;
}
v12 = v5;
if ( v10 < v5 )
v12 = v10;
v13 = memcmp(v6, v11, v12);
v14 = v5 < v10;
if ( v13 )
v14 = v13 < 0;
if ( !v14 )
break;
v8 = v23;
v3 = (__int64 *)*v23;
v7 = v23;
if ( !*v23 )
goto LABEL_20;
}
v15 = memcmp(v11, v6, v12);
v16 = v10 < v5;
if ( v15 )
v16 = v15 < 0;
if ( !v16 )
return v23;
v8 = v23;
v3 = (__int64 *)v23[1];
if ( !v3 )
{
v7 = v23 + 1;
goto LABEL_20;
}
}
}
else
{
v7 = (__int64 *)(a1 + 1);
v8 = (__int64 *)(a1 + 1);
LABEL_20:
v17 = v8;
v18 = operator new(0x38u);
v18[6] = *(_QWORD *)(a3 + 16);
*((_OWORD *)v18 + 2) = *(_OWORD *)a3;
*(_OWORD *)a3 = 0;
*(_QWORD *)(a3 + 16) = 0;
*(_OWORD *)v18 = 0;
v18[2] = v17;
*v7 = (__int64)v18;
v19 = (__int64 *)**a1;
if ( v19 )
*a1 = v19;
sub_100054DD0(a1[1], v18);
a1[2] = (__int64 *)((char *)a1[2] + 1);
}
return v18;
}