//
// sub_1006D3B20 from 0x1006d3b20 to 0x1006d3cf0 (464 bytes)
//
// 9 xrefs:
// > sub_1006D3CF0 @ 0x1006d3d50
// > sub_10072D0E0 @ 0x10072d158
// > sub_10074E0B8 @ 0x10074e0f0
// > sub_10074E758 @ 0x10074e79c
// > sub_10074FA54 @ 0x10074fac4
// > sub_10074FBD0 @ 0x10074fd1c
// > sub_1007546A0 @ 0x1007546fc
// > sub_1007546A0 @ 0x10075471c
// > sub_1007546A0 @ 0x100754738
//
// This function is hookable on this platform (idp: arm, 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:12:27 +0000
//
__int64 __fastcall sub_1006D3B20(__int64 *a1, _BYTE *a2)
{
__int64 v3; // x20
int v4; // w8
__int64 v5; // x25
_BYTE *v6; // x24
_BOOL4 v7; // w23
_BYTE *v8; // x21
int v10; // w8
int v11; // w9
int v12; // w8
char v13; // w8
__int64 v14; // x22
int v15; // w9
unsigned __int8 *v16; // x24
int v17; // t1
int v18; // w8
_QWORD *v19; // x9
bool v20; // vf
if ( !a2 )
return 0;
v3 = 0;
v4 = (unsigned __int8)*a2;
if ( *a2 )
{
v5 = 0;
if ( v4 == 45 )
v6 = a2 + 1;
else
v6 = a2;
v7 = v4 == 45;
while ( (unsigned int)(unsigned __int8)v6[v5] - 48 <= 9 )
{
if ( ++v5 >= 0x20000000 )
goto LABEL_11;
}
if ( (int)v5 > 0x1FFFFFFF )
{
LABEL_11:
v8 = nullptr;
LABEL_12:
if ( !*a1 )
sub_1006D0E38(v8);
return 0;
}
v3 = (unsigned int)(v5 + v7);
if ( !a1 )
return v3;
v8 = (_BYTE *)*a1;
if ( *a1 )
{
sub_1006D1290(*a1, 0);
}
else
{
v8 = sub_1006D0E9C();
if ( !v8 )
return 0;
}
v10 = 4 * v5;
if ( 4 * (int)v5 > 2147483584 )
goto LABEL_12;
v11 = v10 + 63;
v12 = v10 + 126;
if ( v11 >= 0 )
v12 = v11;
if ( v12 >> 6 > *((_DWORD *)v8 + 3) && !sub_1006D10FC((__int64)v8, v12 >> 6) )
goto LABEL_12;
v13 = *v6;
if ( *v6 )
{
v14 = 0;
if ( (int)v5 % 19 )
v15 = 19 - (int)v5 % 19;
else
v15 = 0;
v16 = v6 + 1;
do
{
v14 = 10 * v14 + v13 - 48;
if ( ++v15 == 19 )
{
sub_1006D4B70(v8);
sub_1006D49A4(v8, v14);
v14 = 0;
v15 = 0;
}
v17 = *v16++;
v13 = v17;
}
while ( v17 );
}
*((_DWORD *)v8 + 4) = v7;
v18 = *((_DWORD *)v8 + 2);
if ( v18 >= 1 )
{
v19 = (_QWORD *)(*(_QWORD *)v8 + 8LL * (v18 - 1));
do
{
if ( *v19 )
break;
--v19;
v20 = __OFSUB__(v18--, 1);
}
while ( !((v18 < 0) ^ v20 | (v18 == 0)) );
*((_DWORD *)v8 + 2) = v18;
}
*a1 = (__int64)v8;
}
return v3;
}