//
// sub_74DF1C from 0x74df1c to 0x74dfe8 (204 bytes)
//
// 9 xrefs:
// > sub_74DFE8 @ 0x74e004
// > sub_74DFE8 @ 0x74e032
// > sub_74E040 @ 0x74e05c
// > sub_74E068 @ 0x74e16e
// > sub_74E484 @ 0x74e58c
// > sub_74F1DC @ 0x74f314
// > sub_74F5D4 @ 0x74f6dc
// > sub_74F8B8 @ 0x74fa00
// > sub_74FAF4 @ 0x74fc02
//
// 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
//
_BYTE *__fastcall sub_74DF1C(_BYTE *result, char a2, unsigned __int8 *a3, int a4, char *a5, char *a6)
{
int v6; // lr
unsigned int v7; // r3
int v8; // r4
unsigned int v9; // r12
bool v11; // cf
_BYTE *v12; // r4
char *v13; // r3
char v14; // t1
_BYTE *v15; // r8
char *v16; // r3
int v17; // r7
char v18; // t1
int v19; // r7
unsigned __int8 *v20; // r12
_BYTE *v21; // lr
char v22; // r7
int v23; // t1
char *v24; // r3
int v25; // r7
char v26; // t1
int v27; // r7
v6 = 0;
v7 = a4 - 1;
v8 = *a3;
v9 = 0;
while ( a6 - a5 > v8 && (char)v8 > 0 )
{
v11 = v9 >= v7;
a6 -= v8;
if ( v9 >= v7 )
++v6;
else
++v9;
if ( !v11 )
v8 = a3[v9];
}
if ( a5 != a6 )
{
v12 = result - 1;
v13 = a5;
do
{
v14 = *v13++;
*++v12 = v14;
}
while ( v13 != a6 );
result += a6 - a5;
}
while ( 1 )
{
v11 = v6-- != 0;
if ( !v11 )
break;
while ( 1 )
{
*result = a2;
v15 = result + 1;
if ( !a3[v9] )
break;
v16 = a6 - 1;
v17 = (unsigned __int8)(a3[v9] - 1);
do
{
v18 = *++v16;
*++result = v18;
}
while ( v16 != &a6[v17] );
v11 = v6-- != 0;
v19 = v17 + 1;
result = &v15[v19];
a6 += v19;
if ( !v11 )
goto LABEL_20;
}
++result;
}
LABEL_20:
v20 = &a3[v9];
while ( v20 != a3 )
{
while ( 1 )
{
*result = a2;
v21 = result + 1;
v23 = *--v20;
v22 = v23;
if ( !v23 )
break;
v24 = a6 - 1;
v25 = (unsigned __int8)(v22 - 1);
do
{
v26 = *++v24;
*++result = v26;
}
while ( v24 != &a6[v25] );
v27 = v25 + 1;
result = &v21[v27];
a6 += v27;
if ( v20 == a3 )
return result;
}
++result;
}
return result;
}