//
// sub_8F9DA8 from 0x8f9da8 to 0x8fa0fc (852 bytes)
//
// 3 xrefs:
// > sub_8F7C58 @ 0x8f7db0
// > sub_8F7C58 @ 0x8f7db4
// > ??> @ 0x8f7e68
//
// 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:04:15 +0000
//
int __fastcall sub_8F9DA8(int a1, int a2, unsigned int a3)
{
int result; // r0
int v6; // [sp+10h] [bp-24h]
unsigned int v7; // [sp+14h] [bp-20h]
int v8; // [sp+18h] [bp-1Ch]
int i; // [sp+1Ch] [bp-18h]
int v10; // [sp+1Ch] [bp-18h]
_BYTE *v12; // [sp+20h] [bp-14h]
int v13; // [sp+24h] [bp-10h]
unsigned int j; // [sp+28h] [bp-Ch]
int k; // [sp+2Ch] [bp-8h]
v6 = *(_DWORD *)(*(_DWORD *)(a1 + 576) + 4);
v7 = *(_WORD *)(a1 + 84) >> 3;
v8 = a3 / v7;
v13 = TIFFmalloc(a3);
result = a3 / (v7 * v6);
if ( a3 % (v7 * v6) )
result = _assert2();
if ( v13 )
{
TIFFmemcpy(v13, a2, a3);
for ( i = 0; i < v8; ++i )
{
for ( j = 0; j < v7; ++j )
*(_BYTE *)(a2 + v8 * (v7 - j - 1) + i) = *(_BYTE *)(v13 + v7 * i + j);
}
result = TIFFfree(v13);
v12 = (_BYTE *)(a2 + a3 - v6 - 1);
v10 = a3;
while ( v10 > v6 )
{
switch ( v6 )
{
case 0:
goto LABEL_19;
case 1:
goto LABEL_18;
case 2:
goto LABEL_17;
case 3:
goto LABEL_16;
case 4:
goto LABEL_15;
default:
for ( k = v6 - 4; k > 0; --k )
{
v12[v6] -= *v12;
--v12;
}
LABEL_15:
v12[v6] -= *v12;
--v12;
LABEL_16:
v12[v6] -= *v12;
--v12;
LABEL_17:
v12[v6] -= *v12;
--v12;
LABEL_18:
v12[v6] -= *v12;
--v12;
LABEL_19:
v10 -= v6;
break;
}
}
}
return result;
}