//
// sub_6F6C2C from 0x6f6c2c to 0x6f6e34 (520 bytes)
//
// 1 xrefs:
// > sub_6F77F8 @ 0x6f7d62
//
// 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_6F6C2C(int a1, unsigned int a2, int a3)
{
int v5; // r8
int v6; // r7
int v7; // r6
_DWORD *v9; // r0
unsigned int v10; // r12
_BYTE *v11; // r1
unsigned int v12; // lr
unsigned int v13; // r9
int v14; // r2
int v15; // r9
int *v16; // r0
int v17; // r11
void (__fastcall *v18)(int, int, int, unsigned int, int, int); // r9
int v19; // r10
int v20; // r3
int v21; // r3
int v22; // r6
_DWORD *v23; // r7
int v24; // r0
_DWORD *v25; // r5
int v26; // [sp+8h] [bp-Ch]
int v27; // [sp+Ch] [bp-8h]
int v28; // [sp+Ch] [bp-8h]
v5 = *(unsigned __int16 *)(a1 + 48);
v6 = *(unsigned __int16 *)(a1 + 50);
if ( (a3 <= 0) | (a2 >> 31) )
return 0;
v7 = a3;
if ( v6 < (int)(a2 + a3) )
return 0;
if ( a2 )
{
if ( *(_DWORD *)(a1 + 2356) )
return *(_DWORD *)(a1 + 2360) + v5 * a2;
goto LABEL_20;
}
v9 = (_DWORD *)WebPSafeCalloc(1u, 0, 0x88u);
*(_DWORD *)(a1 + 2344) = v9;
if ( !v9 )
return 0;
v10 = *(_DWORD *)(a1 + 2352);
v11 = *(_BYTE **)(a1 + 2348);
*v9 = v5;
v9[1] = v6;
if ( v10 <= 1 )
goto LABEL_37;
v12 = *v11 & 3;
v9[2] = v12;
v9[3] = ((unsigned __int8)*v11 >> 2) & 3;
v13 = ((unsigned __int8)*v11 >> 4) & 3;
v9[4] = v13;
v14 = (unsigned __int8)*v11 >> 6 != 0;
if ( v12 > 1 )
v14 = 1;
if ( v13 > 1 )
v14 |= 1u;
if ( v14 || (v12 ? (v15 = sub_6FE768()) : (v15 = v10 - 1 >= v6 * v5), sub_70D39C(), !v15) )
{
LABEL_37:
v25 = *(_DWORD **)(a1 + 2344);
if ( v25 )
{
sub_6FE6D4(v25[5]);
v25[5] = 0;
WebPSafeFree(v25);
}
goto LABEL_39;
}
if ( *(_DWORD *)(*(_DWORD *)(a1 + 2344) + 16) == 1 )
v7 = v6;
else
*(_DWORD *)(a1 + 2364) = 0;
if ( *(_DWORD *)(a1 + 2356) )
return *(_DWORD *)(a1 + 2360) + v5 * a2;
LABEL_20:
v16 = *(int **)(a1 + 2344);
v17 = *v16;
v18 = (void (__fastcall *)(int, int, int, unsigned int, int, int))dword_AD5008[v16[3]];
v26 = v16[1];
if ( !v16[2] )
{
v27 = *(_DWORD *)(a1 + 2360);
v19 = v7 + a2;
memcpy((void *)(v17 * a2 + v27), (const void *)(*(_DWORD *)(a1 + 2348) + v17 * a2 + 1), v17 * v7);
v20 = v27;
LABEL_22:
if ( v18 )
v18(v17, v26, v17, a2, v7, v20);
v21 = *(_DWORD *)(a1 + 2364);
if ( *(unsigned __int16 *)(a1 + 50) == v19 )
{
v22 = 1;
*(_DWORD *)(a1 + 2356) = 1;
if ( v21 <= 0 )
{
LABEL_29:
v23 = *(_DWORD **)(a1 + 2344);
if ( !v23 )
{
*(_DWORD *)(a1 + 2344) = 0;
return *(_DWORD *)(a1 + 2360) + v5 * a2;
}
LABEL_30:
sub_6FE6D4(v23[5]);
v23[5] = 0;
WebPSafeFree(v23);
*(_DWORD *)(a1 + 2344) = 0;
if ( v22 )
return *(_DWORD *)(a1 + 2360) + v5 * a2;
return 0;
}
}
else if ( v21 <= 0 )
{
v22 = 1;
goto LABEL_28;
}
v22 = sub_735E28(*(_DWORD *)(a1 + 2360), v5, v6);
if ( v22 )
{
LABEL_28:
if ( !*(_DWORD *)(a1 + 2356) )
return *(_DWORD *)(a1 + 2360) + v5 * a2;
goto LABEL_29;
}
goto LABEL_33;
}
v19 = v7 + a2;
v28 = *(_DWORD *)(a1 + 2360);
v24 = sub_6FE948();
v20 = v28;
if ( v24 )
goto LABEL_22;
LABEL_33:
v23 = *(_DWORD **)(a1 + 2344);
v22 = 0;
if ( v23 )
goto LABEL_30;
LABEL_39:
*(_DWORD *)(a1 + 2344) = 0;
return 0;
}