//
// sub_918F0 from 0x918f0 to 0x91904 (20 bytes)
//
// 2 xrefs:
// > sub_8D6F8 @ 0x8ed54
// > sub_8D6F8 @ 0x8ed98
//
// 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 __usercall sub_918F0@(
__int64 a1@,
int a2@,
__int64 a3@,
int a4@,
int a5@,
int a6@,
char a7@)
{
int v7; // w8
__int64 v8; // x9
int v9; // w13
int v11; // w13
char *v12; // x14
int v13; // w15
__int64 v14; // x13
__int64 v15; // x17
int v16; // w15
int v17; // w16
int v18; // w14
int v19; // w9
int v21; // w9
__int64 v22; // x8
int v23; // w9
int v24; // w10
__int64 v25; // x20
int v27; // [xsp+0h] [xbp+0h]
v27 = v23;
v7 = *(_DWORD *)a1;
LODWORD(v8) = *(_DWORD *)(a1 + 4);
if ( (int)v8 >= a2 )
{
LABEL_29:
v21 = *(_DWORD *)(a1 + 8);
*(_DWORD *)a1 = v7 + 1;
*(_DWORD *)(a1 + 12) = v21 >> 16;
*(_BYTE *)(v25 + 60) |= a7;
return 0;
}
v9 = *(unsigned __int16 *)(a3 + 3LL * (int)v8 + 1);
if ( v7 != v9 )
{
v19 = *(_DWORD *)(a1 + 8) + *(_DWORD *)(a1 + 16);
if ( v19 < 0 && a4 == 2 )
v19 = 0;
*(_DWORD *)(a1 + 8) = v19;
goto LABEL_29;
}
while ( 1 )
{
if ( (int)v8 >= a2 || v7 != (unsigned __int16)v9 )
goto LABEL_29;
if ( (a4 & 2) != 0 )
break;
LABEL_11:
while ( (a4 & 4) != 0 && (int)v8 >= a6 )
{
v11 = a5;
if ( a6 <= a5 )
{
v22 = 3LL * a5;
goto LABEL_31;
}
LABEL_14:
*(_DWORD *)(a1 + 4) = v11;
LODWORD(v8) = v11;
v7 = *(unsigned __int16 *)(a3 + 3LL * v11 + 1) - 1;
*(_DWORD *)a1 = v7;
if ( (a4 & 2) != 0 )
goto LABEL_9;
}
v12 = (char *)(a3 + 3LL * (int)v8);
v13 = *v12;
if ( (_DWORD)v8 == a2 - 1 )
{
*(_DWORD *)(a1 + 12) = v13;
*(_BYTE *)(a1 + 20) = 1;
return 0;
}
v14 = (int)v8;
v8 = (int)v8 + 1LL;
v15 = a3 + 3 * v14;
v9 = *(unsigned __int16 *)(a3 + 3 * v8 + 1);
v16 = v13 << 16;
v17 = v9 - *(unsigned __int16 *)(v15 + 1);
if ( v17 )
v18 = ((v12[3] << 16) - v16) / v17;
else
v18 = 0;
*(_DWORD *)(a1 + 16) = v18;
*(_DWORD *)(a1 + 4) = v8;
*(_DWORD *)(a1 + 8) = v16;
}
LABEL_9:
if ( (int)v8 < v24 || *(_BYTE *)(v25 + 188) )
goto LABEL_11;
v11 = v27;
if ( v24 != v27 )
goto LABEL_14;
v22 = 3LL * (int)v8;
LABEL_31:
*(_DWORD *)(a1 + 12) = *(char *)(a3 + v22);
return 0;
}