//
// sub_C544E8 from 0xc544e8 to 0xc546a0 (440 bytes)
//
// 2 xrefs:
// > sub_C56154 @ 0xc561b4
// > sub_C56154 @ 0xc561bc
//
// 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_C544E8(__int64 a1, char *a2, __int64 a3)
{
__int64 v3; // x24
__int64 v6; // x21
char *v7; // x22
unsigned __int8 *v8; // x20
__int64 v9; // x19
int v10; // w5
__int64 v11; // x4
int v12; // w0
int v13; // w2
char *v14; // x1
int v15; // w3
int v16; // t1
bool v18; // w3
int v20; // w7
int v21; // w0
int v22; // w7
char *v23; // x2
bool v24; // w6
v3 = *(_QWORD *)(a1 + 848);
v6 = a3 / *(int *)(v3 + 8);
if ( *(_DWORD *)v3 == 2 )
v7 = a2;
else
v7 = *(char **)(v3 + 16);
TIFFmemset(v7, 0, 4 * v6);
v8 = *(unsigned __int8 **)(a1 + 904);
v9 = *(_QWORD *)(a1 + 912);
v10 = 24;
while ( 1 )
{
v11 = 0;
while ( v9 > 0 )
{
LABEL_6:
if ( v11 >= v6 )
break;
v12 = *v8;
if ( (v12 & 0x80) != 0 )
{
v20 = v8[1];
v9 -= 2;
v8 += 2;
v21 = v12 - 127;
v22 = v20 << v10;
v23 = &v7[4 * v11];
do
{
++v11;
v24 = v21-- != 0;
*(_DWORD *)v23 |= v22;
v23 += 4;
}
while ( v24 && v6 > v11 );
}
else
{
--v9;
++v8;
if ( v9 )
{
v13 = v12 - 1;
if ( v12 )
{
v14 = &v7[4 * v11];
while ( 1 )
{
v15 = *(_DWORD *)v14;
v14 += 4;
v16 = *v8++;
--v9;
++v11;
*((_DWORD *)v14 - 1) = v15 | (v16 << v10);
if ( !v9 )
break;
v18 = v13-- != 0;
if ( !v18 || v6 <= v11 )
{
if ( v9 > 0 )
goto LABEL_6;
goto LABEL_17;
}
}
}
}
}
}
LABEL_17:
if ( v6 != v11 )
break;
v10 -= 8;
if ( v10 == -8 )
{
(*(void (__fastcall **)(__int64, char *, __int64))(v3 + 32))(v3, a2, v6);
*(_QWORD *)(a1 + 904) = v8;
*(_QWORD *)(a1 + 912) = v9;
return 1;
}
}
TIFFErrorExt(
*(_QWORD *)(a1 + 952),
(__int64)&unk_F4FA30,
"Not enough data at row %lu (short %llu pixels)",
*(unsigned int *)(a1 + 636),
v6 - v11);
*(_QWORD *)(a1 + 904) = v8;
*(_QWORD *)(a1 + 912) = v9;
return 0;
}