//
// sub_8AF6C0 from 0x8af6c0 to 0x8af7e2 (290 bytes)
//
// 1 xrefs:
// > sub_8AF8FC @ 0x8af9ae
//
// 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_8AF6C0(_DWORD *a1, unsigned int a2, unsigned int a3, unsigned int a4)
{
int v7; // r5
unsigned int v8; // r8
int v9; // r11
unsigned int v10; // r7
int v11; // r9
int v12; // r5
_DWORD *large; // r2
int v14; // r3
_DWORD *v15; // r5
_DWORD *v16; // r3
int v19; // [sp+4h] [bp-10h]
v7 = a1[1];
v8 = 0x3B9AC9F0 / a3;
if ( !(0x3B9AC9F0 / a3) )
{
*(_DWORD *)(*a1 + 20) = 72;
(*(void (__fastcall **)(_DWORD *))*a1)(a1);
}
if ( (int)v8 >= (int)a4 )
v8 = a4;
*(_DWORD *)(v7 + 80) = v8;
v9 = sub_8AEF28(a1, a2, 4 * a4);
if ( a4 )
{
v10 = 0;
v19 = 4 * a2;
do
{
v11 = a1[1];
if ( v8 >= a4 - v10 )
v8 = a4 - v10;
v12 = a3 * v8;
if ( a3 * v8 > 0x3B9AC9F0 )
{
*(_DWORD *)(*a1 + 20) = 56;
*(_DWORD *)(*a1 + 24) = 3;
(*(void (__fastcall **)(_DWORD *))*a1)(a1);
}
if ( (v12 & 7) != 0 )
v12 = v12 + 8 - (v12 & 7);
if ( a2 > 1 )
{
*(_DWORD *)(*a1 + 20) = 15;
*(_DWORD *)(*a1 + 24) = a2;
(*(void (__fastcall **)(_DWORD *))*a1)(a1);
}
large = (_DWORD *)jpeg_get_large((int)a1, v12 + 16);
if ( !large )
{
*(_DWORD *)(*a1 + 20) = 56;
*(_DWORD *)(*a1 + 24) = 4;
(*(void (__fastcall **)(_DWORD *))*a1)(a1);
large = nullptr;
}
*(_DWORD *)(v11 + 76) += 16 + v12;
v14 = *(_DWORD *)(v19 + v11 + 60);
large[1] = v12;
v15 = large + 4;
large[2] = 0;
*large = v14;
*(_DWORD *)(v19 + v11 + 60) = large;
if ( v8 )
{
v16 = (_DWORD *)(v9 + 4 * v10);
v10 += v8;
do
{
*v16++ = v15;
v15 = (_DWORD *)((char *)v15 + a3);
}
while ( v16 != (_DWORD *)(v9 + 4 * v10) );
}
}
while ( a4 > v10 );
}
return v9;
}