//
// TIFFFreeDirectory from 0x8b662c to 0x8b69b0 (900 bytes)
//
// 6 xrefs:
// > TIFFCleanup @ 0x8b0e34
// > TIFFUnlinkDirectory @ 0x8b7c58
// > TIFFReadDirectory @ 0x8c0c34
// > TIFFReadCustomDirectory @ 0x8c2728
// > sub_8C7DD0 @ 0x8ca668
// > ??> @ 0x6ab8c
//
// 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:55 +0000
//
int __fastcall TIFFFreeDirectory(int a1)
{
int result; // r0
_DWORD *v3; // [sp+8h] [bp-Ch]
int i; // [sp+Ch] [bp-8h]
v3 = (_DWORD *)(a1 + 40);
result = TIFFmemset(a1 + 40, 0, 4);
if ( v3[17] )
{
result = TIFFfree(v3[17]);
v3[17] = 0;
}
if ( v3[18] )
{
result = TIFFfree(v3[18]);
v3[18] = 0;
}
if ( v3[25] )
{
result = TIFFfree(v3[25]);
v3[25] = 0;
}
if ( v3[26] )
{
result = TIFFfree(v3[26]);
v3[26] = 0;
}
if ( v3[27] )
{
result = TIFFfree(v3[27]);
v3[27] = 0;
}
if ( v3[30] )
{
result = TIFFfree(v3[30]);
v3[30] = 0;
}
if ( v3[37] )
{
result = TIFFfree(v3[37]);
v3[37] = 0;
}
if ( v3[45] )
{
result = TIFFfree(v3[45]);
v3[45] = 0;
}
if ( v3[43] )
{
result = TIFFfree(v3[43]);
v3[43] = 0;
}
if ( v3[40] )
{
result = TIFFfree(v3[40]);
v3[40] = 0;
}
if ( v3[41] )
{
result = TIFFfree(v3[41]);
v3[41] = 0;
}
if ( v3[42] )
{
result = TIFFfree(v3[42]);
v3[42] = 0;
}
if ( v3[33] )
{
result = TIFFfree(v3[33]);
v3[33] = 0;
}
if ( v3[34] )
{
result = TIFFfree(v3[34]);
v3[34] = 0;
}
*(_DWORD *)(a1 + 44) &= ~0x80u;
*(_DWORD *)(a1 + 44) &= ~0x100u;
for ( i = 0; v3[46] > i; ++i )
{
if ( *(_DWORD *)(v3[47] + 12 * i + 8) )
result = TIFFfree(*(_DWORD *)(v3[47] + 12 * i + 8));
}
v3[46] = 0;
if ( v3[47] )
{
result = TIFFfree(v3[47]);
v3[47] = 0;
}
return result;
}