//
// WebPPictureAlloc from 0x727884 to 0x7279c0 (316 bytes)
//
// 9 xrefs:
// > sub_71CB54 @ 0x71cb7c
// > sub_72939C @ 0x7293d4
// > WebPPictureImportRGBA @ 0x72b010
// > WebPPictureImportBGRA @ 0x72b0b0
// > WebPPictureImportRGBX @ 0x72b14e
// > WebPPictureImportBGRX @ 0x72b1ea
// > WebPPictureCopy @ 0x72b5be
// > WebPPictureCrop @ 0x72b7b2
// > WebPPictureRescale @ 0x72b8ec
//
// 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 WebPPictureAlloc(int a1)
{
int v2; // r5
int v3; // r8
bool v4; // cc
int v5; // r0
int v7; // r7
int v8; // r0
int v9; // r1
int v10; // r11
__int64 v11; // r6
bool v12; // cc
int v13; // r8
int v14; // r10
__int64 v15; // r0
int v16; // off
int v17; // r0
int v18; // r3
__int64 v19; // [sp+0h] [bp-40h]
int v20; // [sp+10h] [bp-30h]
if ( !a1 )
return 1;
v2 = *(_DWORD *)(a1 + 8);
v3 = *(_DWORD *)(a1 + 12);
WebPPictureFree(a1);
if ( *(_DWORD *)a1 )
{
WebPSafeFree(*(void **)(a1 + 160));
v4 = v2 <= 0;
if ( v2 > 0 )
v4 = v3 <= 0;
*(_DWORD *)(a1 + 160) = 0;
*(_DWORD *)(a1 + 52) = 0;
*(_DWORD *)(a1 + 56) = 0;
if ( !v4 )
{
v5 = WebPSafeMalloc(v2 * v3, (unsigned __int64)(v2 * (__int64)v3) >> 32, 4);
if ( v5 )
{
*(_DWORD *)(a1 + 160) = v5;
*(_DWORD *)(a1 + 52) = v5;
*(_DWORD *)(a1 + 56) = v2;
return 1;
}
LABEL_23:
v8 = a1;
v9 = 1;
return sub_7329F0(v8, v9);
}
}
else
{
v7 = *(_DWORD *)(a1 + 4);
WebPSafeFree(*(void **)(a1 + 156));
*(_DWORD *)(a1 + 156) = 0;
*(_DWORD *)(a1 + 36) = 0;
if ( v7 << 30 )
v8 = a1;
*(_DWORD *)(a1 + 24) = 0;
if ( v7 << 30 )
v9 = 4;
*(_DWORD *)(a1 + 20) = 0;
*(_DWORD *)(a1 + 16) = 0;
*(_DWORD *)(a1 + 32) = 0;
*(_DWORD *)(a1 + 28) = 0;
*(_DWORD *)(a1 + 40) = 0;
if ( v7 << 30 )
return sub_7329F0(v8, v9);
if ( (v7 & 4) != 0 )
{
v11 = v3 * (__int64)v2;
v10 = v2;
}
else
{
v10 = 0;
v11 = 0;
}
v19 = v2 * (__int64)v3;
v12 = v2 <= 0;
if ( v2 > 0 )
v12 = v3 <= 0;
if ( !v12 )
{
v13 = (v3 + 1) >> 1;
v14 = (v2 + 1) >> 1;
if ( (v13 | v14) >= 0 )
{
v15 = v14 * (__int64)v13;
v20 = v14 * v13;
v16 = (v15 + (unsigned __int64)(unsigned int)v15) >> 32;
LODWORD(v15) = 2 * v15;
HIDWORD(v15) += v16;
v17 = WebPSafeMalloc(v19 + v11 + v15, (unsigned __int64)(v19 + v11 + v15) >> 32, 1);
if ( v17 )
{
*(_DWORD *)(a1 + 156) = v17;
*(_DWORD *)(a1 + 20) = v19 + v17;
v18 = v19 + v17 + v20;
*(_DWORD *)(a1 + 28) = v2;
*(_DWORD *)(a1 + 24) = v18;
*(_DWORD *)(a1 + 32) = v14;
*(_DWORD *)(a1 + 40) = v10;
*(_DWORD *)(a1 + 16) = v17;
if ( v11 )
*(_DWORD *)(a1 + 36) = v18 + v20;
return 1;
}
goto LABEL_23;
}
}
}
return sub_7329F0(a1, 5);
}