//
// sub_D21B30 from 0xd21b30 to 0xd21ce0 (432 bytes)
//
// 2 xrefs:
// > sub_D24634 @ 0xd246c0
// > sub_D26564 @ 0xd266b0
//
// 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_D21B30(__int64 a1, __int64 *a2, int a3)
{
__int64 *v3; // x21
__int64 *v4; // x28
unsigned __int8 *v5; // x1
int i; // w2
int v9; // w1
__int64 v10; // x0
int v11; // w1
_DWORD *v13; // x21
int v14; // w0
v3 = a2;
v4 = a2;
v5 = *(unsigned __int8 **)(a1 + 24);
for ( i = *v5; i == 86 || i == 114; i = *v5 )
{
*(_QWORD *)(a1 + 24) = v5 + 1;
if ( i != 114 )
{
if ( a3 )
v9 = 29;
else
v9 = 26;
*(_DWORD *)(a1 + 80) += 9;
LABEL_8:
v10 = sub_D21A30(a1, v9, 0, 0);
*v4 = v10;
if ( !v10 )
return nullptr;
goto LABEL_9;
}
if ( a3 )
v11 = 28;
else
v11 = 25;
*(_DWORD *)(a1 + 80) += 9;
v10 = sub_D21A30(a1, v11, 0, 0);
*v4 = v10;
if ( !v10 )
return nullptr;
LABEL_9:
v5 = *(unsigned __int8 **)(a1 + 24);
v4 = (__int64 *)(v10 + 8);
}
if ( i == 75 )
{
*(_QWORD *)(a1 + 24) = v5 + 1;
if ( a3 )
v9 = 30;
else
v9 = 27;
*(_DWORD *)(a1 + 80) += 6;
goto LABEL_8;
}
if ( !a3 && i == 70 && v3 != v4 )
{
do
{
while ( 1 )
{
v13 = (_DWORD *)*v3;
v14 = *v13;
if ( *v13 != 26 )
break;
*v13 = 29;
v3 = (__int64 *)(v13 + 2);
if ( v3 == v4 )
return v4;
}
if ( v14 == 27 )
{
*v13 = 30;
}
else if ( v14 == 25 )
{
*v13 = 28;
}
v3 = (__int64 *)(v13 + 2);
}
while ( v3 != v4 );
}
return v4;
}