//
// sub_764FC from 0x764fc to 0x7676c (624 bytes)
//
// 2 xrefs:
// > sub_6B868 @ 0x6b890
// > sub_7BC78 @ 0x7bd88
//
// 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_764FC(__int64 result, char a2)
{
__int64 v3; // x19
__int64 v4; // x23
char *v5; // x8
__int64 v6; // x9
__int64 v7; // x8
__int64 v8; // x0
__int64 (__fastcall *v9)(__int64); // x8
__int64 (__fastcall *v10)(__int64, __int64, _QWORD, _QWORD, _QWORD); // x8
__int64 i; // x8
char *v12; // x10
int v13; // w8
unsigned int j; // w20
__int64 v15; // x0
__int64 (__fastcall *v16)(__int64, int *); // x8
int v17; // w20
__int64 v18; // x1
_BYTE v19[20]; // [xsp+8h] [xbp-48h] BYREF
int v20; // [xsp+1Ch] [xbp-34h] BYREF
int v21; // [xsp+28h] [xbp-28h] BYREF
_BYTE v22[4]; // [xsp+2Ch] [xbp-24h] BYREF
v22[0] = 0;
v21 = 0;
v3 = result;
v4 = result + 69744;
if ( !byte_1205A0[*(unsigned int *)(result + 69816)] )
{
result = sub_E694C(&v21);
if ( (a2 & 1) == 0
|| (unsigned int)(v21 - *(_DWORD *)(v4 + 80)) > 0x3E7
|| *(_BYTE *)(*(_QWORD *)(v3 + 1648) + 785LL) )
{
*(_DWORD *)(v4 + 80) = v21;
result = sub_E7280(v22);
if ( (_DWORD)result )
return result;
if ( v22[0] )
{
for ( i = 0; i != 8; ++i )
{
v12 = &byte_1205A0[i];
*v12 = 1;
v12[8] = 1;
}
}
}
}
v5 = &byte_1205A0[*(unsigned int *)(v4 + 72)];
if ( v5[8] )
{
v5[8] = 0;
v6 = *(_QWORD *)(v3 + 1648);
v7 = *(_QWORD *)(v6 + 944);
*(_BYTE *)(v6 + 784) = 0;
if ( v7 )
{
v8 = sub_76FF8();
result = v9(v8);
}
}
if ( (a2 & 1) == 0 )
return 0;
if ( !byte_1205A0[*(unsigned int *)(v4 + 72)] )
goto LABEL_30;
v10 = *(__int64 (__fastcall **)(__int64, __int64, _QWORD, _QWORD, _QWORD))(v4 + 456);
if ( v10 && (*(_BYTE *)(v4 + 464) & 1) != 0 )
{
result = v10(v3, 1, 0, 0, *(_QWORD *)v4);
}
else
{
if ( *(_DWORD *)(v3 + 1656) != 2 )
{
result = sub_6B868(v3, &v20);
if ( (_DWORD)result )
return result;
v13 = v20;
if ( v20 )
{
for ( j = 0; (int)j < v13; ++j )
{
result = sub_76FC8();
if ( (_DWORD)result )
return result;
if ( !(unsigned int)sub_77008(v19) )
{
v13 = v20;
break;
}
v13 = v20;
}
v18 = v13 == j ? 0LL : j;
result = sub_7691C(v3, v18);
if ( !(_DWORD)result )
goto LABEL_29;
}
goto LABEL_11;
}
result = sub_7676C(v3, *(unsigned int *)(v4 + 84), *(unsigned int *)(v4 + 88));
if ( (_DWORD)result )
{
LABEL_11:
result = sub_76FE8();
if ( (_DWORD)result )
return result;
}
}
LABEL_29:
byte_1205A0[*(unsigned int *)(v4 + 72)] = 0;
LABEL_30:
if ( !*(_BYTE *)(*(_QWORD *)(v3 + 1648) + 785LL) )
return 0;
result = sub_77020(result);
if ( !(_DWORD)result )
{
v20 = 0;
if ( !*(_QWORD *)(*(_QWORD *)(v3 + 1648) + 824LL) || (v15 = sub_76FF8(), result = v16(v15, &v20), !(_DWORD)result) )
{
if ( *(_DWORD *)(v3 + 1664) )
{
v17 = 0;
*(_DWORD *)(v3 + 1664) = 0;
while ( v17 < v20 )
{
result = sub_76FC8();
if ( (_DWORD)result )
return result;
if ( !(unsigned int)sub_77008(v19) )
{
*(_DWORD *)(v3 + 1664) = v17;
break;
}
++v17;
}
}
if ( !(unsigned int)sub_77028() )
return 0;
result = sub_76FE8();
if ( !(_DWORD)result )
return 0;
}
}
return result;
}