//
// sub_69F640 from 0x69f640 to 0x69f762 (290 bytes)
//
// 1 xrefs:
// > sub_69F87C @ 0x69f92e
//
// 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_69F640(_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_69EEA8(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;
}