//
// sub_765A94 from 0x765a94 to 0x765b70 (220 bytes)
//
// 9 xrefs:
// > sub_765B70 @ 0x765b96
// > sub_765B70 @ 0x765bca
// > sub_765BD8 @ 0x765bf6
// > sub_765C04 @ 0x765d18
// > sub_7660F4 @ 0x766208
// > sub_766DD8 @ 0x766f04
// > sub_7671E0 @ 0x7672de
// > sub_7674C8 @ 0x767604
// > sub_7676FC @ 0x767800
//
// 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
//
_DWORD *__fastcall sub_765A94(_DWORD *result, int a2, unsigned __int8 *a3, int a4, char *a5, char *a6)
{
int v6; // r7
unsigned int v7; // r3
int v8; // r4
unsigned int v9; // lr
bool v11; // cf
_DWORD *v12; // r4
char *v13; // r3
int v14; // t1
_DWORD *v15; // r12
char *v16; // r3
int v17; // r5
int v18; // t1
int v19; // r5
unsigned __int8 *v20; // lr
_DWORD *v21; // r7
char v22; // r5
int v23; // t1
char *v24; // r3
int v25; // r5
int v26; // t1
int v27; // r5
v6 = 0;
v7 = a4 - 1;
v8 = *a3;
v9 = 0;
while ( v8 < (a6 - a5) >> 2 && (char)v8 > 0 )
{
v11 = v9 >= v7;
a6 -= 4 * v8;
if ( v9 >= v7 )
++v6;
else
++v9;
if ( !v11 )
v8 = a3[v9];
}
if ( a5 != a6 )
{
v12 = result - 1;
v13 = a5;
do
{
v14 = *(_DWORD *)v13;
v13 += 4;
v12[1] = v14;
++v12;
}
while ( v13 != a6 );
result = (_DWORD *)((char *)result + ((a6 - (a5 + 4)) & 0xFFFFFFFC) + 4);
}
while ( 1 )
{
v11 = v6-- != 0;
if ( !v11 )
break;
while ( 1 )
{
*result = a2;
v15 = result + 1;
if ( !a3[v9] )
break;
v16 = a6 - 4;
v17 = (unsigned __int8)(a3[v9] - 1);
do
{
v18 = *((_DWORD *)v16 + 1);
v16 += 4;
result[1] = v18;
++result;
}
while ( v16 != &a6[4 * v17] );
v11 = v6-- != 0;
v19 = v17 + 1;
result = &v15[v19];
a6 += v19 * 4;
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 - 4;
v25 = (unsigned __int8)(v22 - 1);
do
{
v26 = *((_DWORD *)v24 + 1);
v24 += 4;
result[1] = v26;
++result;
}
while ( v24 != &a6[4 * v25] );
v27 = v25 + 1;
result = &v21[v27];
a6 += v27 * 4;
if ( v20 == a3 )
return result;
}
++result;
}
return result;
}