//
// TIFFReadEncodedStrip from 0x6eddf8 to 0x6ee014 (540 bytes)
//
// 6 xrefs:
// > sub_6CBBE8 @ 0x6cbe98
// > sub_6CC084 @ 0x6cc438
// > sub_6CC084 @ 0x6cc4cc
// > sub_6CC084 @ 0x6cc560
// > sub_6CC084 @ 0x6cc5fc
// > ??> @ 0x5847c
//
// 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 TIFFReadEncodedStrip(int a1, unsigned int a2, int a3, int a4)
{
_DWORD *v10; // [sp+1Ch] [bp-20h]
unsigned int v11; // [sp+20h] [bp-1Ch]
unsigned int v12; // [sp+24h] [bp-18h]
unsigned int v13; // [sp+30h] [bp-Ch]
int v14; // [sp+34h] [bp-8h]
v10 = (_DWORD *)(a1 + 40);
if ( !sub_6EFC84(a1, 0) )
return -1;
if ( v10[32] > a2 )
{
v11 = v10[15];
if ( v10[5] < v11 )
v11 = v10[5];
v12 = (v10[5] + v11 - 1) / v11;
v13 = v10[5] - v11 * (a2 % v12);
if ( v13 > v11 )
v13 = v11;
v14 = TIFFVStripSize(a1, v13);
if ( v14 )
{
if ( a4 != -1 && a4 < v14 )
v14 = a4;
if ( TIFFFillStrip(a1, a2) )
{
if ( (*(int (__fastcall **)(int, int, int, _DWORD))(a1 + 540))(a1, a3, v14, (unsigned __int16)(a2 / v12)) > 0 )
{
(*(void (__fastcall **)(int, int, int))(a1 + 652))(a1, a3, v14);
return v14;
}
else
{
return -1;
}
}
else
{
return -1;
}
}
else
{
return -1;
}
}
else
{
TIFFErrorExt(*(_DWORD *)(a1 + 628), (int)"TIFFReadEncodedStrip", "%lu: Strip out of range, max %lu", a2, v10[32]);
return -1;
}
}