//
// sub_8BEF30 from 0x8bef30 to 0x8bf148 (536 bytes)
//
// 2 xrefs:
// > sub_8C411C @ 0x8c5d50
// > sub_8C411C @ 0x8c68b8
//
// 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:03:58 +0000
//
int __fastcall sub_8BEF30(_DWORD *a1, int a2, int *a3)
{
unsigned int v3; // r3
int v5; // r3
int v6; // r3
unsigned int *v11; // [sp+1Ch] [bp-20h] BYREF
unsigned int v12; // [sp+20h] [bp-1Ch] BYREF
int v13; // [sp+24h] [bp-18h]
int v14; // [sp+28h] [bp-14h]
unsigned int *v15; // [sp+2Ch] [bp-10h]
_QWORD *v16; // [sp+30h] [bp-Ch]
unsigned int i; // [sp+34h] [bp-8h]
v3 = *(unsigned __int16 *)(a2 + 2);
if ( v3 > 0x12 || ((1 << v3) & 0x52010) == 0 )
return 2;
v13 = sub_8BAA64(a1, a2, (int *)&v12, 8u, (int *)&v11);
if ( !v13 && v11 )
{
v5 = *(unsigned __int16 *)(a2 + 2);
if ( v5 == 16 || v5 == 18 )
{
*a3 = (int)v11;
if ( (a1[3] & 0x80) != 0 )
TIFFSwabArrayOfLong8(*a3, v12);
return 0;
}
else
{
v14 = TIFFmalloc(8 * v12);
if ( v14 )
{
v6 = *(unsigned __int16 *)(a2 + 2);
if ( v6 == 4 || v6 == 13 )
{
v15 = v11;
v16 = (_QWORD *)v14;
for ( i = 0; i < v12; ++i )
{
if ( (a1[3] & 0x80) != 0 )
TIFFSwabLong(v15);
*v16++ = *v15++;
}
}
TIFFfree(v11);
if ( v13 )
{
TIFFfree(v14);
return v13;
}
else
{
*a3 = v14;
return 0;
}
}
else
{
TIFFfree(v11);
return 7;
}
}
}
else
{
*a3 = 0;
return v13;
}
}