//
// TIFFWriteBufferSetup from 0x9045b8 to 0x90475c (420 bytes)
//
// 6 xrefs:
// > TIFFWriteScanline @ 0x902f54
// > TIFFWriteEncodedStrip @ 0x903518
// > TIFFWriteEncodedStrip @ 0x90368c
// > TIFFWriteEncodedTile @ 0x903bc8
// > TIFFWriteEncodedTile @ 0x903cc0
// > ??> @ 0x6b9bc
//
// 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 TIFFWriteBufferSetup(_DWORD *a1, int a2, int a3)
{
int v3; // r3
if ( a1[147] )
{
if ( (a1[3] & 0x200) != 0 )
{
TIFFfree(a1[147]);
a1[3] &= ~0x200u;
}
a1[147] = 0;
}
if ( a3 == -1 )
{
if ( (a1[3] & 0x400) != 0 )
v3 = a1[124];
else
v3 = TIFFStripSize((int)a1);
a3 = v3;
if ( v3 <= 0x1FFF )
a3 = 0x2000;
a2 = 0;
}
if ( a2 )
{
a1[3] &= ~0x200u;
goto LABEL_17;
}
a2 = TIFFmalloc(a3);
if ( a2 )
{
a1[3] |= 0x200u;
LABEL_17:
a1[147] = a2;
a1[148] = a3;
a1[152] = 0;
a1[151] = a1[147];
a1[3] |= 0x10u;
return 1;
}
TIFFErrorExt(a1[157], (int)"TIFFWriteBufferSetup", "No space for output buffer");
return 0;
}