//
// sub_1004A52A0 from 0x1004a52a0 to 0x1004a53d5 (309 bytes)
//
// 1 xrefs:
// > GManager::save @ 0x1004a51cb
//
// 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 12:30:54 +0000
//
void __fastcall sub_1004A52A0(__int64 a1, __int128 *a2, char a3)
{
void *v5; // r15
std::__thread_struct *v6; // r14
char *v7; // rax
int v8; // eax
__int128 v9; // [rsp+10h] [rbp-60h] BYREF
__int128 v10; // [rsp+20h] [rbp-50h] BYREF
void *__p; // [rsp+30h] [rbp-40h]
__int64 v12; // [rsp+40h] [rbp-30h]
pthread_t v13[5]; // [rsp+48h] [rbp-28h] BYREF
v5 = operator new(0xF0u);
sub_100158EB0((__int64)v5);
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)a1 + 904LL))(a1, v5);
(*(void (__fastcall **)(__int64))(*(_QWORD *)a1 + 912LL))(a1);
*(_QWORD *)&v9 = a1;
*((_QWORD *)&v9 + 1) = v5;
if ( a3 )
{
v6 = (std::__thread_struct *)operator new(8u);
std::__thread_struct::__thread_struct(v6);
v7 = (char *)operator new(0x30u);
v12 = 0;
*(_QWORD *)v7 = v6;
*(_OWORD *)(v7 + 8) = v9;
*((_QWORD *)v7 + 5) = *((_QWORD *)a2 + 2);
*(_OWORD *)(v7 + 24) = *a2;
*a2 = 0;
*((_QWORD *)a2 + 2) = 0;
v8 = pthread_create(v13, nullptr, sub_1004A5C90, v7);
if ( v8 )
{
std::__throw_system_error(v8, "thread constructor failed");
BUG();
}
std::thread::detach((std::thread *)v13);
std::thread::~thread((std::thread *)v13);
}
else
{
__p = *((void **)a2 + 2);
v10 = *a2;
*a2 = 0;
*((_QWORD *)a2 + 2) = 0;
sub_1004A5450(&v9, &v10);
if ( (v10 & 1) != 0 )
operator delete(__p);
}
}