//
// sub_C02244 from 0xc02244 to 0xc024cc (648 bytes)
//
// 1 xrefs:
// > jinit_c_prep_controller @ 0xc025d8
//
// 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
//
__int64 __fastcall sub_C02244(
__int64 a1,
__int64 a2,
unsigned int *a3,
unsigned int a4,
__int64 a5,
unsigned int *a6,
unsigned int a7)
{
_DWORD *v8; // x23
unsigned int *v10; // x0
__int64 v11; // x4
__int64 result; // x0
unsigned int v13; // w1
int v14; // w6
int v15; // w19
int v16; // w0
__int64 *v17; // x25
int v18; // w28
int v19; // w24
__int64 v20; // x27
unsigned int v21; // w20
int v22; // w21
int v23; // w3
__int64 v24; // x3
unsigned int v25; // w20
unsigned int v26; // w20
int v27; // w2
int v28; // w1
int v29; // w0
int v30; // w1
int v31; // w0
int v32; // w19
_QWORD *v33; // x24
int v34; // w21
int v35; // w3
int v37; // [xsp+6Ch] [xbp+6Ch]
_DWORD *v39; // [xsp+78h] [xbp+78h]
v8 = *(_DWORD **)(a1 + 512);
v37 = 3 * *(_DWORD *)(a1 + 356);
v39 = v8 + 4;
v10 = a6;
while ( 1 )
{
v11 = *v10;
result = a7;
if ( a7 <= (unsigned int)v11 )
return result;
while ( 1 )
{
v13 = *a3;
if ( *a3 < a4 )
{
v24 = (unsigned int)v8[25];
v25 = a4 - v13;
if ( a4 - v13 > v8[27] - (int)v24 )
v25 = v8[27] - v24;
(*(void (__fastcall **)(__int64, __int64, _DWORD *, __int64, _QWORD))(*(_QWORD *)(a1 + 536) + 8LL))(
a1,
a2 + 8LL * v13,
v39,
v24,
v25);
if ( v8[24] == *(_DWORD *)(a1 + 52) )
{
v30 = *(_DWORD *)(a1 + 92);
if ( v30 > 0 )
{
v31 = *(_DWORD *)(a1 + 356);
v32 = 0;
v33 = v8 + 4;
do
{
v34 = 1;
if ( v31 > 0 )
{
do
{
v35 = -v34++;
jcopy_sample_rows(*v33, 0, *v33, v35, 1, *(unsigned int *)(a1 + 48));
v31 = *(_DWORD *)(a1 + 356);
}
while ( v31 >= v34 );
v30 = *(_DWORD *)(a1 + 92);
}
++v32;
++v33;
}
while ( v32 < v30 );
}
}
*a3 += v25;
v15 = v8[27];
v14 = v25 + v8[25];
v26 = v8[24] - v25;
v8[25] = v14;
v8[24] = v26;
v11 = *a6;
goto LABEL_18;
}
result = (unsigned int)v8[24];
if ( (_DWORD)result )
return result;
v14 = v8[25];
v15 = v8[27];
if ( v14 < v15 )
break;
LABEL_18:
if ( v14 == v15 )
goto LABEL_22;
result = a7;
if ( a7 <= (unsigned int)v11 )
return result;
}
v16 = *(_DWORD *)(a1 + 92);
if ( v16 > 0 )
{
v17 = (__int64 *)(v8 + 4);
v18 = v8[25];
v19 = 0;
while ( 1 )
{
v20 = *v17;
v21 = *(_DWORD *)(a1 + 48);
if ( v18 < v15 )
{
v22 = v18 - 1;
do
{
v23 = v18++;
jcopy_sample_rows(v20, v22, v20, v23, 1, v21);
}
while ( v18 != v15 );
v15 = v8[27];
v16 = *(_DWORD *)(a1 + 92);
}
++v19;
++v17;
if ( v19 >= v16 )
break;
v18 = v8[25];
}
}
v8[25] = v15;
v11 = *a6;
LABEL_22:
(*(void (__fastcall **)(__int64, _DWORD *, _QWORD, __int64, __int64))(*(_QWORD *)(a1 + 544) + 8LL))(
a1,
v39,
(unsigned int)v8[26],
a5,
v11);
++*a6;
v27 = *(_DWORD *)(a1 + 356);
v28 = v8[25];
v29 = v27 + v8[26];
if ( v37 <= v29 )
v29 = 0;
v8[26] = v29;
if ( v37 <= v28 )
{
v8[25] = 0;
v28 = 0;
}
v10 = a6;
v8[27] = v27 + v28;
}
}