//
// sub_C546A0 from 0xc546a0 to 0xc54844 (420 bytes)
//
// 2 xrefs:
// > TIFFInitSGILog @ 0xc576b4
// > TIFFInitSGILog @ 0xc576bc
//
// 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 sub_C546A0(__int64 a1, int a2, __int64 a3)
{
int *v3; // x4
__int64 v5; // x8
__int64 v6; // x6
int v7; // w2
unsigned int v8; // w1
unsigned int *v10; // x0
unsigned int v11; // w3
int *v12; // x0
int v13; // w3
unsigned int v14; // w20
__int64 v15; // x2
__int64 v16; // x0
v3 = *(int **)a3;
v5 = *(_QWORD *)(a3 + 8);
v6 = *(_QWORD *)(a1 + 848);
v7 = *(_DWORD *)(a3 + 24);
if ( a2 == 65560 )
{
v12 = (int *)(v5 + v7);
if ( v7 > -8 )
v12 = v3;
v13 = *v12;
*(_DWORD *)v6 = *v12;
switch ( v13 )
{
case 0:
v14 = 3;
v15 = 32;
break;
case 1:
v14 = 2;
v15 = 16;
break;
case 2:
v14 = 1;
TIFFSetField((const char **)a1, 277);
v15 = 32;
break;
case 3:
v14 = 1;
v15 = 8;
break;
default:
TIFFErrorExt(*(_QWORD *)(a1 + 952), *(_QWORD *)a1, "Unknown data format %d for LogLuv compression", v13);
return 0;
}
TIFFSetField((const char **)a1, 258, v15);
TIFFSetField((const char **)a1, 339, v14);
v16 = -1;
if ( (*(_DWORD *)(a1 + 16) & 0x400) != 0 )
v16 = TIFFTileSize(a1);
*(_QWORD *)(a1 + 688) = v16;
*(_QWORD *)(a1 + 856) = TIFFScanlineSize(a1);
return 1;
}
else
{
if ( a2 != 65561 )
return (*(unsigned int (**)(void))(v6 + 48))();
v10 = (unsigned int *)(v5 + v7);
if ( v7 > -8 )
v10 = (unsigned int *)v3;
v8 = 1;
v11 = *v10;
*(_DWORD *)(v6 + 4) = *v10;
if ( v11 <= 1 )
return v8;
TIFFErrorExt(*(_QWORD *)(a1 + 952), (__int64)&unk_F4FA40, "Unknown encoding %d for LogLuv compression", v11);
return 0;
}
}