//
// sub_180002C10 from 0x180002c10 to 0x180002ddf (463 bytes)
//
// 2 xrefs:
// > ??> @ 0x180023428
// > ??> @ 0x180049198
//
// 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
//
// Hidden C++ exception states: #wind=1
void __fastcall sub_180002C10(__int64 a1)
{
__int64 v2; // rdi
__int64 ***v3; // r8
__int64 **v4; // r9
__int64 *v5; // rcx
void **v6; // rbx
__int64 v7; // rdx
__int64 v8; // rcx
int v9; // ecx
int v10; // ecx
unsigned int *v11; // rdx
void (__fastcall ***v12)(_QWORD, _QWORD); // rcx
unsigned int *v13; // rdx
__int64 v14; // rcx
_QWORD *v15; // rdx
__int64 v16; // r8
__int64 v17; // rcx
__int64 v18; // rax
__int64 v19; // rcx
void *v20; // rcx
cocos2d::CCUserDefault *v21; // rax
void *Block[2]; // [rsp+20h] [rbp-38h] BYREF
__int128 v23; // [rsp+30h] [rbp-28h]
v2 = a1 + 64;
pthread_mutex_lock(a1 + 64);
v3 = *(__int64 ****)(a1 + 56);
v4 = v3[1];
if ( !v4 )
{
pthread_mutex_unlock(v2);
return;
}
v5 = **v3;
v6 = (void **)v5[2];
v7 = *v5;
v3[1] = (__int64 **)((char *)v4 - 1);
*(_QWORD *)v5[1] = v7;
*(_QWORD *)(v7 + 8) = v5[1];
j_j_free(v5);
pthread_mutex_unlock(v2);
v8 = *(unsigned int *)v6;
if ( !(_DWORD)v8 )
{
sub_180002DE0(v8, v6);
goto LABEL_23;
}
v9 = v8 - 1;
if ( !v9 )
{
v15 = (char *)v6[1] + 40;
if ( *((_QWORD *)v6[1] + 8) > 0xFu )
v15 = (_QWORD *)*v15;
*(_OWORD *)Block = 0;
v23 = 0;
v16 = -1;
do
++v16;
while ( *((_BYTE *)v15 + v16) );
sub_180003AB0(Block, v15);
v18 = cocos2d::CCUserDefault::sharedUserDefault(v17);
cocos2d::CCUserDefault::setStringForKey(v18, "downloaded-version-code", Block);
if ( *((_QWORD *)&v23 + 1) > 0xFu )
{
v20 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v23 + 1) + 1LL) >= 0x1000 )
{
v20 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v20 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v20);
}
v21 = (cocos2d::CCUserDefault *)cocos2d::CCUserDefault::sharedUserDefault(v19);
cocos2d::CCUserDefault::flush(v21);
goto LABEL_23;
}
v10 = v9 - 1;
if ( !v10 )
{
v13 = (unsigned int *)v6[1];
v14 = *(_QWORD *)(*((_QWORD *)v13 + 1) + 200LL);
if ( v14 )
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v14 + 8LL))(v14, *v13);
goto LABEL_11;
}
if ( v10 == 1 )
{
v11 = (unsigned int *)v6[1];
v12 = *(void (__fastcall ****)(_QWORD, _QWORD))(*((_QWORD *)v11 + 1) + 200LL);
if ( v12 )
{
(**v12)(v12, *v11);
j_j_free(v6[1]);
goto LABEL_23;
}
LABEL_11:
j_j_free(v6[1]);
}
LABEL_23:
j_j_free(v6);
}