//
// jpeg_write_scanlines from 0x6670bc to 0x667158 (156 bytes)
//
// 2 xrefs:
// > cocos2d::CCImage::_saveImageToJPG @ 0x5e2378
// > cocos2d::CCImage::_saveImageToJPG @ 0x5e23a0
//
// 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 jpeg_write_scanlines(_DWORD *a1, int a2, unsigned int a3)
{
int v6; // r3
int v7; // r3
int v8; // r0
unsigned int v9; // r3
int result; // r0
int v11; // [sp+4h] [bp-8h] BYREF
if ( a1[5] != 101 )
{
*(_DWORD *)(*a1 + 20) = 21;
*(_DWORD *)(*a1 + 24) = a1[5];
(*(void (__fastcall **)(_DWORD *))*a1)(a1);
}
if ( a1[66] >= a1[8] )
{
*(_DWORD *)(*a1 + 20) = 126;
(*(void (__fastcall **)(_DWORD *, int))(*a1 + 4))(a1, -1);
}
v6 = a1[2];
if ( v6 )
{
*(_DWORD *)(v6 + 4) = a1[66];
*(_DWORD *)(a1[2] + 8) = a1[8];
(*(void (__fastcall **)(_DWORD *))a1[2])(a1);
}
v7 = a1[98];
if ( *(_DWORD *)(v7 + 12) )
(*(void (__fastcall **)(_DWORD *))(v7 + 4))(a1);
v8 = a1[99];
v9 = a1[8] - a1[66];
v11 = 0;
if ( v9 >= a3 )
v9 = a3;
(*(void (__fastcall **)(_DWORD *, int, int *, unsigned int))(v8 + 4))(a1, a2, &v11, v9);
result = v11;
a1[66] += v11;
return result;
}