//
// sub_995304 from 0x995304 to 0x99549a (406 bytes)
//
// 4 xrefs:
// > sub_993ED0 @ 0x994732
// > sub_9951EC @ 0x995272
// > sub_9951EC @ 0x995292
// > sub_9957F0 @ 0x995f2a
//
// 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 12:06:39 +0000
//
_DWORD *__fastcall sub_995304(_DWORD *a1, _DWORD *a2)
{
_DWORD *result; // r0
int v5; // r0
_DWORD *v6; // r4
int v7; // r2
bool v8; // cc
int v9; // r0
int v10; // r10
int v11; // r11
int v12; // r9
_DWORD *v13; // r5
unsigned int *v14; // r8
int v15; // r2
int v16; // r5
unsigned int *v17; // lr
unsigned int v18; // r9
unsigned int *v19; // r10
unsigned int *v20; // r11
unsigned int v21; // r0
int v22; // r4
int v23; // r0
unsigned int v24; // r3
unsigned int v25; // r6
unsigned int v26; // r5
unsigned int v27; // r1
unsigned int v28; // r3
unsigned int v29; // r6
unsigned int v30; // r4
unsigned int v31; // r12
unsigned int *v32; // r0
unsigned int *v33; // r5
unsigned int v34; // r3
unsigned int v35; // t1
unsigned int v36; // r1
unsigned int v37; // r2
unsigned int v38; // t1
int v39; // r0
int v40; // r0
int v41; // r1
int v42; // [sp+0h] [bp-18h]
_DWORD *v43; // [sp+4h] [bp-14h]
unsigned int v44; // [sp+8h] [bp-10h]
result = &unk_C50F20;
if ( a1 != (_DWORD *)&unk_C50F20 && a2 != (_DWORD *)&unk_C50F20 )
{
v5 = a2[4];
v6 = a1;
v7 = a1[4];
v8 = v7 < v5;
if ( v7 < v5 )
v6 = a2;
v9 = v6[1];
v10 = v6[4];
if ( v8 )
a2 = a1;
v11 = a2[4];
v12 = v11 + v10;
if ( v11 + v10 > v6[2] )
++v9;
v13 = sub_993E20(v9);
result = &unk_C50F20;
if ( v13 != (_DWORD *)&unk_C50F20 )
{
v14 = v13 + 5;
if ( v12 >= 1 )
{
v15 = (int)(v13 + 6);
if ( &v13[v12 + 5] > v13 + 6 )
v15 = (int)&v13[v12 + 5];
memset(v13 + 5, 0, (-21 - (_DWORD)v13 + v15 + 4) & 0xFFFFFFFC);
}
v42 = v11 + v10;
v43 = v13;
if ( v11 >= 1 )
{
v44 = (unsigned int)&a2[v11 + 5];
v16 = (int)(v6 + 6);
if ( &v6[v10 + 5] > v6 + 6 )
v16 = (int)&v6[v10 + 5];
v17 = v6 + 5;
v18 = (unsigned int)&v6[v10 + 5];
v19 = (_DWORD *)((char *)v43 + ((-21 - (_DWORD)v6 + v16) & 0xFFFFFFFC) + 24);
v20 = a2 + 5;
do
{
v21 = *v20;
v22 = (unsigned __int16)*v20;
if ( (unsigned __int16)*v20 )
{
v23 = 0;
v24 = 0;
do
{
v25 = v14[v23];
v26 = v17[v23];
v27 = v24 + (unsigned __int16)v25 + (unsigned __int16)v26 * v22;
v28 = HIWORD(v26) * v22 + HIWORD(v25) + HIWORD(v27);
HIWORD(v14[v23]) = v28;
LOWORD(v14[v23++]) = v27;
v24 = HIWORD(v28);
}
while ( (unsigned int)&v17[v23] < v18 );
*v19 = v24;
v21 = *v20;
}
if ( HIWORD(v21) )
{
v29 = *v14;
v30 = HIWORD(v21);
v31 = 0;
v32 = v17;
v33 = v14;
v34 = *v14;
do
{
v35 = *v32++;
v36 = HIWORD(v35);
v37 = v31 + HIWORD(v29) + (unsigned __int16)v35 * v30;
*((_WORD *)v33 + 1) = v37;
*(_WORD *)v33 = v34;
v38 = v33[1];
++v33;
v29 = v38;
v34 = HIWORD(v37) + (unsigned __int16)v38 + v36 * v30;
v31 = HIWORD(v34);
}
while ( (unsigned int)v32 < v18 );
*v19 = v34;
}
++v19;
++v14;
++v20;
}
while ( (unsigned int)v20 < v44 );
}
v39 = v42;
if ( v42 >= 1 )
{
v40 = v42 + 4;
while ( !v43[v40] )
{
v41 = v40 - 1;
v8 = v40 - 4 <= 1;
--v40;
if ( v8 )
{
v39 = v41 - 4;
goto LABEL_34;
}
}
v39 = v40 - 4;
}
LABEL_34:
v43[4] = v39;
return v43;
}
}
return result;
}