//
// sub_14040CC50 from 0x14040cc50 to 0x14040ce6b (539 bytes)
//
// 2 xrefs:
// > LevelSettingsObject::objectFromDict @ 0x1404121b3
// > ??> @ 0x140925d0c
//
// 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 11:32:01 +0000
//
// Hidden C++ exception states: #wind=1
void __fastcall sub_14040CC50(_QWORD *a1, _QWORD *a2)
{
_QWORD *v4; // rbx
__int64 v5; // r8
__int64 v6; // rax
_QWORD *v7; // rsi
char *v8; // rbx
__int64 v9; // rax
unsigned __int64 v10; // rcx
size_t v11; // rbp
unsigned __int64 v12; // rsi
size_t v13; // r8
const void *v14; // rdx
const char *v15; // rcx
__int64 v16; // rcx
int v17; // ebx
__int64 v18; // r8
__int64 v19; // r9
__int64 v20; // rdx
char *v21; // r8
unsigned __int64 v22; // rsi
unsigned __int64 v23; // rax
size_t v24; // rax
char *v25; // rcx
char *String[2]; // [rsp+38h] [rbp-50h] BYREF
__int128 v27; // [rsp+48h] [rbp-40h]
v4 = (_QWORD *)*a2;
sub_14018C850((__int64)a2, (__int64)a2, *(_QWORD *)(*a2 + 8LL));
v4[1] = v4;
*v4 = v4;
v4[2] = v4;
a2[1] = 0;
v6 = a1[2];
if ( v6 )
{
v7 = a1;
if ( a1[3] > 0xFu )
v7 = (_QWORD *)*a1;
v8 = (char *)v7 + v6;
LOBYTE(v5) = 124;
v9 = sub_140677120(v7, (char *)v7 + v6, v5);
v10 = v9 - (_QWORD)v7;
v11 = -1;
v12 = -1;
if ( (char *)v9 != v8 )
v12 = v10;
*(_OWORD *)String = 0;
v27 = 0;
v13 = v12;
if ( a1[2] < v12 )
v13 = a1[2];
v14 = a1;
if ( a1[3] > 0xFu )
v14 = (const void *)*a1;
sub_14003D230(String, v14, v13);
v15 = (const char *)String;
if ( *((_QWORD *)&v27 + 1) > 0xFu )
v15 = String[0];
v17 = atoi(v15);
v20 = *((_QWORD *)&v27 + 1);
if ( *((_QWORD *)&v27 + 1) > 0xFu )
{
v21 = String[0];
if ( (unsigned __int64)(*((_QWORD *)&v27 + 1) + 1LL) >= 0x1000 )
{
v21 = *((char **)String[0] - 1);
if ( (unsigned __int64)(String[0] - v21 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v21);
}
if ( v17 <= 1 && v12 != -1 )
{
v22 = v12 + 1;
*(_OWORD *)String = 0;
v27 = 0;
v23 = a1[2];
if ( v23 < v22 )
sub_14003F4D0(v16, v20, v18, v19);
v24 = v23 - v22;
if ( v24 != -1 )
v11 = v24;
if ( a1[3] > 0xFu )
a1 = (_QWORD *)*a1;
sub_14003D230(String, (char *)a1 + v22, v11);
MusicDownloadManager::decodeCustomSFXMappingEntries(String, a2, 0);
if ( *((_QWORD *)&v27 + 1) > 0xFu )
{
v25 = String[0];
if ( (unsigned __int64)(*((_QWORD *)&v27 + 1) + 1LL) >= 0x1000 )
{
v25 = *((char **)String[0] - 1);
if ( (unsigned __int64)(String[0] - v25 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v25);
}
}
}
}