//
// sub_18004EDE0 from 0x18004ede0 to 0x18004efcd (493 bytes)
//
// 5 xrefs:
// > ??> @ 0x180166e48
// > ??> @ 0x180166e88
// > ??> @ 0x180166ec8
// > ??> @ 0x1801f8844
// > ??> @ 0x1801f8850
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// 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 10:53:16 +0000
//
_DWORD *__fastcall sub_18004EDE0(__int64 a1, __int64 a2, int *a3)
{
int v5; // esi
__int64 v6; // rdi
int v7; // r13d
_DWORD *v8; // r15
int v9; // eax
int v10; // ebp
unsigned int *v11; // r14
unsigned int v12; // ebx
int v13; // eax
int v14; // eax
int i; // ecx
__int64 v16; // rbx
int *v17; // r14
int v18; // eax
__int64 v19; // r9
int v20; // r8d
int *v21; // rdx
__int64 v22; // rax
int *v23; // rcx
int v24; // eax
__int64 v27; // [rsp+68h] [rbp+10h]
v5 = 1;
v6 = 0;
v7 = 0;
v8 = (_DWORD *)sub_180033C30(a1, 1, 1812);
v27 = *(_QWORD *)(a2 + 32);
if ( v8 )
{
*v8 = sub_180048210(a3, 0x18u);
v8[1] = sub_180048210(a3, 0x18u);
v8[2] = sub_180048210(a3, 0x18u) + 1;
v8[3] = sub_180048210(a3, 6u) + 1;
v9 = sub_180048210(a3, 8u);
v8[4] = v9;
if ( v9 >= 0 )
{
v10 = 0;
if ( (int)v8[3] <= 0 )
{
LABEL_12:
if ( v7 <= 0 )
{
LABEL_16:
v19 = (int)v8[4];
v20 = *(_DWORD *)(v27 + 24);
if ( (int)v19 < v20 )
{
if ( v7 <= 0 )
{
LABEL_22:
v23 = *(int **)(v27 + 8 * v19 + 2848);
v24 = *v23;
if ( *v23 <= 0 )
return v8;
while ( 1 )
{
v5 *= v8[3];
if ( v5 > v23[1] )
break;
if ( --v24 <= 0 )
return v8;
}
}
else
{
v21 = v8 + 69;
while ( 1 )
{
v22 = *v21;
if ( (int)v22 >= v20 || !*(_DWORD *)(*(_QWORD *)(v27 + 8 * v22 + 2848) + 16LL) )
break;
++v6;
++v21;
if ( v6 >= v7 )
goto LABEL_22;
}
}
}
}
else
{
v16 = 0;
v17 = v8 + 69;
while ( 1 )
{
v18 = sub_180048210(a3, 8u);
if ( v18 < 0 )
break;
*v17 = v18;
++v16;
++v17;
if ( v16 >= v7 )
goto LABEL_16;
}
}
}
else
{
v11 = v8 + 5;
while ( 1 )
{
v12 = sub_180048210(a3, 3u);
v13 = sub_180048210(a3, 1u);
if ( v13 < 0 )
break;
if ( v13 )
{
v14 = sub_180048210(a3, 5u);
if ( v14 < 0 )
break;
v12 |= 8 * v14;
}
*v11 = v12;
for ( i = 0; v12; v12 >>= 1 )
i += v12 & 1;
v7 += i;
++v10;
++v11;
if ( v10 >= v8[3] )
goto LABEL_12;
}
}
}
memset(v8, 0, 0x714u);
sub_180033C90(a1, (__int64)v8);
}
return nullptr;
}