//
// sub_6E911C from 0x6e911c to 0x6e9454 (824 bytes)
//
// 3 xrefs:
// > sub_6E7DA0 @ 0x6e7f88
// > sub_6E7DA0 @ 0x6e7f8c
// > ??> @ 0x6e8084
//
// 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_6E911C(int a1, _BYTE *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 v9; // [sp+1Ch] [bp-18h]
int j; // [sp+1Ch] [bp-18h]
_BYTE *v11; // [sp+20h] [bp-14h]
int v12; // [sp+24h] [bp-10h]
int i; // [sp+28h] [bp-Ch]
unsigned int k; // [sp+2Ch] [bp-8h]
v6 = *(_DWORD *)(*(_DWORD *)(a1 + 576) + 4);
v7 = *(_WORD *)(a1 + 84) >> 3;
v8 = a3 / v7;
v9 = a3;
v11 = a2;
v12 = TIFFmalloc(a3);
result = v9 / (v7 * v6);
if ( v9 % (v7 * v6) )
result = _assert2();
if ( v12 )
{
while ( v9 > v6 )
{
switch ( v6 )
{
case 0:
goto LABEL_13;
case 1:
goto LABEL_12;
case 2:
goto LABEL_11;
case 3:
goto LABEL_10;
case 4:
goto LABEL_9;
default:
for ( i = v6 - 4; i > 0; --i )
{
v11[v6] += *v11;
++v11;
}
LABEL_9:
v11[v6] += *v11;
++v11;
LABEL_10:
v11[v6] += *v11;
++v11;
LABEL_11:
v11[v6] += *v11;
++v11;
LABEL_12:
v11[v6] += *v11;
++v11;
LABEL_13:
v9 -= v6;
break;
}
}
TIFFmemcpy(v12, a2, a3);
for ( j = 0; j < v8; ++j )
{
for ( k = 0; k < v7; ++k )
a2[v7 * j + k] = *(_BYTE *)(v12 + v8 * (v7 - k - 1) + j);
}
return TIFFfree(v12);
}
return result;
}