//
// sub_733C40 from 0x733c40 to 0x733d60 (288 bytes)
//
// 14 xrefs:
// > sub_721EF0 @ 0x721fae
// > sub_721EF0 @ 0x722012
// > sub_72F448 @ 0x72f492
// > sub_72F448 @ 0x72f49a
// > sub_72F448 @ 0x72f4aa
// > sub_72F448 @ 0x72f4c8
// > sub_72F448 @ 0x72f4e4
// > sub_72F448 @ 0x72f55a
// > sub_72F448 @ 0x72f7b0
// > sub_72F448 @ 0x72f7b8
// > sub_72F448 @ 0x72f7e0
// > sub_72F448 @ 0x72f7fe
// > sub_72F448 @ 0x72fa12
// > sub_7308C4 @ 0x730988
//
// 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
//
int __fastcall sub_733C40(int a1, int a2)
{
int v4; // r3
int v5; // r1
int v6; // r1
int v7; // r2
int v8; // r0
unsigned int v9; // r7
unsigned int v10; // r6
unsigned __int64 v11; // r2
bool v12; // zf
unsigned int v14; // r1
unsigned int v15; // r8
_BYTE *v16; // r0
_BYTE *v17; // r9
size_t v18; // r2
_BYTE *v19; // r3
int v20; // r2
int v21; // r2
int v22; // r3
bool v23; // cc
v4 = *(int *)a1 >> 1;
if ( a2 )
{
v5 = v4 + 1;
v4 = ~v4 + *(_DWORD *)a1;
*(_DWORD *)(a1 + 4) += v5;
}
*(_DWORD *)a1 = v4;
if ( v4 > 126 )
return a2;
v6 = *(_DWORD *)(a1 + 12);
v7 = 2 * *(_DWORD *)(a1 + 4);
v8 = byte_A068D0[v4 + 128];
*(_DWORD *)(a1 + 12) = v6 + 1;
*(_DWORD *)a1 = v8;
*(_DWORD *)(a1 + 4) = v7;
if ( v6 + 1 <= 0 )
return a2;
v9 = v7 >> (v6 + 9);
*(_DWORD *)(a1 + 12) = v6 - 7;
*(_DWORD *)(a1 + 4) = v7 - (v9 << (v6 + 9));
if ( (unsigned __int8)v9 == 255 )
{
++*(_DWORD *)(a1 + 8);
return a2;
}
else
{
v10 = *(_DWORD *)(a1 + 20);
v11 = v10 + (unsigned __int64)(unsigned int)(*(_DWORD *)(a1 + 8) + 1);
v12 = HIDWORD(v11) == 0;
if ( !HIDWORD(v11) )
v12 = 1;
if ( !v12 )
goto LABEL_9;
v14 = *(_DWORD *)(a1 + 24);
if ( (unsigned int)v11 <= v14 )
{
v19 = *(_BYTE **)(a1 + 16);
}
else
{
v15 = 2 * v14;
if ( 2 * v14 < (unsigned int)v11 )
v15 = v10 + *(_DWORD *)(a1 + 8) + 1;
if ( v15 < 0x400 )
v15 = 1024;
v16 = (_BYTE *)WebPSafeMalloc(1, 0, v15);
v17 = v16;
if ( !v16 )
{
LABEL_9:
*(_DWORD *)(a1 + 28) = 1;
return a2;
}
v18 = *(_DWORD *)(a1 + 20);
if ( v18 )
memcpy(v16, *(const void **)(a1 + 16), v18);
WebPSafeFree(*(void **)(a1 + 16));
v19 = v17;
*(_DWORD *)(a1 + 16) = v17;
*(_DWORD *)(a1 + 24) = v15;
}
if ( v10 )
v20 = (v9 >> 8) & 1;
else
v20 = 0;
if ( v20 )
{
++v19[v10 - 1];
v19 = *(_BYTE **)(a1 + 16);
}
if ( *(int *)(a1 + 8) > 0 )
{
do
{
v19[v10] = -!(v9 & 0x100);
v21 = ++v10;
v22 = *(_DWORD *)(a1 + 8) - 1;
*(_DWORD *)(a1 + 8) = v22;
v23 = v22 <= 0;
v19 = *(_BYTE **)(a1 + 16);
}
while ( !v23 );
}
else
{
v21 = v10;
}
v19[v21] = v9;
*(_DWORD *)(a1 + 20) = v21 + 1;
return a2;
}
}