//
// sub_1004AAF50 from 0x1004aaf50 to 0x1004ab2b8 (872 bytes)
//
// 3 xrefs:
// > sub_1004AB2B8 @ 0x1004ab69c
// > sub_1004AC008 @ 0x1004ac0b8
// > sub_1004AC5C8 @ 0x1004ac660
//
// 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_1004AAF50(
__int64 a1,
__int64 a2,
__int64 a3,
__int64 a4,
__int64 a5,
__int64 a6,
_WORD *a7,
__int64 a8,
int a9,
_BYTE *a10)
{
__int64 v17; // x27
__int64 v18; // x28
_BYTE *v19; // x26
int v20; // w8
int v21; // w27
__int64 i; // x28
unsigned int v23; // w10
bool v24; // cc
__int64 v25; // x10
int v27; // w0
int v28; // w8
unsigned __int8 *v30; // x23
__int64 v31; // x8
int v32; // w10
unsigned int v33; // w8
__int64 v34; // x8
__int64 result; // x0
unsigned __int8 *v37; // x8
unsigned int v38; // w11
__int64 v39; // x11
signed __int64 v41; // x22
char v42[2048]; // [xsp+0h] [xbp-1860h] BYREF
_BYTE v43[4096]; // [xsp+800h] [xbp-1060h] BYREF
if ( a10 )
*a10 = 0;
v17 = 7;
if ( (unsigned int)sub_1004C705C("http://", a2, 7) )
{
v17 = 7;
if ( (unsigned int)sub_1004C705C("http:\\\\", a2, 7) )
{
v17 = 8;
if ( (unsigned int)sub_1004C705C("https://", a2, 8) )
{
v17 = 8;
if ( (unsigned int)sub_1004C705C("https:\\\\", a2, 8) )
{
if ( (unsigned int)sub_1004C705C("mms://", a2, 6) && (unsigned int)sub_1004C705C("mms:\\\\", a2, 6) )
return 31;
if ( a10 )
*a10 = 1;
v17 = 6;
}
}
}
}
v18 = 0;
v19 = (_BYTE *)(a2 + v17);
v20 = (unsigned __int8)*v19;
if ( *v19 )
{
while ( v20 != 47 )
{
if ( v20 == 64 )
{
sub_1004C6BD0(v43, v19, 4096);
v43[v18] = 0;
v19 += v18 + 1;
v21 = 1;
goto LABEL_18;
}
v20 = (unsigned __int8)v19[++v18];
if ( !v19[v18] )
break;
}
}
v21 = 0;
LABEL_18:
for ( i = 0; ; ++i )
{
v23 = (unsigned __int8)v19[i];
v24 = v23 > 0x3A;
v25 = (1LL << v23) & 0x400800000000001LL;
if ( !v24 && v25 != 0 )
break;
}
v27 = sub_1004C6AA0(v19);
if ( v27 >= (int)a4 )
return 31;
sub_1004C6BD0(a3, v19, a4);
*(_BYTE *)(a3 + i) = 0;
v28 = (unsigned __int8)v19[i];
if ( v28 == 47 || v28 == 0 )
{
v30 = &v19[i];
*a7 = 80;
}
else
{
v31 = 0;
while ( 1 )
{
v32 = (unsigned __int8)v19[v31 + 1 + i];
if ( (unsigned int)(v32 - 48) > 9 )
break;
v42[v31++] = v32;
if ( v31 == 2048 )
{
v30 = &v19[i + 2049];
LODWORD(v31) = 2048;
goto LABEL_36;
}
}
v30 = &v19[i + 1 + v31];
LABEL_36:
v42[(unsigned int)v31] = 0;
*a7 = atoi(v42);
}
v33 = *v30;
v24 = v33 > 0x20;
v34 = (1LL << v33) & 0x100000601LL;
if ( v24 || v34 == 0 )
{
if ( (int)sub_1004C6AA0(v30) < a9 )
{
v37 = &v30[(int)sub_1004C6AA0(v30) - 1];
if ( v37 > v30 )
{
while ( 1 )
{
v38 = *v37;
v24 = v38 > 0x20;
v39 = (1LL << v38) & 0x100000600LL;
if ( v24 || v39 == 0 )
break;
if ( --v37 <= v30 )
{
v37 = v30;
break;
}
}
}
v41 = v37 - v30;
sub_1004C6BD0(a8, v30, (unsigned int)((_DWORD)v37 - (_DWORD)v30 + 2));
*(_BYTE *)(v41 + a8 + 1) = 0;
goto LABEL_42;
}
return 31;
}
sub_1004C6BD0(a8, "/", (unsigned int)a9);
LABEL_42:
if ( (a5 == 0) | (v21 ^ 1) & 1 )
return 0;
result = sub_1004B3D58(v43, a5, a6);
if ( !(_DWORD)result )
return 0;
return result;
}