//
// sub_76D948 from 0x76d948 to 0x76da96 (334 bytes)
//
// 2 xrefs:
// > sub_76C6C4 @ 0x76c756
// > sub_76C6C4 @ 0x76c76e
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:59:13 +0000
//
int __fastcall sub_76D948(int result, int *a2, int *a3, int a4, int *a5)
{
int *v5; // r8
int *v9; // r4
int *v10; // r9
int v11; // r5
int v12; // r9
int v13; // r2
int *v14; // r8
int *v15; // r5
int v16; // r10
int *v17; // r9
int v18; // r11
int v19; // r10
int v20; // r11
int v21; // r10
int v22; // r8
int v23; // r3
int *v24; // r5
int v25; // r3
int v26; // t1
int v27; // r3
int v28; // t1
int v29; // r11
int v30; // r10
int v31; // [sp+4h] [bp-8h]
v5 = (int *)result;
v9 = a5;
v10 = (int *)result;
if ( a4 == 1 )
{
if ( a5 )
*a5 = *(_DWORD *)result;
}
else if ( a4 == 2 )
{
v11 = *(_DWORD *)result;
v12 = *(a2 - 1);
result = sub_769114((int)a3, v12, *(_DWORD *)result);
if ( result )
{
if ( a5 )
*a5 = v12;
v13 = *v5;
}
else
{
if ( a5 )
*a5 = v11;
v13 = *(a2 - 1);
}
if ( a5 != (int *)-4 )
a5[1] = v13;
}
else if ( a4 )
{
if ( a4 > 8 )
{
v20 = a4 >> 1;
v21 = 4 * (a4 >> 1);
v22 = result + v21;
sub_76C6C4(result, (int *)(result + v21), a3, a4 >> 1, a5, a4 >> 1);
v23 = a4 - v20;
v31 = a4 - v20;
v24 = (int *)v22;
result = sub_76C6C4(v22, a2, a3, v23, &a5[v21 / 4u], v31);
while ( 1 )
{
if ( v10 == (int *)v22 )
{
while ( v24 != a2 )
{
v26 = *v24++;
v25 = v26;
if ( v9 )
*v9 = v25;
++v9;
}
return result;
}
if ( v24 == a2 )
break;
v29 = *v24;
v30 = *v10;
result = sub_769114((int)a3, *v24, *v10);
if ( result )
{
if ( v9 )
*v9 = v29;
++v24;
}
else
{
if ( v9 )
*v9 = v30;
++v10;
}
++v9;
}
do
{
v28 = *v10++;
v27 = v28;
if ( v9 )
*v9 = v27;
++v9;
}
while ( (int *)v22 != v10 );
}
else if ( (int *)result != a2 )
{
if ( a5 )
*a5 = *(_DWORD *)result;
v14 = (int *)(result + 4);
v15 = a5;
while ( v14 != a2 )
{
v16 = *v14;
v17 = v15 + 1;
v18 = *v15;
result = sub_769114((int)a3, *v14, *v15);
if ( result )
{
v15[1] = v18;
while ( v15 != a5 )
{
v19 = *(v15 - 1);
result = sub_769114((int)a3, *v14, v19);
if ( !result )
break;
*v15-- = v19;
}
*v15 = *v14;
}
else
{
v15[1] = v16;
}
++v14;
v15 = v17;
}
}
}
return result;
}