//
// sub_C584A0 from 0xc584a0 to 0xc585c4 (292 bytes)
//
// 2 xrefs:
// > TIFFInitLZW @ 0xc58b9c
// > TIFFInitLZW @ 0xc58ba4
//
// 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_C584A0(__int64 a1)
{
__int64 v1; // x19
unsigned int v3; // w20
_BYTE *v5; // x0
__int64 v6; // x1
int v7; // w3
char v8; // w2
_BYTE *v9; // x2
_QWORD *v10; // x0
v1 = *(_QWORD *)(a1 + 848);
if ( !v1 )
{
v10 = TIFFmalloc(0x120u);
*(_QWORD *)(a1 + 848) = v10;
if ( !v10 )
{
v3 = 0;
TIFFErrorExt(*(_QWORD *)(a1 + 952), (__int64)"LZWSetupDecode", "No space for LZW state block");
return v3;
}
v10[28] = 0;
v10[23] = 0;
TIFFPredictorInit(a1);
v1 = *(_QWORD *)(a1 + 848);
}
v3 = 1;
if ( !*(_QWORD *)(v1 + 224) )
{
v5 = TIFFmalloc(0x13FF0u);
*(_QWORD *)(v1 + 224) = v5;
if ( v5 )
{
v6 = 4080;
v7 = 255;
do
{
v8 = v7--;
v5[v6 + 10] = v8;
*(_BYTE *)(*(_QWORD *)(v1 + 224) + v6 + 11) = v8;
v9 = *(_BYTE **)(v1 + 224);
v5 = v9;
*(_WORD *)&v9[v6 + 8] = 1;
*(_QWORD *)&v9[v6] = 0;
v6 -= 16;
}
while ( v7 != -1 );
v3 = 1;
TIFFmemset(v9 + 4096, 0, 0x20u);
}
else
{
v3 = 0;
TIFFErrorExt(*(_QWORD *)(a1 + 952), (__int64)"LZWSetupDecode", "No space for LZW code table");
}
}
return v3;
}