//
// sub_ECC314 from 0xecc314 to 0xecc630 (796 bytes)
//
// 1 xrefs:
// > TIFFInitSGILog @ 0xecd800
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:11:38 +0000
//
__int64 __fastcall sub_ECC314(__int64 a1)
{
__int64 v1; // x21
int v2; // w3
int *v4; // x20
__int64 result; // x0
int v6; // w0
__int64 v7; // x1
__int64 v8; // x3
__int64 v9; // x0
__int64 v10; // x1
void *v11; // x0
int v12; // w1
int v13; // w1
v1 = a1 + 56;
v2 = *(unsigned __int16 *)(a1 + 122);
*(_QWORD *)(a1 + 1000) = TIFFNoPostDecode;
v4 = *(int **)(a1 + 848);
if ( v2 == 32844 )
{
v6 = *v4;
if ( *v4 != -1 )
goto LABEL_12;
v13 = (8 * *(unsigned __int16 *)(a1 + 130))
| (*(unsigned __int16 *)(a1 + 116) << 6)
| *(unsigned __int16 *)(a1 + 118);
if ( v13 > 1034 )
{
if ( v13 != 1036 )
{
if ( v13 == 2059 )
v6 = 0;
else
v6 = -1;
*v4 = v6;
goto LABEL_12;
}
}
else if ( v13 < 1033 )
{
if ( v13 == 521 || v13 == 524 )
v6 = 3;
*v4 = v6;
LABEL_12:
if ( v6 == 1 )
{
v4[2] = 2;
}
else if ( v6 == 3 )
{
v4[2] = 1;
}
else
{
if ( v6 )
{
TIFFErrorExt(
*(_QWORD *)(a1 + 952),
(__int64)"LogL16InitState",
"No support for converting user data format to LogL");
return 0;
}
v4[2] = 4;
}
if ( (*(_DWORD *)(a1 + 16) & 0x400) != 0 )
{
v7 = *(unsigned int *)(v1 + 44);
v8 = *(unsigned int *)(v1 + 48);
v9 = v7 * v8;
if ( !*(_DWORD *)(v1 + 44) )
goto LABEL_28;
}
else
{
v7 = *(unsigned int *)(v1 + 32);
v8 = *(unsigned int *)(v1 + 76);
v9 = v7 * v8;
if ( !*(_DWORD *)(v1 + 32) )
goto LABEL_28;
}
if ( v8 != v9 / v7 )
{
v9 = 0;
*((_QWORD *)v4 + 3) = 0;
v10 = 0;
LABEL_29:
if ( v10 )
{
v11 = TIFFmalloc(2 * v9);
*((_QWORD *)v4 + 2) = v11;
if ( v11 )
{
v12 = *v4;
*(_QWORD *)(a1 + 760) = sub_ECA500;
if ( v12 )
{
if ( v12 != 3 )
return 1;
*((_QWORD *)v4 + 4) = sub_ECC690;
return 1;
}
else
{
*((_QWORD *)v4 + 4) = sub_ECC750;
return 1;
}
}
}
LABEL_22:
TIFFErrorExt(*(_QWORD *)(a1 + 952), (__int64)"LogL16InitState", "No space for SGILog translation buffer");
return 0;
}
LABEL_28:
*((_QWORD *)v4 + 3) = v9;
v10 = 2 * v9;
if ( v9 && v10 / v9 != 2 )
goto LABEL_22;
goto LABEL_29;
}
v6 = 1;
*v4 = 1;
goto LABEL_12;
}
if ( v2 == 32845 )
{
result = sub_ECBDC4(a1);
if ( (_DWORD)result )
{
result = (unsigned int)*v4;
if ( *(unsigned __int16 *)(v1 + 64) == 34677 )
{
*(_QWORD *)(a1 + 760) = sub_ECA428;
if ( (_DWORD)result == 1 )
{
*((_QWORD *)v4 + 4) = sub_ECD020;
}
else if ( (_DWORD)result == 3 )
{
*((_QWORD *)v4 + 4) = sub_ECD208;
return 1;
}
else
{
if ( (_DWORD)result )
return 1;
*((_QWORD *)v4 + 4) = sub_ECD274;
return 1;
}
}
else
{
*(_QWORD *)(a1 + 760) = sub_ECA6A8;
if ( (_DWORD)result == 1 )
{
*((_QWORD *)v4 + 4) = sub_EC9860;
}
else if ( (_DWORD)result == 3 )
{
*((_QWORD *)v4 + 4) = sub_ECD4E0;
return 1;
}
else
{
if ( (_DWORD)result )
return 1;
*((_QWORD *)v4 + 4) = sub_ECD54C;
return 1;
}
}
}
}
else
{
TIFFErrorExt(
*(_QWORD *)(a1 + 952),
(__int64)"LogLuvSetupDecode",
"Inappropriate photometric interpretation %d for SGILog compression; %s",
v2,
"must be either LogLUV or LogL");
return 0;
}
return result;
}