//
// sub_69EEA8 from 0x69eea8 to 0x69efc6 (286 bytes)
//
// 2 xrefs:
// > sub_69F640 @ 0x69f678
// > sub_69F764 @ 0x69f79a
//
// 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_69EEA8(_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_9E0588[a2];
}
else
{
v10 = v5 + 16;
v11 = dword_9E0588[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;
}