//
// sub_100183E40 from 0x100183e40 to 0x100183f7d (317 bytes)
//
// 1 xrefs:
// > sub_100183CF0 @ 0x100183dac
//
// 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_100183E40(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, unsigned __int8 a6)
{
__int64 v6; // r12
__int64 v8; // rbx
__int64 v9; // rax
__int64 v10; // rcx
signed __int64 v11; // r13
bool v12; // cc
signed __int64 v13; // rcx
char *v14; // r14
size_t v15; // r12
void *v16; // rsi
__int64 v17; // r14
__int64 v18; // r15
__int64 v21; // [rsp+10h] [rbp-50h]
_QWORD __b[2]; // [rsp+20h] [rbp-40h] BYREF
void *__p; // [rsp+30h] [rbp-30h]
if ( !a1 )
return 0;
v6 = a5;
v8 = a1;
v9 = a4 - a2;
v10 = *(_QWORD *)(a5 + 24);
v11 = 0;
v12 = v10 <= v9;
v13 = v10 - v9;
if ( !v12 )
v11 = v13;
if ( a3 - a2 > 0
&& (*(__int64 (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)a1 + 96LL))(a1, a2, a3 - a2) != a3 - a2 )
{
return 0;
}
if ( v11 > 0 )
{
if ( (unsigned __int64)v11 >= 0x17 )
{
v21 = v6;
v15 = 26;
if ( (v11 | 7) != 0x17 )
v15 = (v11 | 7) + 1;
v14 = (char *)operator new(v15);
__p = v14;
__b[0] = v15 + 1;
v6 = v21;
__b[1] = v11;
}
else
{
LOBYTE(__b[0]) = 2 * v11;
v14 = (char *)__b + 1;
}
memset(v14, a6, v11);
v14[v11] = 0;
v16 = (__b[0] & 1) != 0 ? __p : (char *)__b + 1;
v17 = (*(__int64 (__fastcall **)(__int64, void *, signed __int64))(*(_QWORD *)a1 + 96LL))(a1, v16, v11);
if ( (__b[0] & 1) != 0 )
operator delete(__p);
if ( v17 != v11 )
return 0;
}
v18 = a4 - a3;
if ( v18 > 0 && (*(__int64 (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)a1 + 96LL))(a1, a3, v18) != v18 )
return 0;
*(_QWORD *)(v6 + 24) = 0;
return v8;
}