//
// TIFFWriteEncodedStrip from 0x9033a4 to 0x90385c (1208 bytes)
//
// 1 xrefs:
// > ??> @ 0x6b9cc
//
// 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:18 +0000
//
int __fastcall TIFFWriteEncodedStrip(int a1, unsigned int a2, int a3, int a4)
{
unsigned int v5; // r3
__int64 v6; // r0
__int64 v7; // r2
int v13; // [sp+10h] [bp-1Ch]
unsigned __int16 v14; // [sp+16h] [bp-16h]
v13 = a1 + 40;
if ( (*(_DWORD *)(a1 + 12) & 0x40) == 0 && !TIFFWriteCheck(a1, 0, "TIFFWriteEncodedStrip") )
return -1;
if ( *(_DWORD *)(v13 + 128) <= a2 )
{
if ( *(_WORD *)(v13 + 86) == 2 )
{
TIFFErrorExt(
*(_DWORD *)(a1 + 628),
(int)"TIFFWriteEncodedStrip",
"Can not grow image by strips when using separate planes");
return -1;
}
if ( !sub_904764(a1, 1, "TIFFWriteEncodedStrip") )
return -1;
if ( *(_DWORD *)(v13 + 20) >= (unsigned int)-*(_DWORD *)(v13 + 60) )
v5 = 0;
else
v5 = (unsigned int)(*(_DWORD *)(v13 + 20) + *(_DWORD *)(v13 + 60) - 1) / *(_DWORD *)(v13 + 60);
*(_DWORD *)(v13 + 124) = v5;
}
if ( ((*(_DWORD *)(a1 + 12) & 0x10) == 0 || !*(_DWORD *)(a1 + 588)) && !TIFFWriteBufferSetup(a1, 0, -1) )
return -1;
*(_DWORD *)(a1 + 12) |= 0x100000u;
*(_DWORD *)(a1 + 452) = a2;
*(_DWORD *)(a1 + 444) = *(_DWORD *)(v13 + 60) * (a2 % *(_DWORD *)(v13 + 124));
if ( (*(_DWORD *)(a1 + 12) & 0x20) == 0 )
{
if ( !(*(int (__fastcall **)(int))(a1 + 516))(a1) )
return -1;
*(_DWORD *)(a1 + 12) |= 0x20u;
}
if ( *(_QWORD *)(*(_DWORD *)(v13 + 136) + 8 * a2) )
{
v6 = *(int *)(a1 + 592);
v7 = *(_QWORD *)(*(_DWORD *)(v13 + 136) + 8 * a2);
if ( (unsigned int)((int)v6 >> 31) <= HIDWORD(v7)
&& (HIDWORD(v6) != HIDWORD(v7) || (unsigned int)v6 <= (unsigned int)v7)
&& !TIFFWriteBufferSetup(
a1,
0,
(unsigned int)((*(_QWORD *)(*(_DWORD *)(v13 + 136) + 8 * a2) + 1024LL) >> 10) << 10) )
{
return -1;
}
*(_QWORD *)(a1 + 456) = 0;
}
*(_DWORD *)(a1 + 608) = 0;
*(_DWORD *)(a1 + 604) = *(_DWORD *)(a1 + 588);
*(_DWORD *)(a1 + 12) &= ~0x1000u;
v14 = a2 / *(_DWORD *)(v13 + 124);
if ( !(*(int (__fastcall **)(int, _DWORD))(a1 + 524))(a1, v14) )
return -1;
(*(void (__fastcall **)(int, int, int))(a1 + 652))(a1, a3, a4);
if ( !(*(int (__fastcall **)(int, int, int, _DWORD))(a1 + 544))(a1, a3, a4, v14) )
return 0;
if ( !(*(int (__fastcall **)(int))(a1 + 528))(a1) )
return -1;
if ( (*(_DWORD *)(a1 + 12) & *(unsigned __int16 *)(v13 + 54)) == 0 && (*(_DWORD *)(a1 + 12) & 0x100) == 0 )
TIFFReverseBits(*(unsigned __int8 **)(a1 + 588), *(_DWORD *)(a1 + 608));
if ( *(int *)(a1 + 608) > 0 && !sub_904958(a1, a2, *(_DWORD *)(a1 + 588), *(_DWORD *)(a1 + 608)) )
return -1;
*(_DWORD *)(a1 + 608) = 0;
*(_DWORD *)(a1 + 604) = *(_DWORD *)(a1 + 588);
return a4;
}