//
// sub_6B376 from 0x6b376 to 0x6b444 (206 bytes)
//
// 4 xrefs:
// > sub_52628 @ 0x52658
// > sub_52628 @ 0x52682
// > sub_527B6 @ 0x527e6
// > sub_527B6 @ 0x52816
//
// 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_6B376(int a1, int *a2, int a3, int a4)
{
int v4; // r4
int v7; // r0
int v8; // r5
int v10; // r4
int *v11; // r12
int v12; // r2
int v13; // r3
int v14; // r0
int v15; // r3
int v16; // r2
int *v17; // [sp+4h] [bp-34h] BYREF
int v18[6]; // [sp+8h] [bp-30h] BYREF
v17 = a2;
v18[0] = a3;
v18[1] = a4;
v4 = *a2;
if ( (unsigned int)*a2 > 0x6400000 )
return 28;
memset(v18, 0, 0x14u);
v7 = sub_6AC9C((int *)(a1 + 1140), v4, 0, v18);
if ( !v7 )
{
if ( *(_BYTE *)(a1 + 624) )
{
v8 = 0;
goto LABEL_7;
}
v7 = sub_BFFC4(&v17);
if ( !v7 )
{
v11 = v17;
v12 = 0;
a2[1] = (int)v17;
while ( v12 != 512 )
{
v13 = a1 + v12;
if ( *(unsigned __int8 *)(a1 + v12 + 628) == *((unsigned __int8 *)a2 + 8)
&& *(unsigned __int8 *)(v13 + 629) == *((unsigned __int8 *)a2 + 9) )
{
*(_DWORD *)(v13 + 636) = v11;
v14 = *(_DWORD *)(v13 + 640);
if ( v14 <= v4 )
v14 = v4;
*(_DWORD *)(v13 + 640) = v14;
break;
}
v12 += 16;
}
qmemcpy((void *)v18[1], a2, v18[3]);
v16 = v18[4];
if ( v18[4] )
qmemcpy((void *)v18[2], (char *)a2 + v18[3], v18[4]);
v8 = sub_6AD9E((_DWORD *)(a1 + 1140), v4, v16, v15);
v10 = v8;
if ( v8 )
v10 = 1;
goto LABEL_8;
}
}
v8 = v7;
LABEL_7:
v10 = 1;
LABEL_8:
sub_5284E(v18);
if ( !v10 )
return 0;
return v8;
}