//
// sub_1800C4120 from 0x1800c4120 to 0x1800c427f (351 bytes)
//
// 2 xrefs:
// > sub_1800C3960 @ 0x1800c3a07
// > ??> @ 0x1801fde18
//
// 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:54:04 +0000
//
__int64 __fastcall sub_1800C4120(__int64 a1)
{
__int64 v1; // rbx
__int64 result; // rax
__int64 v3; // rcx
int v4; // eax
unsigned int v5; // edx
__int64 v6; // rcx
__int64 v7; // rcx
__int64 v8; // rdx
unsigned int v9; // eax
unsigned int v10; // [rsp+30h] [rbp+8h] BYREF
void *v11; // [rsp+38h] [rbp+10h] BYREF
v1 = a1 - 8;
if ( !a1 )
v1 = 0;
if ( WaitForSingleObject(*(HANDLE *)(v1 + 1848), 0xC8u) == -1 )
return 28;
v3 = *(_QWORD *)(v1 + 1832);
v10 = 0;
v4 = (*(__int64 (__fastcall **)(__int64, unsigned int *))(*(_QWORD *)v3 + 48LL))(v3, &v10);
if ( v4 == -2004287484 )
{
*(_BYTE *)(v1 + 785) = 1;
return 49;
}
else if ( v4 >= 0 )
{
v5 = *(_DWORD *)(v1 + 1864);
if ( v10 > *(_DWORD *)(v1 + 1872) - v5 )
{
return 0;
}
else
{
while ( 1 )
{
v6 = v1 + 8;
if ( !v1 )
v6 = 0;
result = (*(__int64 (__fastcall **)(__int64, _QWORD, _QWORD))(v1 + 16))(v6, *(_QWORD *)(v1 + 1856), v5);
if ( (_DWORD)result )
break;
if ( (*(int (__fastcall **)(_QWORD, unsigned int *))(**(_QWORD **)(v1 + 1832) + 48LL))(
*(_QWORD *)(v1 + 1832),
&v10) < 0 )
return 49;
v7 = *(_QWORD *)(v1 + 1840);
v8 = *(unsigned int *)(v1 + 1864);
v11 = nullptr;
if ( (*(int (__fastcall **)(__int64, __int64, void **))(*(_QWORD *)v7 + 24LL))(v7, v8, &v11) < 0 )
return 49;
memmove(v11, *(const void **)(v1 + 1856), *(int *)(v1 + 1868));
if ( (*(int (__fastcall **)(_QWORD, _QWORD, _QWORD))(**(_QWORD **)(v1 + 1840) + 32LL))(
*(_QWORD *)(v1 + 1840),
*(unsigned int *)(v1 + 1864),
0) < 0 )
return 49;
v5 = *(_DWORD *)(v1 + 1864);
v9 = *(_DWORD *)(v1 + 1872) - v5;
v10 += v5;
if ( v10 > v9 )
return 0;
}
}
}
else
{
return 49;
}
return result;
}