//
// _TIFFMergeFields from 0x6a84a8 to 0x6a8690 (488 bytes)
//
// 13 xrefs:
// > _TIFFSetupFields @ 0x6a831c
// > _TIFFFindOrRegisterField @ 0x6a8e78
// > TIFFMergeFieldInfo @ 0x6a99e8
// > TIFFReadDirectory @ 0x6b12a4
// > TIFFReadCustomDirectory @ 0x6b2c50
// > sub_6C6AF4 @ 0x6c6b20
// > TIFFInitCCITTFax3 @ 0x6c6e2c
// > TIFFInitCCITTFax4 @ 0x6c8840
// > TIFFInitSGILog @ 0x6dc708
// > TIFFInitPixarLog @ 0x6e7904
// > TIFFPredictorInit @ 0x6eace8
// > TIFFInitZIP @ 0x6f6160
// > ??> @ 0x5804c
//
// 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
//
unsigned int __fastcall TIFFMergeFields(_DWORD *a1, int a2, unsigned int a3)
{
unsigned int i; // [sp+18h] [bp-Ch]
a1[166] = 0;
if ( a1[164] && a1[165] )
a1[164] = TIFFCheckRealloc(a1, a1[164], a1[165] + a3, 4, "for fields array");
else
a1[164] = TIFFCheckMalloc(a1, a3, 4, "for fields array");
if ( a1[164] )
{
for ( i = 0; i < a3; ++i )
{
if ( !TIFFFindField(a1, *(_DWORD *)(a2 + 36 * i), 0) )
*(_DWORD *)(a1[164] + 4 * a1[165]++) = a2 + 36 * i;
}
qsort((void *)a1[164], a1[165], 4u, (int (*)(const void *, const void *))sub_6A8368);
return a3;
}
else
{
TIFFErrorExt(a1[157], "_TIFFMergeFields", "Failed to allocate fields array");
return 0;
}
}