//
// sub_6FD934 from 0x6fd934 to 0x6fdaae (378 bytes)
//
// 3 xrefs:
// > sub_6FDAB0 @ 0x6fddc2
// > sub_6FE220 @ 0x6fe398
// > sub_6FE220 @ 0x6fe420
//
// 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_6FD934(int a1, int a2, int a3, _DWORD *a4)
{
int v4; // r5
void *v9; // r6
int v10; // r5
int v12; // r6
int v13; // r3
unsigned int v14; // lr
void *v15; // r0
int v16; // r6
int v17; // r2
v4 = a3 + 24;
if ( sub_733970(a3 + 24) )
{
v16 = sub_733970(v4);
if ( (unsigned int)(v16 - 1) > 0xA || !sub_6FDAB0(a3, a1, a2, v16, 0) )
goto LABEL_3;
v10 = a3 + 124;
*(_DWORD *)(a3 + 120) = 1 << v16;
if ( !sub_734688(a3 + 124, v16, v17, 1 << v16) )
{
*(_DWORD *)a3 = 1;
v9 = nullptr;
goto LABEL_4;
}
}
else
{
if ( !sub_6FDAB0(a3, a1, a2, 0, 0) )
{
LABEL_3:
v9 = nullptr;
*(_DWORD *)a3 = 3;
v10 = a3 + 124;
LABEL_4:
WebPSafeFree(v9);
WebPSafeFree(*(void **)(a3 + 160));
WebPSafeFree(*(void **)(a3 + 172));
sub_734B4C(*(_DWORD *)(a3 + 168));
sub_7346B0(v10);
sub_7346B0(a3 + 136);
memset((void *)(a3 + 120), 0, 0x38u);
return 0;
}
v10 = a3 + 124;
*(_DWORD *)(a3 + 120) = 0;
}
v12 = *(_DWORD *)(a3 + 152);
*(_DWORD *)(a3 + 100) = a1;
v13 = (1 << v12) - 1;
*(_DWORD *)(a3 + 104) = a2;
v14 = v13 + a1;
if ( !v12 )
v13 = -1;
*(_DWORD *)(a3 + 148) = v13;
*(_DWORD *)(a3 + 156) = v14 >> v12;
v9 = (void *)WebPSafeMalloc(a1 * a2, (unsigned __int64)(a1 * (__int64)a2) >> 32, 4);
if ( !v9 )
{
*(_DWORD *)a3 = 1;
goto LABEL_4;
}
if ( !sub_6FCC80((_DWORD *)a3, (int)v9, a1, a2, a2, nullptr) || *(_DWORD *)(a3 + 48) )
goto LABEL_4;
if ( a4 )
*a4 = v9;
v15 = *(void **)(a3 + 160);
*(_DWORD *)(a3 + 112) = 0;
WebPSafeFree(v15);
WebPSafeFree(*(void **)(a3 + 172));
sub_734B4C(*(_DWORD *)(a3 + 168));
sub_7346B0(v10);
sub_7346B0(a3 + 136);
memset((void *)(a3 + 120), 0, 0x38u);
return 1;
}