//
// cocos2d::unzOpenCurrentFile3 from 0x5f1f84 to 0x5f22c6 (834 bytes)
//
// 3 xrefs:
// > cocos2d::unzOpenCurrentFile @ 0x5f22de
// > cocos2d::unzOpenCurrentFilePassword @ 0x5f22f2
// > cocos2d::unzOpenCurrentFile2 @ 0x5f2302
//
// 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 cocos2d::unzOpenCurrentFile3(cocos2d *this, _DWORD *a2, int *a3, int *a4, int a5, const char *a6)
{
__int64 v10; // r2
int v11; // r7
int v12; // r0
int v13; // r6
int v14; // r10
unsigned int v15; // r11
_DWORD *v16; // r7
void *v17; // r0
int v18; // r6
int v19; // r3
int v20; // r3
int v21; // r3
int v22; // r3
int v23; // r1
int v24; // r2
int v25; // r3
int v26; // r1
int v27; // r2
int v28; // r3
int v29; // r1
int v30; // r2
__int64 v31; // r2
int v32; // r5
__int64 v33; // r2
__int64 v35; // [sp+8h] [bp-2Ch]
unsigned int v36; // [sp+14h] [bp-20h]
int v37; // [sp+18h] [bp-1Ch] BYREF
int v38; // [sp+1Ch] [bp-18h] BYREF
int v39; // [sp+20h] [bp-14h] BYREF
unsigned int v40; // [sp+24h] [bp-10h] BYREF
int v41; // [sp+28h] [bp-Ch] BYREF
if ( a5 || !this || !*((_QWORD *)this + 12) )
return -102;
if ( *((_DWORD *)this + 56) )
cocos2d::unzCloseCurrentFile(this, a2);
v10 = *((_QWORD *)this + 27) + *((_QWORD *)this + 9);
if ( cocos2d::call_zseek64((int)this, *((_DWORD *)this + 12), v10, SHIDWORD(v10), 0) )
return -103;
if ( sub_5F0BBC((int)this, *((_DWORD *)this + 12), &v37) )
{
v11 = -1;
}
else if ( v37 == 67324752 )
{
v11 = 0;
}
else
{
v11 = -103;
}
if ( sub_5F0B68((int)this, *((_DWORD *)this + 12), &v38) )
v11 = -1;
if ( sub_5F0B68((int)this, *((_DWORD *)this + 12), &v39) )
v11 = -1;
if ( sub_5F0B68((int)this, *((_DWORD *)this + 12), &v38) )
{
v11 = -1;
}
else if ( !v11 )
{
if ( v38 == *((_DWORD *)this + 35) )
{
if ( (v38 & 0xFFFFFFF7) != 0 )
{
if ( v38 == 12 )
v11 = 0;
else
v11 = -103;
}
}
else
{
v11 = -103;
}
}
if ( sub_5F0BBC((int)this, *((_DWORD *)this + 12), &v38) )
v11 = -1;
if ( sub_5F0BBC((int)this, *((_DWORD *)this + 12), &v38) )
{
v11 = -1;
}
else if ( !v11 && v38 != *((_DWORD *)this + 37) )
{
if ( (v39 & 8) != 0 )
v11 = 0;
else
v11 = -103;
}
if ( sub_5F0BBC((int)this, *((_DWORD *)this + 12), &v38) )
{
v11 = -1;
}
else if ( v38 != -1 && !v11 && v38 != *((_QWORD *)this + 19) )
{
if ( (v39 & 8) != 0 )
v11 = 0;
else
v11 = -103;
}
if ( sub_5F0BBC((int)this, *((_DWORD *)this + 12), &v38) )
{
v11 = -1;
}
else if ( v38 != -1 && !v11 && v38 != *((_QWORD *)this + 20) )
{
if ( (v39 & 8) != 0 )
v11 = 0;
else
v11 = -103;
}
if ( sub_5F0B68((int)this, *((_DWORD *)this + 12), (int *)&v40) )
{
v11 = -1;
}
else if ( !v11 && v40 != *((_DWORD *)this + 42) )
{
v11 = -103;
}
v36 = v40;
v12 = sub_5F0B68((int)this, *((_DWORD *)this + 12), &v41);
v13 = v41;
if ( v12 )
v11 = -1;
v14 = v11;
v35 = *((_QWORD *)this + 27) + 30LL + v40;
v15 = v41 + v36;
if ( v11 )
return -103;
v16 = malloc(0xD0u);
if ( !v16 )
return -104;
v17 = malloc(0x4000u);
v16[22] = v13;
v16[50] = a4;
*((_QWORD *)v16 + 10) = v35;
*((_QWORD *)v16 + 12) = 0;
*v16 = v17;
if ( !v17 )
{
free(v16);
return -104;
}
v16[18] = 0;
v18 = *((_DWORD *)this + 35);
if ( a2 )
*a2 = v18;
if ( a3 )
{
*a3 = 6;
v19 = *((_DWORD *)this + 34) & 6;
switch ( v19 )
{
case 4:
v20 = 2;
break;
case 6:
v20 = 1;
break;
case 2:
v20 = 9;
break;
default:
goto LABEL_67;
}
*a3 = v20;
}
LABEL_67:
v21 = *((_DWORD *)this + 37);
v16[46] = v18;
v16[29] = v21;
*((_QWORD *)v16 + 13) = 0;
v22 = *((_DWORD *)this + 12);
v16[28] = 0;
v16[45] = v22;
v23 = *((_DWORD *)this + 1);
v24 = *((_DWORD *)this + 2);
v25 = *((_DWORD *)this + 3);
v16[34] = *(_DWORD *)this;
v16[35] = v23;
v16[36] = v24;
v16[37] = v25;
v26 = *((_DWORD *)this + 5);
v27 = *((_DWORD *)this + 6);
v28 = *((_DWORD *)this + 7);
v16[38] = *((_DWORD *)this + 4);
v16[39] = v26;
v16[40] = v27;
v16[41] = v28;
v29 = *((_DWORD *)this + 9);
v30 = *((_DWORD *)this + 10);
v16[42] = *((_DWORD *)this + 8);
v16[43] = v29;
v16[44] = v30;
v31 = *((_QWORD *)this + 9);
v16[6] = 0;
*((_QWORD *)v16 + 24) = v31;
if ( v18 == 12 )
{
if ( !a4 )
v16[50] = 1;
goto LABEL_75;
}
if ( v18 != 8 || a4 )
{
LABEL_75:
v33 = *((_QWORD *)this + 19);
*((_DWORD *)this + 56) = v16;
*((_QWORD *)v16 + 15) = v33;
*((_QWORD *)v16 + 16) = *((_QWORD *)this + 20);
*((_QWORD *)v16 + 8) = *((_QWORD *)this + 27) + 30LL + v15;
v16[2] = 0;
*((_DWORD *)this + 57) = 0;
return v14;
}
v16[9] = 0;
v16[10] = 0;
v16[11] = 0;
v16[1] = 0;
v16[2] = 0;
v32 = inflateInit2_(v16 + 1, -15, "1.2.8", 56);
if ( !v32 )
{
v16[18] = 8;
goto LABEL_75;
}
v14 = v32;
free(v16);
return v14;
}