//
// TIFFReadBufferSetup from 0x8ff260 to 0x8ff450 (496 bytes)
//
// 6 xrefs:
// > sub_8FCF80 @ 0x8fd088
// > TIFFFillStrip @ 0x8fe518
// > TIFFFillStrip @ 0x8fe55c
// > TIFFFillTile @ 0x8ff12c
// > TIFFFillTile @ 0x8ff170
// > ??> @ 0x6b7bc
//
// 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:16 +0000
//
int __fastcall TIFFReadBufferSetup(_DWORD *a1, int a2, int a3)
{
if ( (a1[3] & 0x20000) != 0 )
_assert2();
a1[3] &= ~0x800000u;
if ( a1[147] )
{
if ( (a1[3] & 0x200) != 0 )
TIFFfree(a1[147]);
a1[147] = 0;
a1[148] = 0;
}
if ( a2 )
{
a1[148] = a3;
a1[147] = a2;
a1[3] &= ~0x200u;
}
else
{
a1[148] = (unsigned int)((a3 + 1023LL) >> 10) << 10;
if ( !a1[148] )
a1[148] = -1;
a1[147] = TIFFmalloc(a1[148]);
a1[3] |= 0x200u;
}
if ( a1[147] )
return 1;
TIFFErrorExt(a1[157], (int)"TIFFReadBufferSetup", "No space for data buffer at scanline %lu", a1[111]);
a1[148] = 0;
return 0;
}