//
// sub_773D18 from 0x773d18 to 0x773da0 (136 bytes)
//
// 1 xrefs:
// > sub_7732C4 @ 0x7732fc
//
// 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_773D18(_BYTE *a1, int a2, unsigned __int8 *a3, unsigned int *a4)
{
_BYTE *v5; // r6
_BYTE *v7; // r4
int v8; // r2
int v9; // r1
char *v10; // r1
char v11; // r2
int v12; // t1
unsigned int *v14; // r8
int v15; // r0
v5 = &a1[a2 - 1];
v7 = a1;
while ( 1 )
{
v8 = *a3;
if ( !*a3 )
break;
while ( 1 )
{
if ( v7 >= v5 )
goto LABEL_20;
if ( v8 != 37 )
goto LABEL_2;
v9 = a3[1];
if ( v9 != 115 )
break;
v10 = (char *)*a4++;
v11 = *v10;
if ( *v10 )
{
while ( 1 )
{
*v7++ = v11;
v12 = (unsigned __int8)*++v10;
v11 = v12;
if ( !v12 )
break;
if ( v7 == v5 )
goto LABEL_20;
}
}
a3 += 2;
v8 = *a3;
if ( !*a3 )
goto LABEL_16;
}
if ( v9 == 122 )
{
if ( a3[2] != 117 )
goto LABEL_2;
v14 = a4 + 1;
v15 = sub_773C9C(v7, v5 - v7, *a4);
if ( v15 <= 0 )
LABEL_20:
sub_773C4C(a1, (int)v7);
v7 += v15;
a3 += 3;
a4 = v14;
}
else
{
if ( v9 == 37 )
{
++a3;
LOBYTE(v8) = 37;
}
LABEL_2:
*v7 = v8;
++a3;
++v7;
}
}
LABEL_16:
*v7 = v8;
return v7 - a1;
}