//
// sub_6FFCC0 from 0x6ffcc0 to 0x6fff6a (682 bytes)
//
// 1 xrefs:
// > sub_6F85BC @ 0x6f8626
//
// 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_6FFCC0(int a1)
{
unsigned __int8 *v1; // r4
unsigned int v2; // r5
int v3; // r6
bool v4; // cc
int v5; // r7
int v6; // r4
unsigned int v9; // r10
unsigned int v10; // r12
int v11; // r9
int v12; // r3
__int64 v13; // r0
bool v14; // cf
unsigned int v15; // r5
int v16; // r11
int v17; // r0
int v18; // r0
unsigned int v19; // r0
unsigned int v20; // lr
bool v21; // zf
unsigned int v22; // lr
unsigned int v23; // r5
char *v24; // r6
unsigned int v25; // r1
int v26; // r2
int v27; // r3
unsigned int v28; // r1
unsigned int v29; // r2
unsigned int v30; // r3
_BOOL4 v31; // r5
_BOOL4 v32; // r0
unsigned int v33; // r2
unsigned int v34; // r1
int v35; // [sp+8h] [bp-44h]
int v36; // [sp+Ch] [bp-40h]
void *v37; // [sp+14h] [bp-38h] BYREF
unsigned int v38; // [sp+18h] [bp-34h] BYREF
int v39; // [sp+1Ch] [bp-30h] BYREF
int v40; // [sp+20h] [bp-2Ch] BYREF
unsigned __int8 *v41; // [sp+24h] [bp-28h]
unsigned int v42; // [sp+28h] [bp-24h]
int v43; // [sp+2Ch] [bp-20h]
int v44; // [sp+30h] [bp-1Ch]
unsigned __int8 *v45; // [sp+34h] [bp-18h] BYREF
unsigned int v46; // [sp+38h] [bp-14h] BYREF
unsigned int v47; // [sp+3Ch] [bp-10h]
unsigned int v48; // [sp+40h] [bp-Ch]
_BOOL4 v49; // [sp+44h] [bp-8h]
v1 = *(unsigned __int8 **)a1;
v2 = *(_DWORD *)(a1 + 4);
v3 = *(_DWORD *)(a1 + 8);
v39 = 0;
v4 = v1 != nullptr;
if ( v1 )
v4 = v2 > 0xB;
v40 = 0;
v37 = v1;
v38 = v2;
if ( !v4 )
return 7;
v5 = 0;
v43 = 0;
v44 = 0;
v45 = nullptr;
v46 = 0;
v47 = 0;
v48 = 0;
v49 = 0;
v41 = v1;
v42 = v2;
if ( !memcmp(v1, "RIFF", 4u) )
{
if ( memcmp(v1 + 8, "WEBP", 4u) )
return 3;
v9 = v1[4] | (v1[5] << 8) | ((v1[6] | (v1[7] << 8)) << 16);
if ( v9 - 12 > 0xFFFFFFEA )
return 3;
if ( v3 && v9 > v2 - 8 )
return 7;
v2 -= 12;
v1 += 12;
v38 = v2;
v37 = v1;
v48 = v9;
if ( v2 <= 7 )
return 7;
v5 = 1;
}
else
{
v9 = 0;
}
if ( !memcmp(v1, "VP8X", 4u) )
{
if ( (v1[4] | (v1[5] << 8) | ((v1[6] | (v1[7] << 8)) << 16)) != 0xA )
return 3;
if ( v2 > 0x11 )
{
v10 = v1[8];
v11 = ((v1[17] << 16) | (v1[16] << 8) | v1[15]) + 1;
v12 = ((v1[14] << 16) | (v1[13] << 8) | v1[12]) + 1;
v36 = v12;
v13 = v11 * (__int64)v12;
v14 = HIDWORD(v13) != 0;
if ( HIDWORD(v13) == 1 )
v14 = 1;
if ( v14 )
return 3;
v15 = v2 - 18;
v37 = v1 + 18;
v38 = v15;
if ( !v5 )
return 3;
v16 = (v10 >> 1) & 1;
v39 = v12;
v40 = v11;
if ( v15 <= 3 )
goto LABEL_33;
goto LABEL_20;
}
return 7;
}
if ( v5 )
{
v39 = 0;
v11 = 0;
v16 = 0;
v40 = 0;
v36 = 0;
LABEL_53:
v5 = 0;
v35 = memcmp(v1, "VP8 ", 4u);
v19 = memcmp(v1, "VP8L", 4u);
goto LABEL_35;
}
v11 = 0;
if ( memcmp(v1, "ALPH", 4u) )
{
v16 = 0;
v36 = 0;
goto LABEL_53;
}
v16 = 0;
v36 = 0;
LABEL_20:
v17 = sub_6FF768((unsigned __int8 **)&v37, &v38, v9, &v45, &v46);
v6 = v17;
if ( v17 )
{
if ( v17 != 7 )
return v6;
LABEL_22:
if ( v16 )
return 4;
return v6;
}
v1 = (unsigned __int8 *)v37;
v2 = v38;
v18 = memcmp(v37, "VP8 ", 4u);
v9 = v48;
v35 = v18;
v19 = memcmp(v1, "VP8L", 4u);
if ( v2 <= 7 )
goto LABEL_33;
LABEL_35:
v20 = __clz(v19);
v21 = v19 == 0;
if ( v19 )
v21 = v35 == 0;
v22 = v20 >> 5;
if ( v21 )
{
v33 = v1[4] | (v1[5] << 8) | ((v1[6] | (v1[7] << 8)) << 16);
if ( v9 > 0xB && v33 > v9 - 12 )
return 3;
v23 = v2 - 8;
if ( v3 && v33 > v23 )
goto LABEL_33;
v34 = v23;
v32 = v22;
v38 = v23;
v37 = v1 + 8;
v47 = v33;
v49 = v22;
}
else
{
v32 = VP8LCheckSignature(v1, v2);
v33 = v38;
v47 = v38;
v34 = v38;
v49 = v32;
}
if ( v33 > 0xFFFFFFF6 )
return 3;
if ( !v32 )
{
if ( v34 > 9 )
{
if ( !VP8GetInfo((unsigned __int8 *)v37, v34, v33, &v39, &v40) )
return 3;
goto LABEL_48;
}
LABEL_33:
v6 = 7;
goto LABEL_22;
}
if ( v34 <= 4 )
goto LABEL_33;
if ( !VP8LGetInfo(v37, v34, &v39, &v40, nullptr) )
return 3;
LABEL_48:
if ( !v5 || v39 == v36 && v40 == v11 )
{
v24 = (char *)v37;
v6 = 0;
v25 = v42;
v26 = v43;
v27 = v44;
*(_DWORD *)a1 = v41;
*(_DWORD *)(a1 + 4) = v25;
*(_DWORD *)(a1 + 8) = v26;
*(_DWORD *)(a1 + 12) = v27;
v28 = v46;
v29 = v47;
v30 = v48;
v31 = v49;
*(_DWORD *)(a1 + 16) = v45;
*(_DWORD *)(a1 + 20) = v28;
*(_DWORD *)(a1 + 24) = v29;
*(_DWORD *)(a1 + 28) = v30;
*(_DWORD *)(a1 + 32) = v31;
*(_DWORD *)(a1 + 12) = &v24[-*(_DWORD *)a1];
goto LABEL_22;
}
return 3;
}