//
// sub_77BE24 from 0x77be24 to 0x77bf02 (222 bytes)
//
// 2 xrefs:
// > sub_77D960 @ 0x77d99a
// > sub_77EC0C @ 0x77ec66
//
// 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
//
int **__fastcall sub_77BE24(_DWORD *a1, int **a2, int a3)
{
unsigned __int8 *v3; // r3
int **v5; // r9
int v7; // r0
int **v8; // r5
int v9; // r1
_DWORD *v10; // r0
int v11; // r1
int *v13; // r7
int v14; // r3
v3 = (unsigned __int8 *)a1[3];
v5 = a2;
v7 = *v3;
v8 = a2;
while ( v7 == 86 || v7 == 114 )
{
a1[3] = v3 + 1;
if ( v7 == 114 )
{
v11 = 28;
if ( !a3 )
v11 = 25;
}
else
{
v11 = 29;
if ( !a3 )
v11 = 26;
}
a1[12] += 9;
v10 = sub_77BD98(a1, v11, 0, 0);
*v8 = v10;
if ( !v10 )
return nullptr;
LABEL_7:
v3 = (unsigned __int8 *)a1[3];
v8 = (int **)(v10 + 1);
v7 = *v3;
}
if ( v7 == 75 )
{
a1[3] = v3 + 1;
v9 = 30;
if ( !a3 )
v9 = 27;
a1[12] += 6;
v10 = sub_77BD98(a1, v9, 0, 0);
*v8 = v10;
if ( !v10 )
return nullptr;
goto LABEL_7;
}
if ( !a3 && v7 == 70 && v5 != v8 )
{
do
{
while ( 1 )
{
v13 = *v5;
v14 = **v5;
if ( v14 != 26 )
break;
*v13 = 29;
v5 = (int **)(v13 + 1);
if ( v13 + 1 == (int *)v8 )
return v8;
}
if ( v14 == 27 )
{
*v13 = 30;
}
else if ( v14 == 25 )
{
*v13 = 28;
}
v5 = (int **)(v13 + 1);
}
while ( v13 + 1 != (int *)v8 );
}
return v8;
}