//
// GJAccountManager::linkToAccount from 0x140309590 to 0x140309820 (656 bytes)
//
// 2 xrefs:
// > AccountLoginLayer::loginAccountFinished @ 0x1400917dd
// > ??> @ 0x14091e5fc
//
// 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:30:10 +0000
//
// Hidden C++ exception states: #wind=9
void __fastcall GJAccountManager::linkToAccount(__int64 a1, void **a2, void **a3, int a4, int a5)
{
void **v9; // rcx
void *v10; // rdx
void *v11; // rdx
__int64 v12; // rcx
void **v13; // rbx
__int64 v14; // rcx
void **v15; // rcx
void *v16; // rdx
_DWORD *v17; // rbp
float v18; // xmm0_4
__int64 v19; // rcx
__int64 v20; // rdx
__int64 v21; // r8
void (__fastcall ***v22)(_QWORD); // rcx
__int64 v23; // rax
__int64 v24; // rcx
void *v25; // [rsp+20h] [rbp-78h]
void *v26; // [rsp+20h] [rbp-78h]
void *v27; // [rsp+20h] [rbp-78h]
void *v28; // [rsp+20h] [rbp-78h]
void *v29; // [rsp+28h] [rbp-70h]
_BYTE v30[32]; // [rsp+38h] [rbp-60h] BYREF
void **v31; // [rsp+58h] [rbp-40h]
void **v32; // [rsp+60h] [rbp-38h]
v31 = a2;
v32 = a3;
v9 = (void **)(a1 + 376);
if ( v9 != a3 )
{
v10 = a3;
if ( (unsigned __int64)a3[3] > 0xF )
v10 = *a3;
sub_1400405A0(v9, v10, (size_t)a3[2]);
}
if ( (void **)(a1 + 328) != a2 )
{
v11 = a2;
if ( (unsigned __int64)a2[3] > 0xF )
v11 = *a2;
sub_1400405A0((void **)(a1 + 328), v11, (size_t)a2[2]);
}
*(_DWORD *)(a1 + 360) = a4;
v12 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v29 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v29);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v12 = *(_QWORD *)&qword_14090BFB0;
}
GameLevelManager::resetAccountCaches(v12);
v13 = (void **)sub_14003F4F0((__int64)v30, a1 + 328);
v14 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v25 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v25);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v14 = qword_14090BFD0;
}
v15 = (void **)(v14 + 656);
if ( v15 != v13 )
{
v16 = v13;
if ( (unsigned __int64)v13[3] > 0xF )
v16 = *v13;
sub_1400405A0(v15, v16, (size_t)v13[2]);
}
sub_14003D310((__int64)v13);
v17 = (_DWORD *)qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v26 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v26);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v17 = (_DWORD *)qword_14090BFD0;
}
v17[175] = a5;
v18 = (float)((float)rand() / 32767.0) * 1000.0;
v17[174] = (int)v18;
v17[173] = a5 + (int)v18;
v19 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v27 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v27);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v19 = *(_QWORD *)&qword_14090BFB0;
}
GameLevelManager::syncFollowListIfNeeded(v19);
v22 = *(void (__fastcall ****)(_QWORD))(a1 + 424);
if ( v22 )
(**v22)(v22);
v23 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v28 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v28);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v23 = qword_14090BFD0;
}
v24 = *(_QWORD *)(v23 + 592);
if ( v24 )
MenuLayer::updateUserProfileButton(v24, v20, v21);
sub_14003D310((__int64)a2);
sub_14003D310((__int64)a3);
}