//
// sub_10020E0CC from 0x10020e0cc to 0x10020e748 (1660 bytes)
//
// 2 xrefs:
// > GJBaseGameLayer::processAreaEffects @ 0x1001f4380
// > sub_10020E0CC @ 0x10020e4f8
//
// 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
//
__int64 __fastcall sub_10020E0CC(
__int64 result,
__int64 a2,
__int64 (__fastcall **a3)(__int64, __int64),
__int64 a4,
char a5)
{
__int64 v8; // x20
__int64 v9; // x21
__int64 v10; // x27
__int64 v11; // x8
__int64 v12; // x24
__int64 v13; // x8
unsigned __int64 v14; // x9
unsigned __int64 v15; // x25
__int64 v16; // x26
__int64 (__fastcall *v17)(__int64, __int64); // x9
char v18; // w27
int v19; // w0
__int64 v20; // x0
char v21; // w27
int v22; // w0
__int64 v23; // x0
__int64 v24; // x1
__int64 v25; // x1
__int64 v26; // x27
char v27; // w28
int v28; // w0
__int64 v29; // x0
__int64 v30; // x1
unsigned __int64 v31; // x25
char v32; // w28
int v33; // w0
__int64 v34; // x0
__int64 v35; // x1
char v36; // w28
int v37; // w0
__int64 v38; // x1
__int64 v39; // x0
__int64 v40; // x26
char v41; // w1
char v42; // w28
char v43; // w22
__int64 v44; // x0
__int64 v45; // x0
__int64 v46; // x1
__int64 v47; // x1
__int64 v48; // [xsp+0h] [xbp-60h]
__int64 v49; // [xsp+8h] [xbp-58h]
v8 = result;
LABEL_2:
v9 = a2 - 240;
v48 = a2 - 720;
v49 = a2 - 480;
v10 = v8;
LABEL_3:
v11 = 1 - a4;
while ( 1 )
{
v8 = v10;
v12 = v11;
v13 = a2 - v10;
v14 = 0xEEEEEEEEEEEEEEEFLL * ((a2 - v10) >> 4);
if ( (__int64)v14 > 2 )
break;
if ( v14 < 2 )
return result;
if ( v14 == 2 )
{
result = (*a3)(a2 - 240, v10);
if ( !(_DWORD)result )
return result;
LABEL_83:
v44 = v10;
goto LABEL_84;
}
LABEL_11:
if ( v13 <= 5759 )
{
if ( (a5 & 1) != 0 )
return sub_10020E884(v10, a2, a3);
else
return sub_10020EB58(v10, a2, a3);
}
if ( v12 == 1 )
{
if ( v10 != a2 )
return sub_10020FC30(v10, a2, a2, a3);
return result;
}
v15 = v14 >> 1;
v16 = v10 + 240 * (v14 >> 1);
v17 = *a3;
if ( (unsigned __int64)v13 >= 0x7801 )
{
v18 = v17(v16, v10);
v19 = (*a3)(a2 - 240, v16);
if ( (v18 & 1) != 0 )
{
if ( v19 )
{
v20 = v8;
goto LABEL_28;
}
sub_10020F9DC(v8, v16);
if ( (unsigned int)(*a3)(a2 - 240, v16) )
{
v20 = v16;
LABEL_28:
v24 = a2 - 240;
LABEL_29:
sub_10020F9DC(v20, v24);
}
}
else if ( v19 )
{
sub_10020F9DC(v16, a2 - 240);
if ( (unsigned int)(*a3)(v16, v8) )
{
v20 = v8;
v24 = v16;
goto LABEL_29;
}
}
v26 = v8 + 240 * v15 - 240;
v27 = (*a3)(v26, v8 + 240);
v28 = (*a3)(v49, v26);
if ( (v27 & 1) != 0 )
{
if ( v28 )
{
v29 = v8 + 240;
goto LABEL_41;
}
sub_10020F9DC(v8 + 240, v8 + 240 * v15 - 240);
if ( (unsigned int)(*a3)(v49, v8 + 240 * v15 - 240) )
{
v29 = v8 + 240 * v15 - 240;
LABEL_41:
v30 = a2 - 480;
LABEL_42:
sub_10020F9DC(v29, v30);
}
}
else if ( v28 )
{
sub_10020F9DC(v8 + 240 * v15 - 240, v49);
if ( (unsigned int)(*a3)(v8 + 240 * v15 - 240, v8 + 240) )
{
v29 = v8 + 240;
v30 = v8 + 240 * v15 - 240;
goto LABEL_42;
}
}
v31 = v8 + 240 * v15;
v32 = (*a3)(v31 + 240, v8 + 480);
v33 = (*a3)(v48, v31 + 240);
if ( (v32 & 1) != 0 )
{
if ( v33 )
{
v34 = v8 + 480;
goto LABEL_51;
}
sub_10020F9DC(v8 + 480, v31 + 240);
if ( (unsigned int)(*a3)(v48, v31 + 240) )
{
v34 = v31 + 240;
LABEL_51:
v35 = a2 - 720;
LABEL_52:
sub_10020F9DC(v34, v35);
}
}
else if ( v33 )
{
sub_10020F9DC(v31 + 240, v48);
if ( (unsigned int)(*a3)(v31 + 240, v8 + 480) )
{
v34 = v8 + 480;
v35 = v31 + 240;
goto LABEL_52;
}
}
v36 = (*a3)(v16, v26);
v37 = (*a3)(v31 + 240, v16);
if ( (v36 & 1) != 0 )
{
if ( v37 )
{
v38 = v31 + 240;
v39 = v26;
goto LABEL_61;
}
sub_10020F9DC(v26, v16);
if ( (unsigned int)(*a3)(v31 + 240, v16) )
{
v38 = v31 + 240;
v39 = v16;
LABEL_61:
sub_10020F9DC(v39, v38);
}
}
else if ( v37 )
{
sub_10020F9DC(v16, v31 + 240);
if ( (unsigned int)(*a3)(v16, v26) )
{
v39 = v26;
v38 = v16;
goto LABEL_61;
}
}
v23 = v8;
v25 = v16;
LABEL_63:
sub_10020F9DC(v23, v25);
goto LABEL_64;
}
v21 = v17(v10, v16);
v22 = (*a3)(a2 - 240, v8);
if ( (v21 & 1) != 0 )
{
if ( v22 )
{
v23 = v16;
LABEL_38:
v25 = a2 - 240;
goto LABEL_63;
}
sub_10020F9DC(v16, v8);
if ( (unsigned int)(*a3)(a2 - 240, v8) )
{
v23 = v8;
goto LABEL_38;
}
}
else if ( v22 )
{
sub_10020F9DC(v8, a2 - 240);
if ( (unsigned int)(*a3)(v8, v16) )
{
v23 = v16;
v25 = v8;
goto LABEL_63;
}
}
LABEL_64:
if ( (a5 & 1) == 0 && ((*a3)(v8 - 240, v8) & 1) == 0 )
{
result = sub_10020EDF0(v8, a2, a3);
v10 = result;
goto LABEL_71;
}
v40 = sub_10020F154(v8, a2, a3);
if ( (v41 & 1) == 0 )
goto LABEL_69;
v42 = sub_10020F4C0(v8, v40, a3);
v10 = v40 + 240;
result = sub_10020F4C0(v40 + 240, a2, a3);
if ( (_DWORD)result )
{
a4 = -v12;
a2 = v40;
if ( (v42 & 1) != 0 )
return result;
goto LABEL_2;
}
v11 = v12 + 1;
if ( (v42 & 1) == 0 )
{
LABEL_69:
result = sub_10020E0CC(v8, v40, a3, -v12, a5 & 1);
v10 = v40 + 240;
LABEL_71:
a5 = 0;
a4 = -v12;
goto LABEL_3;
}
}
if ( v14 != 3 )
{
if ( v14 == 4 )
return sub_10020E748(v10, v10 + 240, v10 + 480, a2 - 240, a3);
if ( v14 == 5 )
{
sub_10020E748(v10, v10 + 240, v10 + 480, v10 + 720, a3);
result = (*a3)(a2 - 240, v10 + 720);
if ( (_DWORD)result )
{
sub_10020F9DC(v10 + 720, a2 - 240);
result = (*a3)(v10 + 720, v10 + 480);
if ( (_DWORD)result )
{
sub_10020F9DC(v10 + 480, v10 + 720);
result = (*a3)(v10 + 480, v10 + 240);
if ( (_DWORD)result )
{
v45 = v10 + 240;
v46 = v10 + 480;
goto LABEL_93;
}
}
}
return result;
}
goto LABEL_11;
}
v43 = (*a3)(v10 + 240, v10);
result = (*a3)(v9, v10 + 240);
if ( (v43 & 1) != 0 )
{
if ( (_DWORD)result )
goto LABEL_83;
sub_10020F9DC(v10, v10 + 240);
result = (*a3)(v9, v10 + 240);
if ( !(_DWORD)result )
return result;
v44 = v10 + 240;
LABEL_84:
v47 = v9;
return sub_10020F9DC(v44, v47);
}
if ( (_DWORD)result )
{
v45 = v10 + 240;
v46 = v9;
LABEL_93:
sub_10020F9DC(v45, v46);
result = (*a3)(v10 + 240, v10);
if ( (_DWORD)result )
{
v47 = v10 + 240;
v44 = v10;
return sub_10020F9DC(v44, v47);
}
}
return result;
}