//
// TIFFUnsetField from 0xc321e0 to 0xc3230c (300 bytes)
//
// 1 xrefs:
// > ??> @ 0x8d9f0
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __fastcall TIFFUnsetField(__int64 a1, __int64 a2)
{
int v2; // w20
__int64 v4; // x0
int v5; // w0
int v7; // w3
__int64 v8; // x1
__int64 v9; // x0
int v10; // w19
int v11; // w1
int v12; // w20
v2 = a2;
v4 = TIFFFieldWithTag(a1, a2);
if ( !v4 )
return 0;
v5 = *(unsigned __int16 *)(v4 + 24);
if ( v5 == 65 )
{
v7 = *(_DWORD *)(a1 + 320);
if ( v7 > 0 )
{
v8 = *(_QWORD *)(a1 + 328);
if ( **(_DWORD **)v8 == v2 )
{
v10 = 0;
LABEL_10:
TIFFfree(*(void **)(v8 + 16));
v11 = *(_DWORD *)(a1 + 320);
v12 = v11 - 1;
if ( v11 - 1 > v10 )
memmove(
(void *)(*(_QWORD *)(a1 + 328) + 24LL * v10),
(const void *)(*(_QWORD *)(a1 + 328) + 24LL * v10 + 24),
24 * ((unsigned int)(v11 - 2 - v10) + 1LL));
*(_DWORD *)(a1 + 320) = v12;
}
else
{
v9 = v8 + 24;
v10 = 0;
while ( 1 )
{
++v10;
v8 = v9;
v9 += 24;
if ( v10 == v7 )
break;
if ( **(_DWORD **)v8 == v2 )
goto LABEL_10;
}
}
}
}
else
{
*(_QWORD *)(a1 + 8LL * ((unsigned __int16)v5 >> 5) + 56) &= ~(1LL << (v5 & 0x1F));
}
*(_DWORD *)(a1 + 16) |= 8u;
return 1;
}