//
// sub_1000D2610 from 0x1000d2610 to 0x1000d2990 (896 bytes)
//
// 2 xrefs:
// > GJAccountManager::onLoginAccountCompleted @ 0x1000d035f
// > GJAccountManager::onSyncAccountCompleted @ 0x1000d0964
//
// 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_1000D2610(unsigned __int8 *a1, const char *a2, double a3)
{
unsigned int v3; // eax
unsigned __int8 *v4; // r14
__int64 v5; // rbx
size_t v6; // rax
bool v7; // zf
__int64 v8; // rbx
unsigned __int8 *v9; // rcx
unsigned __int8 *v10; // rdx
__int64 v11; // rdi
unsigned __int64 v12; // r8
unsigned __int8 *v13; // r14
unsigned int v14; // r13d
unsigned __int64 v15; // r13
unsigned __int8 *v16; // r12
size_t v17; // r13
char *v18; // r15
char v19; // al
const char *v20; // r12
size_t v21; // r14
char *v22; // rax
size_t v23; // rax
size_t v24; // r13
char *v25; // r15
size_t v26; // r14
__int64 v27; // rax
__int64 v28; // r15
unsigned __int8 *v29; // rax
unsigned int v30; // r14d
unsigned __int8 *v31; // r12
unsigned __int64 v32; // r14
size_t v33; // rax
unsigned __int8 *v34; // rcx
unsigned __int8 *v35; // r14
__int64 v36; // rsi
unsigned __int64 v37; // r12
unsigned __int8 *v39; // [rsp+8h] [rbp-88h]
__int64 v40; // [rsp+10h] [rbp-80h]
_QWORD v42[2]; // [rsp+20h] [rbp-70h] BYREF
void *__p; // [rsp+30h] [rbp-60h]
unsigned __int64 v44; // [rsp+38h] [rbp-58h]
__int64 v45; // [rsp+40h] [rbp-50h]
size_t __dst; // [rsp+48h] [rbp-48h] BYREF
size_t v47; // [rsp+50h] [rbp-40h]
void *v48; // [rsp+58h] [rbp-38h]
unsigned __int8 *v49; // [rsp+60h] [rbp-30h]
v40 = sub_10071F9E0(a1, a2);
v3 = *a1;
v4 = a1 + 1;
v49 = a1;
v39 = a1 + 1;
if ( (v3 & 1) != 0 )
{
v4 = *((unsigned __int8 **)a1 + 2);
v5 = *((_QWORD *)a1 + 1);
}
else
{
v5 = v3 >> 1;
}
v6 = strlen(a2);
v45 = v5;
v7 = v5 != 0 && v6 != 0;
v8 = -1;
if ( v7 )
{
v9 = &v4[v45];
v10 = v4;
LABEL_6:
v11 = 0;
while ( *v10 != a2[v11] )
{
if ( v6 == ++v11 )
{
if ( ++v10 != v9 )
goto LABEL_6;
v10 = &v4[v45];
break;
}
}
v8 = -1;
if ( v10 != v9 )
v8 = v10 - v4;
}
v12 = 0;
v13 = v49;
do
{
v14 = *v13;
if ( (v14 & 1) != 0 )
{
v15 = *((_QWORD *)v13 + 1);
if ( v15 < v12 )
LABEL_65:
sub_1000547C0();
v16 = *((unsigned __int8 **)v13 + 2);
}
else
{
v15 = v14 >> 1;
v16 = v39;
if ( v12 > v15 )
goto LABEL_65;
}
v17 = v15 - v12;
if ( v17 >= v8 - v12 )
v17 = v8 - v12;
if ( v17 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a3);
v44 = v12;
if ( v17 >= 0x17 )
{
v21 = (v17 | 7) + 1;
if ( (v17 | 7) == 0x17 )
v21 = 26;
v22 = (char *)operator new(v21);
v12 = v44;
v18 = v22;
v48 = v22;
__dst = v21 + 1;
v13 = v49;
v47 = v17;
}
else
{
LOBYTE(__dst) = 2 * v17;
v18 = (char *)&__dst + 1;
if ( !v17 )
{
BYTE1(__dst) = 0;
v19 = __dst;
if ( (__dst & 1) == 0 )
goto LABEL_26;
goto LABEL_33;
}
}
memmove(v18, &v16[v12], v17);
v12 = v44;
v18[v17] = 0;
v19 = __dst;
if ( (__dst & 1) == 0 )
{
LABEL_26:
if ( !v19 && v12 == v45 )
goto LABEL_47;
v20 = (char *)&__dst + 1;
goto LABEL_36;
}
LABEL_33:
if ( !v47 && v12 == v45 )
goto LABEL_47;
v20 = (const char *)v48;
LABEL_36:
v23 = strlen(v20);
if ( v23 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a3);
v24 = v23;
if ( v23 >= 0x17 )
{
v26 = (v23 | 7) + 1;
if ( (v23 | 7) == 0x17 )
v26 = 26;
v25 = (char *)operator new(v26);
__p = v25;
v42[0] = v26 | 1;
v42[1] = v24;
v13 = v49;
}
else
{
LOBYTE(v42[0]) = 2 * v23;
v25 = (char *)v42 + 1;
if ( !v23 )
goto LABEL_44;
}
memmove(v25, v20, v24);
LABEL_44:
v25[v24] = 0;
v27 = sub_1007AB360(v42);
sub_10071FCD0(v40, v27);
if ( (v42[0] & 1) != 0 )
operator delete(__p);
v12 = v44;
LABEL_47:
v28 = -1;
if ( v8 == -1 )
{
if ( (__dst & 1) == 0 )
goto LABEL_14;
LABEL_63:
v37 = v12;
operator delete(v48);
v12 = v37;
goto LABEL_14;
}
v29 = v13;
v30 = *v13;
if ( (v30 & 1) != 0 )
{
v31 = *((unsigned __int8 **)v29 + 2);
v32 = *((_QWORD *)v29 + 1);
}
else
{
v32 = v30 >> 1;
v31 = v39;
}
v33 = strlen(a2);
v12 = v8 + 1;
if ( v32 > v8 + 1 && v33 != 0 )
{
v34 = &v31[v8 + 1];
v35 = &v31[v32];
LABEL_55:
v36 = 0;
while ( *v34 != a2[v36] )
{
if ( v33 == ++v36 )
{
if ( ++v34 != v35 )
goto LABEL_55;
v34 = v35;
break;
}
}
v28 = v34 - v31;
if ( v34 == v35 )
v28 = -1;
}
v13 = v49;
if ( (__dst & 1) != 0 )
goto LABEL_63;
LABEL_14:
v7 = v8 == -1;
v8 = v28;
}
while ( !v7 );
return v40;
}