//
// jinit_upsampler from 0xc15a5c to 0xc15c6c (528 bytes)
//
// 2 xrefs:
// > jinit_master_decompress @ 0xc14034
// > ??> @ 0xb86b0
//
// 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 jinit_upsampler(void (__fastcall ***a1)(_QWORD))
{
__int64 v2; // x27
int v3; // w1
__int64 result; // x0
_DWORD *v5; // x20
int *v6; // x26
_QWORD *v7; // x24
int v8; // w25
_BYTE *i; // x27
int v10; // w4
int v11; // w6
int v12; // w2
int v13; // w0
int v14; // w3
int v15; // w1
int v16; // w5
int v17; // w1
void (__fastcall *v18)(_QWORD); // x28
__int64 v19; // x0
void (__fastcall *v20)(_QWORD); // x2
void (__fastcall *v21)(_QWORD); // x2
v2 = ((__int64 (*)(void))*a1[1])();
a1[80] = (void (__fastcall **)(_QWORD))v2;
v3 = *((_DWORD *)a1 + 100);
*(_QWORD *)v2 = sub_C15288;
*(_DWORD *)(v2 + 16) = 0;
*(_QWORD *)(v2 + 8) = sub_C152A0;
if ( v3 )
{
v21 = **a1;
*((_DWORD *)*a1 + 10) = 26;
v21(a1);
}
result = *((unsigned int *)a1 + 14);
v5 = a1[38];
if ( (int)result > 0 )
{
v6 = (int *)(v2 + 192);
v7 = (_QWORD *)(v2 + 24);
v8 = 0;
for ( i = (_BYTE *)(v2 + 232); ; ++i )
{
while ( 1 )
{
v10 = v5[13];
v11 = v5[9];
v12 = v5[2];
v13 = v5[3] * v5[10] / *((_DWORD *)a1 + 107);
v14 = *((_DWORD *)a1 + 104);
v15 = *((_DWORD *)a1 + 106);
v16 = *((_DWORD *)a1 + 105);
*v6 = v13;
if ( v10 )
break;
v7[10] = sub_C15408;
LABEL_6:
result = *((unsigned int *)a1 + 14);
++v8;
v5 += 24;
++v6;
++v7;
++i;
if ( (int)result <= v8 )
return result;
}
v17 = v12 * v11 / v15;
if ( v13 != v16 || v17 != v14 )
break;
++v8;
v7[10] = sub_C15400;
result = *((unsigned int *)a1 + 14);
v5 += 24;
++v6;
++v7;
if ( (int)result <= v8 )
return result;
}
if ( v14 != 2 * v17 )
goto LABEL_13;
if ( v13 == v16 )
{
v7[10] = sub_C15410;
}
else
{
if ( v16 != 2 * v13 )
{
LABEL_13:
if ( v14 % v17 || v16 % v13 )
{
v20 = **a1;
*((_DWORD *)*a1 + 10) = 39;
v20(a1);
}
else
{
v7[10] = sub_C15688;
*i = v14 / v17;
i[10] = v16 / v13;
}
goto LABEL_16;
}
v7[10] = sub_C15794;
}
LABEL_16:
v18 = a1[1][2];
v19 = jround_up(*((unsigned int *)a1 + 34), *((int *)a1 + 104));
*v7 = ((__int64 (__fastcall *)(void (__fastcall ***)(_QWORD), __int64, __int64, _QWORD))v18)(
a1,
1,
v19,
*((unsigned int *)a1 + 105));
goto LABEL_6;
}
return result;
}