//
// sub_EA1060 from 0xea1060 to 0xea11c4 (356 bytes)
//
// 4 xrefs:
// > sub_EA11C4 @ 0xea11d8
// > sub_EA11C4 @ 0xea11e4
// > jinit_memory_mgr @ 0xea2500
// > jinit_memory_mgr @ 0xea2508
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:11:07 +0000
//
__int64 __fastcall sub_EA1060(__int64 result, unsigned int a2)
{
__int64 v2; // x21
_QWORD *v4; // x22
__int64 (__fastcall **v5)(_QWORD); // x1
_QWORD *v6; // x23
_QWORD *v7; // x2
_QWORD *v8; // x19
__int64 v9; // x20
_QWORD *v10; // x2
_QWORD *v11; // x19
__int64 v12; // x20
__int64 i; // x19
__int64 (__fastcall *v14)(__int64, __int64); // x2
__int64 v15; // x20
__int64 (__fastcall *v16)(__int64, __int64); // x2
v2 = result;
v4 = *(_QWORD **)(result + 8);
if ( a2 <= 1 )
{
if ( a2 == 1 )
{
for ( i = v4[17]; i; i = *(_QWORD *)(i + 48) )
{
while ( 1 )
{
result = *(unsigned int *)(i + 44);
if ( (_DWORD)result )
break;
i = *(_QWORD *)(i + 48);
if ( !i )
goto LABEL_14;
}
v14 = *(__int64 (__fastcall **)(__int64, __int64))(i + 72);
*(_DWORD *)(i + 44) = 0;
result = v14(v2, i + 56);
}
LABEL_14:
v15 = v4[18];
for ( v4[17] = 0; v15; v15 = *(_QWORD *)(v15 + 48) )
{
while ( 1 )
{
result = *(unsigned int *)(v15 + 44);
if ( (_DWORD)result )
break;
v15 = *(_QWORD *)(v15 + 48);
if ( !v15 )
goto LABEL_19;
}
v16 = *(__int64 (__fastcall **)(__int64, __int64))(v15 + 72);
*(_DWORD *)(v15 + 44) = 0;
result = v16(v2, v15 + 56);
}
LABEL_19:
v4[18] = 0;
}
}
else
{
v5 = *(__int64 (__fastcall ***)(_QWORD))result;
*((_DWORD *)v5 + 11) = a2;
*((_DWORD *)v5 + 10) = 15;
result = (**(__int64 (__fastcall ***)(__int64))result)(result);
}
v6 = &v4[a2];
v7 = (_QWORD *)v6[15];
v6[15] = 0;
if ( v7 )
{
do
{
v8 = (_QWORD *)*v7;
v9 = v7[1] + v7[2] + 24LL;
jpeg_free_large(v2, v7);
result = v4[19];
v7 = v8;
v4[19] = result - v9;
}
while ( v8 );
}
v10 = (_QWORD *)v6[13];
v6[13] = 0;
if ( v10 )
{
do
{
v11 = (_QWORD *)*v10;
v12 = v10[1] + v10[2] + 24LL;
jpeg_free_small(v2, v10);
result = v4[19];
v10 = v11;
v4[19] = result - v12;
}
while ( v11 );
}
return result;
}