//
// sub_90D4F4 from 0x90d4f4 to 0x90d66e (378 bytes)
//
// 3 xrefs:
// > sub_90D670 @ 0x90d982
// > sub_90DDE0 @ 0x90df58
// > sub_90DDE0 @ 0x90dfe0
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:04:24 +0000
//
int __fastcall sub_90D4F4(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_943530(a3 + 24) )
{
v16 = sub_943530(v4);
if ( (unsigned int)(v16 - 1) > 0xA || !sub_90D670(a3, a1, a2, v16, 0) )
goto LABEL_3;
v10 = a3 + 124;
*(_DWORD *)(a3 + 120) = 1 << v16;
if ( !sub_944248(a3 + 124, v16, v17, 1 << v16) )
{
*(_DWORD *)a3 = 1;
v9 = nullptr;
goto LABEL_4;
}
}
else
{
if ( !sub_90D670(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_94470C(*(_DWORD *)(a3 + 168));
sub_944270(v10);
sub_944270(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_90C840((_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_94470C(*(_DWORD *)(a3 + 168));
sub_944270(v10);
sub_944270(a3 + 136);
memset((void *)(a3 + 120), 0, 0x38u);
return 1;
}