//
// WebPGetFeaturesInternal from 0x9101ac to 0x9104a4 (760 bytes)
//
// 1 xrefs:
// > WebPIDecode @ 0x9087be
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:04:26 +0000
//
int __fastcall WebPGetFeaturesInternal(unsigned __int8 *a1, unsigned int a2, int *a3, int a4)
{
int v4; // r4
int result; // r0
unsigned __int8 *v9; // r3
int v10; // r11
unsigned int v11; // r9
int v12; // r5
int v13; // r8
__int64 v14; // r0
bool v15; // cf
unsigned int v16; // r2
int v17; // r7
int v18; // r1
int v19; // r0
int v20; // r10
int v21; // r3
unsigned int v22; // r3
int v23; // r2
int v24; // r3
int v25; // r1
unsigned __int8 *v26; // r4
int v27; // r0
unsigned __int8 *v28; // r9
int v29; // r11
int v30; // r0
_BOOL4 v31; // r1
unsigned int v32; // r0
unsigned int v33; // r2
_BOOL4 v34; // r3
int v35; // r1
_BOOL4 v36; // r0
unsigned __int8 *v37; // [sp+8h] [bp-44h]
unsigned int v38; // [sp+8h] [bp-44h]
unsigned int v39; // [sp+8h] [bp-44h]
unsigned int v40; // [sp+Ch] [bp-40h]
void *v41; // [sp+14h] [bp-38h] BYREF
unsigned int v42; // [sp+18h] [bp-34h] BYREF
int v43; // [sp+1Ch] [bp-30h] BYREF
int v44[5]; // [sp+20h] [bp-2Ch] BYREF
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]
v4 = a3 == nullptr;
if ( a4 >> 8 != 2 )
v4 = 1;
if ( v4 || !a1 )
return 2;
memset(a3, 0, 0x28u);
v41 = a1;
v42 = a2;
v43 = 0;
v44[0] = 0;
if ( a2 <= 0xB )
return 7;
v44[3] = 0;
v44[4] = 0;
v45 = nullptr;
v46 = 0;
v47 = 0;
v48 = 0;
v49 = 0;
v44[1] = (int)a1;
v44[2] = a2;
if ( !memcmp(a1, "RIFF", 4u) )
{
if ( memcmp(a1 + 8, "WEBP", 4u) )
return 3;
v11 = a1[4] | (a1[5] << 8) | ((a1[6] | (a1[7] << 8)) << 16);
if ( v11 - 12 > 0xFFFFFFEA )
return 3;
a2 -= 12;
v9 = a1 + 12;
v42 = a2;
v41 = a1 + 12;
v48 = v11;
if ( a2 <= 7 )
return 7;
v10 = 1;
}
else
{
v9 = a1;
v10 = 0;
v11 = 0;
}
v37 = v9;
if ( !memcmp(v9, "VP8X", 4u) )
{
if ( (v37[4] | (v37[5] << 8) | ((v37[6] | (v37[7] << 8)) << 16)) != 0xA )
return 3;
if ( a2 <= 0x11 )
return 7;
v12 = ((v37[14] << 16) | (v37[13] << 8) | v37[12]) + 1;
v13 = ((v37[17] << 16) | (v37[16] << 8) | v37[15]) + 1;
v14 = v13 * (__int64)v12;
v15 = HIDWORD(v14) != 0;
if ( HIDWORD(v14) == 1 )
v15 = 1;
v16 = v37[8] | (v37[9] << 8) | ((v37[10] | (v37[11] << 8)) << 16);
if ( v15 )
return 3;
v41 = v37 + 18;
v42 = a2 - 18;
if ( !v10 )
return 3;
v17 = (v16 >> 1) & 1;
v4 = v16 & 1;
v18 = 0;
v19 = 1;
v20 = v10;
v21 = v17;
}
else
{
v17 = 0;
v20 = 0;
v16 = 0;
v18 = (unsigned __int8)v10 ^ 1;
v13 = 0;
v19 = 0;
v12 = 0;
v21 = 0;
}
a3[3] = v21;
a3[2] = (v16 >> 4) & 1;
v43 = v12;
v44[0] = v13;
a3[4] = 0;
if ( !v20 )
{
v22 = v42;
if ( v42 <= 3 )
return 7;
goto LABEL_35;
}
if ( v17 || v4 )
{
v23 = v12;
v24 = v13;
goto LABEL_28;
}
v22 = v42;
if ( v42 <= 3 )
goto LABEL_25;
if ( !v10 )
{
LABEL_35:
if ( v19 )
goto LABEL_44;
if ( !v18 )
goto LABEL_44;
v38 = v22;
v27 = memcmp(v41, "ALPH", 4u);
v22 = v38;
if ( v27 )
goto LABEL_44;
}
result = sub_90F328((unsigned __int8 **)&v41, &v42, v11, &v45, &v46);
if ( result )
{
if ( result != 7 )
return result;
goto LABEL_25;
}
v22 = v42;
LABEL_44:
v28 = (unsigned __int8 *)v41;
v40 = v22;
v39 = v48;
v29 = memcmp(v41, "VP8 ", 4u);
v30 = memcmp(v28, "VP8L", 4u);
if ( v40 <= 7 )
goto LABEL_25;
v31 = v30 == 0;
if ( v29 && v30 )
{
v36 = VP8LCheckSignature(v28, v40);
v47 = v42;
v49 = v36;
}
else
{
v32 = v28[4] | (v28[5] << 8) | ((v28[6] | (v28[7] << 8)) << 16);
if ( v39 > 0xB && v32 > v39 - 12 )
return 3;
v41 = v28 + 8;
v42 = v40 - 8;
v47 = v32;
v49 = v31;
}
v33 = v47;
if ( v47 > 0xFFFFFFF6 )
return 3;
v34 = v49;
if ( !v17 && !v4 )
{
if ( v49 )
v35 = 2;
else
v35 = 1;
a3[4] = v35;
}
if ( v34 )
{
if ( v42 > 4 )
{
if ( !VP8LGetInfo(v41, v42, &v43, v44, a3 + 2) )
return 3;
goto LABEL_60;
}
LABEL_25:
if ( !v20 )
return 7;
v23 = v43;
goto LABEL_27;
}
if ( v42 <= 9 )
goto LABEL_25;
if ( !VP8GetInfo((unsigned __int8 *)v41, v42, v33, &v43, v44) )
return 3;
LABEL_60:
v23 = v43;
if ( !v20 )
{
LABEL_27:
v24 = v44[0];
goto LABEL_28;
}
if ( v43 != v12 )
return 3;
v24 = v44[0];
if ( v44[0] != v13 )
return 3;
LABEL_28:
v25 = a3[2];
result = 0;
v26 = v45;
*a3 = v23;
a3[1] = v24;
if ( v26 )
v25 |= 1u;
a3[2] = v25;
return result;
}