//
// sub_73158C from 0x73158c to 0x7316dc (336 bytes)
//
// 4 xrefs:
// > sub_7316DC @ 0x73199a
// > sub_7319C0 @ 0x731c4c
// > sub_7319C0 @ 0x7321aa
// > sub_7319C0 @ 0x73261c
//
// 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
//
bool __fastcall sub_73158C(int a1, unsigned int *a2, void **a3, int a4, int a5, int a6, int a7)
{
void *v11; // r7
int v12; // r9
int *v13; // r0
int *v14; // r6
_BOOL4 v15; // r4
unsigned __int8 *v16; // r11
int v17; // r3
int v18; // r0
int v19; // r3
int *v20; // r4
_BYTE *v21; // r0
int v22; // lr
_BYTE *v23; // r3
int v25; // r3
unsigned __int16 v27; // [sp+1Ch] [bp-48h] BYREF
int v28; // [sp+20h] [bp-44h] BYREF
int v29[15]; // [sp+24h] [bp-40h] BYREF
char v30; // [sp+60h] [bp-4h] BYREF
memset(v29, 0, sizeof(v29));
v27 = 0;
v28 = 0;
v11 = (void *)WebPSafeMalloc(57, 0, 16);
if ( v11
&& (v12 = sub_71ED0C(a5, a6, a2, a7, 0, &v28, a3, a4)) != 0
&& (v13 = sub_7246D0(1, v28), (v14 = v13) != nullptr) )
{
v15 = 1;
sub_724400(v12, *(_DWORD **)v13[2]);
v16 = (unsigned __int8 *)sub_730DE4(*v14, v14 + 2, v29);
if ( v16 )
{
sub_73449C(a1, 0, 1);
v17 = v29[3];
v18 = v29[9];
if ( v29[3] < v29[0] )
v17 = v29[0];
v19 = v17 & ~(v17 >> 31);
if ( v19 < v29[6] )
v19 = v29[6];
if ( v29[9] < v19 )
v18 = v19;
if ( v18 < v29[12] )
v18 = v29[12];
v16 = (unsigned __int8 *)WebPSafeMalloc(v18, v18 >> 31, 2);
if ( v16 )
{
v20 = v29;
do
{
sub_7311D8(a1, (int)v11, v16, v20);
if ( *v20 > 0 )
{
v21 = (_BYTE *)v20[1];
v22 = 0;
v23 = v21;
do
{
if ( *v23++ )
{
if ( v22 )
goto LABEL_24;
v22 = 1;
}
}
while ( v23 != &v21[*v20] );
v25 = 0;
while ( 1 )
{
v21[v25] = 0;
*(_WORD *)(v20[2] + 2 * v25++) = 0;
if ( v25 >= *v20 )
break;
v21 = (_BYTE *)v20[1];
}
}
LABEL_24:
v20 += 3;
}
while ( v20 != (int *)&v30 );
v15 = sub_730F98(a1, a5, 0, v12, &v27, (int)v29);
}
else
{
v15 = 1;
}
}
}
else
{
v14 = nullptr;
v15 = 1;
v16 = nullptr;
}
WebPSafeFree(v16);
WebPSafeFree(v11);
j_WebPSafeFree_0(v14);
WebPSafeFree((void *)v29[2]);
return v15;
}