//
// sub_1800DC940 from 0x1800dc940 to 0x1800dca90 (336 bytes)
//
// 2 xrefs:
// > ??> @ 0x18016d210
// > ??> @ 0x1801ff594
//
// 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_1800DC940(
__int64 a1,
unsigned int a2,
unsigned int a3,
_QWORD *a4,
_QWORD *a5,
unsigned int *a6,
_DWORD *a7)
{
int v8; // r8d
__int64 v10; // rbx
int v12; // ecx
unsigned int v13; // edx
__int64 result; // rax
unsigned int v15; // edx
__int64 v16; // r8
v8 = *(_DWORD *)(a1 + 104);
v10 = a2;
switch ( *(_DWORD *)(a1 + 40) )
{
case 1:
goto LABEL_8;
case 2:
v12 = 16;
goto LABEL_9;
case 3:
v12 = 24;
goto LABEL_9;
}
if ( (unsigned int)(*(_DWORD *)(a1 + 40) - 4) > 1 )
{
LABEL_8:
v12 = 8;
goto LABEL_9;
}
v12 = 32;
LABEL_9:
v13 = *(_DWORD *)(a1 + 384);
if ( !v13
|| (unsigned int)v10 + a3 <= v13
|| (unsigned int)v10 >= v13 + v12 * v8
|| (result = sub_1800DCB70(a1), !(_DWORD)result) )
{
v15 = *(_DWORD *)(a1 + 72);
v16 = *(_QWORD *)(a1 + 352);
if ( (unsigned int)v10 >= v15 || a3 > v15 )
{
*a4 = 0;
if ( a5 )
*a5 = 0;
if ( a6 )
*a6 = 0;
if ( a7 )
*a7 = 0;
return 31;
}
else
{
*a4 = v16 + v10;
if ( (unsigned int)v10 + a3 > v15 )
{
if ( a6 )
*a6 = *(_DWORD *)(a1 + 72) - v10;
if ( a5 )
*a5 = v16;
if ( a7 )
*a7 = a3 + v10 - *(_DWORD *)(a1 + 72);
}
else
{
if ( a6 )
*a6 = a3;
if ( a5 )
*a5 = 0;
if ( a7 )
{
*a7 = 0;
return 0;
}
}
return 0;
}
}
return result;
}