//
// sub_E78164 from 0xe78164 to 0xe78404 (672 bytes)
//
// 2 xrefs:
// > jinit_c_prep_controller @ 0xe786ec
// > jinit_c_prep_controller @ 0xe786f4
//
// 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:10:41 +0000
//
__int64 __fastcall sub_E78164(
__int64 a1,
__int64 a2,
unsigned int *a3,
unsigned int a4,
__int64 *a5,
unsigned int *a6,
unsigned int a7)
{
__int64 v7; // x23
unsigned int v10; // w1
__int64 result; // x0
unsigned int v12; // w6
unsigned int v13; // w19
__int64 v14; // x1
int v15; // w0
signed int v16; // w6
int v17; // w19
int v18; // w19
int v19; // w0
__int64 *v20; // x25
int v21; // w28
int v22; // w24
__int64 v23; // x27
unsigned int v24; // w20
int v25; // w21
int v26; // w3
unsigned int v27; // w19
int v28; // w1
_DWORD *v29; // x23
__int64 *v30; // x25
int v31; // w24
__int64 v32; // x28
int v33; // w20
unsigned int v34; // w21
int v35; // w19
int v36; // w20
int v37; // w27
int v38; // w3
__int64 v44; // [xsp+88h] [xbp+88h]
v7 = *(_QWORD *)(a1 + 512);
v44 = v7 + 16;
while ( 2 )
{
v10 = *a3;
result = a4;
if ( *a3 < a4 )
{
while ( 1 )
{
result = *a6;
if ( (unsigned int)result >= a7 )
return result;
v12 = a4 - v10;
v13 = *(_DWORD *)(a1 + 356) - *(_DWORD *)(v7 + 100);
v14 = a2 + 8LL * v10;
if ( v12 <= v13 )
v13 = v12;
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)(a1 + 536) + 8LL))(a1, v14, v44);
*a3 += v13;
v15 = *(_DWORD *)(v7 + 96);
v16 = v13 + *(_DWORD *)(v7 + 100);
*(_DWORD *)(v7 + 100) = v16;
v17 = v15 - v13;
*(_DWORD *)(v7 + 96) = v17;
if ( !v17 )
break;
if ( *(_DWORD *)(a1 + 356) == v16 )
goto LABEL_17;
v10 = *a3;
result = a4;
if ( *a3 >= a4 )
return result;
}
v18 = *(_DWORD *)(a1 + 356);
if ( v16 >= v18 )
{
if ( v16 != v18 )
{
v27 = *a6;
LABEL_18:
if ( a7 <= v27 )
continue;
v28 = *(_DWORD *)(a1 + 92);
v29 = *(_DWORD **)(a1 + 104);
if ( v28 > 0 )
{
v30 = a5;
v31 = 0;
while ( 1 )
{
v32 = *v30;
v33 = v29[3] * v29[10] / *(_DWORD *)(a1 + 364);
v34 = v29[9] * v29[7];
v35 = v33 * v27;
v36 = v33 * a7;
if ( v35 < v36 )
{
v37 = v35 - 1;
do
{
v38 = v35++;
jcopy_sample_rows(v32, v37, v32, v38, 1, v34);
}
while ( v36 != v35 );
v28 = *(_DWORD *)(a1 + 92);
}
++v31;
v29 += 24;
++v30;
if ( v31 >= v28 )
break;
v27 = *a6;
}
}
*a6 = a7;
return a7;
}
}
else
{
v19 = *(_DWORD *)(a1 + 92);
if ( v19 > 0 )
{
v20 = (__int64 *)(v7 + 16);
v21 = v16;
v22 = 0;
while ( 1 )
{
v23 = *v20;
v24 = *(_DWORD *)(a1 + 48);
if ( v21 < v18 )
{
v25 = v21 - 1;
do
{
v26 = v21++;
jcopy_sample_rows(v23, v25, v23, v26, 1, v24);
}
while ( v21 != v18 );
v18 = *(_DWORD *)(a1 + 356);
v19 = *(_DWORD *)(a1 + 92);
}
++v22;
++v20;
if ( v19 <= v22 )
break;
v21 = *(_DWORD *)(v7 + 100);
}
}
*(_DWORD *)(v7 + 100) = v18;
}
LABEL_17:
(*(void (__fastcall **)(__int64, __int64, _QWORD, __int64 *, _QWORD))(*(_QWORD *)(a1 + 544) + 8LL))(
a1,
v44,
0,
a5,
*a6);
*(_DWORD *)(v7 + 100) = 0;
v27 = *a6 + 1;
*a6 = v27;
if ( *(_DWORD *)(v7 + 96) )
continue;
goto LABEL_18;
}
return result;
}
}