//
// sub_8AEF28 from 0x8aef28 to 0x8af046 (286 bytes)
//
// 2 xrefs:
// > sub_8AF6C0 @ 0x8af6f8
// > sub_8AF7E4 @ 0x8af81a
//
// 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:03:53 +0000
//
int __fastcall sub_8AEF28(_DWORD *a1, unsigned int a2, unsigned int a3)
{
unsigned int v5; // r5
int v6; // r8
int v7; // r9
_DWORD *v8; // r4
unsigned int v9; // r0
unsigned int v10; // r7
unsigned int v11; // r3
unsigned int v12; // r11
unsigned int v13; // r10
_DWORD *small; // r0
int v15; // r2
_DWORD *v17; // r3
v5 = a3;
v6 = a1[1];
if ( a3 > 0x3B9AC9F0 )
{
*(_DWORD *)(*a1 + 20) = 56;
*(_DWORD *)(*a1 + 24) = 1;
(*(void (__fastcall **)(_DWORD *))*a1)(a1);
}
if ( (v5 & 7) != 0 )
v5 = v5 + 8 - (v5 & 7);
if ( a2 > 1 )
{
*(_DWORD *)(*a1 + 20) = 15;
*(_DWORD *)(*a1 + 24) = a2;
(*(void (__fastcall **)(_DWORD *))*a1)(a1);
}
v7 = v6 + 4 * a2;
v8 = *(_DWORD **)(v7 + 52);
if ( v8 )
{
v9 = v8[2];
if ( v5 <= v9 )
{
v17 = *(_DWORD **)(v7 + 52);
goto LABEL_22;
}
while ( 1 )
{
v17 = (_DWORD *)*v8;
if ( !*v8 )
break;
v9 = v17[2];
v8 = (_DWORD *)*v8;
if ( v5 <= v9 )
goto LABEL_22;
}
v10 = v5 + 16;
v11 = dword_C22B20[a2];
}
else
{
v10 = v5 + 16;
v11 = dword_C22B20[a2 + 2];
}
if ( v11 >= 999999984 - v5 )
v11 = 999999984 - v5;
v12 = v11;
while ( 1 )
{
v13 = v12 + v10;
small = (_DWORD *)jpeg_get_small((int)a1, v12 + v10);
if ( small )
break;
while ( 1 )
{
v12 >>= 1;
if ( v12 > 0x31 )
break;
v13 = v12 + v10;
*(_DWORD *)(*a1 + 20) = 56;
*(_DWORD *)(*a1 + 24) = 2;
(*(void (__fastcall **)(_DWORD *))*a1)(a1);
small = (_DWORD *)jpeg_get_small((int)a1, v12 + v10);
if ( small )
goto LABEL_19;
}
}
LABEL_19:
v17 = small;
*(_DWORD *)(v6 + 76) += v13;
small[2] = v12 + v5;
*small = 0;
small[1] = 0;
if ( v8 )
*v8 = small;
else
*(_DWORD *)(v7 + 52) = small;
v9 = small[2];
LABEL_22:
v15 = v17[1];
v17[2] = v9 - v5;
v17[1] = v15 + v5;
return (int)v17 + v15 + 16;
}