//
// sub_7642F0 from 0x7642f0 to 0x76449a (426 bytes)
//
// 6 xrefs:
// > sub_76449C @ 0x7644f8
// > sub_768348 @ 0x768732
// > sub_768348 @ 0x7687d8
// > sub_768348 @ 0x768984
// > sub_768348 @ 0x7689b8
// > sub_768348 @ 0x768b42
//
// 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
//
_DWORD *__fastcall sub_7642F0(
_DWORD *a1,
int a2,
_DWORD *a3,
int a4,
_DWORD *a5,
int a6,
int *a7,
int a8,
int a9,
unsigned int a10,
int a11,
_DWORD *a12)
{
int v12; // r5
void *v16; // r0
int v17; // r1
void *v18; // r10
int v19; // r6
unsigned int v20; // r11
int v21; // r9
bool v22; // zf
int *v23; // r3
int v24; // r0
int *v25; // r2
int v26; // r0
unsigned int v27; // r3
int *v28; // r3
int v29; // r1
int v31; // r0
int v34; // [sp+Ch] [bp-10h]
v16 = sub_764188(a11 + 108);
v17 = a4;
if ( a10 == 2 )
v12 = 10;
v18 = v16;
if ( a10 != 2 )
{
if ( a10 == 4 )
v12 = 1000;
else
v12 = 1;
}
v19 = 0;
v20 = 0;
while ( a3 )
{
if ( v17 == -1 )
{
v23 = (int *)a3[2];
if ( (unsigned int)v23 >= a3[3] )
{
v24 = (*(int (__fastcall **)(_DWORD *))(*a3 + 36))(a3);
v17 = -1;
}
else
{
v24 = *v23;
}
if ( v24 == -1 )
break;
v17 = v24;
}
v21 = 0;
if ( !a5 )
{
if ( v20 >= a10 )
goto LABEL_14;
LABEL_32:
v21 = v17;
goto LABEL_33;
}
if ( a6 == -1 )
goto LABEL_25;
LABEL_12:
if ( (a6 == -1) == v21 || v20 >= a10 )
goto LABEL_14;
if ( !a3 )
{
v21 = v17;
goto LABEL_33;
}
if ( v17 != -1 )
goto LABEL_32;
v28 = (int *)a3[2];
if ( (unsigned int)v28 >= a3[3] )
v29 = (*(int (__fastcall **)(_DWORD *))(*a3 + 36))(a3);
else
v29 = *v28;
if ( v29 == -1 )
a3 = nullptr;
else
v21 = v29;
if ( v29 == -1 )
v21 = -1;
LABEL_33:
v26 = (*(int (__fastcall **)(void *))(*(_DWORD *)v18 + 48))(v18) - 48;
if ( (unsigned __int8)v26 > 9u || (v19 = v26 + 10 * v19, v12 * v19 > a9) || a8 >= v12 * v19 + v12 )
{
v17 = v21;
LABEL_14:
if ( a10 == v20 )
goto LABEL_50;
goto LABEL_15;
}
v17 = v21;
v12 /= 10;
if ( a3 )
{
v27 = a3[2];
if ( v27 >= a3[3] )
(*(void (__fastcall **)(_DWORD *, int))(*a3 + 40))(a3, v21);
else
a3[2] = v27 + 4;
v17 = -1;
}
++v20;
}
if ( a5 )
{
a3 = nullptr;
v21 = 1;
if ( a6 != -1 )
goto LABEL_12;
LABEL_25:
v25 = (int *)a5[2];
if ( (unsigned int)v25 >= a5[3] )
{
v34 = v17;
v31 = (*(int (__fastcall **)(_DWORD *))(*a5 + 36))(a5);
v17 = v34;
a6 = v31;
}
else
{
a6 = *v25;
}
if ( a6 == -1 )
a5 = nullptr;
goto LABEL_12;
}
a3 = nullptr;
if ( a10 == v20 )
goto LABEL_50;
LABEL_15:
v22 = v20 == 2;
if ( v20 == 2 )
v22 = a10 == 4;
if ( !v22 )
{
*a12 |= 4u;
goto LABEL_51;
}
v19 -= 100;
LABEL_50:
*a7 = v19;
LABEL_51:
*a1 = a3;
a1[1] = v17;
return a1;
}