//
// sub_100427620 from 0x100427620 to 0x1004277cc (428 bytes)
//
// 1 xrefs:
// > sub_100426FFC @ 0x10042726c
//
// 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_100427620(__int64 a1, __int64 *a2, char *a3, _BYTE *a4)
{
int v6; // w9
int v9; // w8
__int64 v10; // x1
__int64 result; // x0
__int64 v12; // x22
int *v13; // x23
int v14; // w9
__int64 v15; // x8
__int64 v16; // x23
int v17; // t1
int v18; // w21
__int64 v19; // x8
char v20; // w20
int v21; // w8
int v22; // w9
int v23; // w8
__int64 v24; // x1
__int64 v25; // x8
if ( !a4 )
return 28;
*a4 = 0;
v6 = *(_DWORD *)(a1 + 36);
if ( v6 == -1 )
return 28;
v9 = *(_DWORD *)(a1 + 8);
if ( v6 == v9 )
{
if ( v6 >= 2 )
v10 = (unsigned int)(2 * v6);
else
v10 = 4;
result = sub_100427E9C(a1, v10);
if ( (_DWORD)result )
return result;
v9 = *(_DWORD *)(a1 + 8);
}
if ( !v9 )
return 28;
v12 = *a2;
v13 = (int *)(*(_QWORD *)a1 + 4LL * (int)((v9 - 1) & (HIDWORD(v12) ^ v12)));
v14 = *v13;
if ( *v13 == -1 )
{
LABEL_14:
v18 = *(_DWORD *)(a1 + 32);
if ( v18 == -1 )
{
v20 = *a3;
v18 = *(_DWORD *)(a1 + 24);
v21 = *(_DWORD *)(a1 + 28);
if ( v21 < 0 )
v21 = -v21;
v22 = *(_DWORD *)(a1 + 24);
if ( v21 <= v18 )
{
v23 = (int)(float)((float)v21 * 1.5);
if ( v23 <= v18 + 1 )
v23 = v18 + 1;
if ( v23 <= 4 )
v24 = 4;
else
v24 = (unsigned int)v23;
result = sub_100427BA8(a1 + 16, v24);
if ( (_DWORD)result )
return result;
v22 = *(_DWORD *)(a1 + 24);
}
v25 = *(_QWORD *)(a1 + 16) + 16LL * v22;
*(_QWORD *)v25 = v12;
*(_DWORD *)(v25 + 8) = -1;
*(_BYTE *)(v25 + 12) = v20;
++*(_DWORD *)(a1 + 24);
}
else
{
v19 = *(_QWORD *)(a1 + 16) + 16LL * v18;
*(_DWORD *)(a1 + 32) = *(_DWORD *)(v19 + 8);
*(_DWORD *)(v19 + 8) = -1;
*(_QWORD *)v19 = v12;
*(_BYTE *)(v19 + 12) = *a3;
}
*v13 = v18;
++*(_DWORD *)(a1 + 36);
return 0;
}
v15 = *(_QWORD *)(a1 + 16);
while ( *(_QWORD *)(v15 + 16LL * v14) != v12 )
{
v16 = v15 + 16LL * v14;
v17 = *(_DWORD *)(v16 + 8);
v13 = (int *)(v16 + 8);
v14 = v17;
if ( v17 == -1 )
goto LABEL_14;
}
*a4 = *(_BYTE *)(v15 + 16LL * v14 + 12);
return 0;
}