//
// sub_F2C800 from 0xf2c800 to 0xf2c970 (368 bytes)
//
// 4 xrefs:
// > sub_F2CF14 @ 0xf2cf9c
// > sub_F2CF14 @ 0xf2d194
// > sub_F2CF14 @ 0xf2d234
// > sub_F2D350 @ 0xf2d4d4
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:12:50 +0000
//
__int64 __fastcall sub_F2C800(__int64 result)
{
int v1; // w3
int v2; // w1
unsigned __int64 v3; // x23
__int64 v4; // x19
unsigned __int64 v5; // x22
__int64 v6; // x20
unsigned __int64 v7; // x21
unsigned __int64 v8; // x22
void *v9; // x0
__int64 v10; // x21
size_t v11; // x2
__int64 v12; // x1
int v13; // w0
bool v14; // cc
v1 = *(_DWORD *)(result + 12);
v2 = *(_DWORD *)(result + 4);
v3 = (unsigned int)(v2 >> (v1 + 8));
*(_DWORD *)(result + 12) = v1 - 8;
*(_DWORD *)(result + 4) = v2 - ((_DWORD)v3 << (v1 + 8));
if ( (unsigned __int8)(v2 >> (v1 + 8)) == 255 )
{
++*(_DWORD *)(result + 8);
return result;
}
v4 = result;
v5 = *(_QWORD *)(result + 32);
v6 = *(_QWORD *)(result + 24);
v7 = v6 + *(_DWORD *)(result + 8) + 1;
if ( v7 <= v5 )
{
result = *(_QWORD *)(result + 16);
}
else
{
v8 = 2 * v5;
if ( v7 >= v8 )
v8 = v6 + *(_DWORD *)(result + 8) + 1;
if ( v8 <= 0x3FF )
v8 = 1024;
v9 = (void *)WebPSafeMalloc(1, v8);
v10 = (__int64)v9;
if ( !v9 )
{
*(_DWORD *)(v4 + 40) = 1;
return 1;
}
v11 = *(_QWORD *)(v4 + 24);
if ( v11 )
memcpy(v9, *(const void **)(v4 + 16), v11);
WebPSafeFree(*(void **)(v4 + 16));
*(_QWORD *)(v4 + 16) = v10;
*(_QWORD *)(v4 + 32) = v8;
result = v10;
}
if ( ((v3 >> 8) & 1) != 0 && v6 )
{
++*(_BYTE *)(result + v6 - 1);
result = *(_QWORD *)(v4 + 16);
}
if ( *(int *)(v4 + 8) <= 0 )
{
v12 = v6;
}
else
{
do
{
*(_BYTE *)(result + v6) = -!(v3 & 0x100);
v12 = ++v6;
v13 = *(_DWORD *)(v4 + 8) - 1;
*(_DWORD *)(v4 + 8) = v13;
v14 = v13 <= 0;
result = *(_QWORD *)(v4 + 16);
}
while ( !v14 );
}
*(_BYTE *)(result + v12) = v3;
*(_QWORD *)(v4 + 24) = v12 + 1;
return result;
}