//
// sub_6BC370 from 0x6bc370 to 0x6bc624 (692 bytes)
//
// 1 xrefs:
// > sub_6B8210 @ 0x6b8ee0
//
// 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
//
int __fastcall sub_6BC370(int a1, _DWORD *a2, int a3)
{
__int64 v8; // [sp+18h] [bp-24h]
int v9; // [sp+24h] [bp-18h]
int v10; // [sp+28h] [bp-14h]
_DWORD *v11; // [sp+2Ch] [bp-10h]
_DWORD *v12; // [sp+30h] [bp-Ch]
unsigned __int16 i; // [sp+36h] [bp-6h]
if ( !*(_WORD *)(a1 + 184) )
return 1;
if ( a3 )
{
v8 = *(_QWORD *)(a1 + 464);
if ( (*(_DWORD *)(a1 + 12) & 0x80000) != 0 )
{
v9 = sub_6BD7B0(a1, a2, a3, 330, *(unsigned __int16 *)(a1 + 184), *(_DWORD *)(a1 + 188));
}
else
{
v10 = TIFFmalloc(4 * *(unsigned __int16 *)(a1 + 184));
if ( !v10 )
{
TIFFErrorExt(*(_DWORD *)(a1 + 628), "TIFFWriteDirectoryTagSubifd", "Out of memory");
return 0;
}
v11 = *(_DWORD **)(a1 + 188);
v12 = (_DWORD *)v10;
for ( i = 0; i < (unsigned int)*(unsigned __int16 *)(a1 + 184); ++i )
{
if ( !v11 )
_assert2();
if ( v11[1] )
_assert2();
*v12++ = *v11;
v11 += 2;
}
v9 = sub_6BD6E8(a1, a2, a3, 330, *(unsigned __int16 *)(a1 + 184), v10);
TIFFfree(v10);
}
if ( v9 )
{
*(_DWORD *)(a1 + 12) |= 0x2000u;
*(_WORD *)(a1 + 472) = *(_WORD *)(a1 + 184);
if ( *(_WORD *)(a1 + 184) == 1 )
*(_QWORD *)(a1 + 480) = 0;
else
*(_QWORD *)(a1 + 480) = v8;
return 1;
}
else
{
return 0;
}
}
else
{
++*a2;
return 1;
}
}