//
// TIFFCleanup from 0x8b0df8 to 0x8b1084 (652 bytes)
//
// 3 xrefs:
// > TIFFClose @ 0x8b10b4
// > TIFFClientOpen @ 0x8f02cc
// > ??> @ 0x6ab6c
//
// 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:03:54 +0000
//
int __fastcall TIFFCleanup(int a1)
{
_DWORD *v3; // [sp+8h] [bp-14h]
unsigned int i; // [sp+Ch] [bp-10h]
int v5; // [sp+10h] [bp-Ch]
unsigned int j; // [sp+14h] [bp-8h]
if ( *(_DWORD *)(a1 + 8) )
TIFFFlush(a1);
(*(void (__fastcall **)(int))(a1 + 564))(a1);
TIFFFreeDirectory(a1);
if ( *(_DWORD *)(a1 + 32) )
TIFFfree(*(_DWORD *)(a1 + 32));
while ( *(_DWORD *)(a1 + 680) )
{
v3 = *(_DWORD **)(a1 + 680);
*(_DWORD *)(a1 + 680) = *v3;
TIFFfree(v3[2]);
TIFFfree(v3);
}
if ( *(_DWORD *)(a1 + 588) && (*(_DWORD *)(a1 + 12) & 0x200) != 0 )
TIFFfree(*(_DWORD *)(a1 + 588));
if ( (*(_DWORD *)(a1 + 12) & 0x800) != 0 )
(*(void (__fastcall **)(_DWORD, _DWORD, _DWORD, int))(a1 + 624))(
*(_DWORD *)(a1 + 628),
*(_DWORD *)(a1 + 612),
*(_DWORD *)(a1 + 616),
*(int *)(a1 + 616) >> 31);
if ( *(_DWORD *)(a1 + 656) && *(_DWORD *)(a1 + 660) )
{
for ( i = 0; *(_DWORD *)(a1 + 660) > i; ++i )
{
v5 = *(_DWORD *)(*(_DWORD *)(a1 + 656) + 4 * i);
if ( *(_WORD *)(v5 + 24) == 65 && !strncmp("Tag ", *(const char **)(v5 + 28), 4u) )
{
TIFFfree(*(_DWORD *)(v5 + 28));
TIFFfree(v5);
}
}
TIFFfree(*(_DWORD *)(a1 + 656));
}
if ( *(_DWORD *)(a1 + 688) )
{
for ( j = 0; *(_DWORD *)(a1 + 688) > j; ++j )
{
if ( *(_DWORD *)(*(_DWORD *)(a1 + 684) + 16 * j + 4) )
TIFFfree(*(_DWORD *)(*(_DWORD *)(a1 + 684) + 16 * j + 12));
}
TIFFfree(*(_DWORD *)(a1 + 684));
}
return TIFFfree(a1);
}