//
// sub_BBFA4 from 0xbbfa4 to 0xbc172 (462 bytes)
//
// 3 xrefs:
// > sub_BC194 @ 0xbc450
// > sub_BCC7C @ 0xbccf6
// > sub_BD050 @ 0xbd0b0
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:41:46 +0000
//
int __fastcall sub_BBFA4(int a1, int a2, int a3, int a4, int a5, int a6, __int16 *a7, int a8, int a9, _BYTE *a10)
{
int v13; // r6
int v14; // r8
_BYTE *i; // r4
int v16; // r0
int v17; // r6
int v18; // r5
_BYTE *v19; // r0
int j; // r4
int v21; // r0
bool v22; // zf
unsigned __int8 *v23; // r5
int v24; // r0
bool v25; // zf
__int16 v26; // r0
int k; // r5
char v28; // r1
int v29; // r0
int result; // r0
unsigned __int8 *m; // r0
unsigned int v32; // r3
int v33; // r4
int v34; // [sp+4h] [bp-1824h]
char nptr[2048]; // [sp+8h] [bp-1820h] BYREF
_BYTE v36[4100]; // [sp+808h] [bp-1020h] BYREF
if ( a10 )
*a10 = 0;
v13 = 7;
if ( sub_BE30E("http://", a2, 7) )
{
v13 = 7;
if ( sub_BE30E("http:\\\\", a2, 7) )
{
v13 = 8;
if ( sub_BE30E("https://", a2, 8) )
{
v13 = 8;
if ( sub_BE30E("https:\\\\", a2, 8) )
{
if ( sub_BE30E("mms://", a2, 6) && sub_BE30E("mms:\\\\", a2, 6) )
return 31;
if ( a10 )
*a10 = 1;
v13 = 6;
}
}
}
}
v14 = a2 + v13;
for ( i = (_BYTE *)(a2 + v13); ; ++i )
{
v16 = (unsigned __int8)*i;
if ( !*i || v16 == 47 )
{
v17 = a8;
v18 = 0;
goto LABEL_19;
}
if ( v16 == 64 )
break;
}
v17 = a8;
sub_BE220(v36, v14, 4096);
v19 = &i[-v14];
v14 = (int)(i + 1);
v36[(_DWORD)v19] = 0;
v18 = 1;
LABEL_19:
for ( j = v14 + 1; ; ++j )
{
v21 = *(unsigned __int8 *)(j - 1);
if ( !*(_BYTE *)(j - 1) )
break;
v22 = v21 == 47;
if ( v21 != 47 )
v22 = v21 == 58;
if ( v22 )
break;
}
if ( sub_BE198(v14) >= a4 )
return 31;
v34 = v18;
v23 = (unsigned __int8 *)(j - 1);
sub_BE220(a3, v14, a4);
*(_BYTE *)(a3 + j - 1 - v14) = 0;
v24 = *(unsigned __int8 *)(j - 1);
v25 = v24 == 47;
if ( v24 != 47 )
v25 = v24 == 0;
if ( v25 )
{
v26 = 80;
}
else
{
for ( k = 0; k != 2048; ++k )
{
v28 = *(_BYTE *)(j + k);
if ( (unsigned __int8)(v28 - 48) > 9u )
break;
nptr[k] = v28;
}
nptr[k] = 0;
v26 = atoi(nptr);
v23 = (unsigned __int8 *)(k + j);
}
*a7 = v26;
v29 = *v23;
if ( ((unsigned int)(v29 - 9) > 0x17 || ((1 << (v29 - 9)) & 0x800003) == 0) && *v23 )
{
if ( sub_BE198(v23) < a9 )
{
for ( m = &v23[sub_BE198(v23) - 1]; m > v23; --m )
{
v32 = *m - 9;
if ( v32 > 0x17 || ((1 << v32) & 0x800003) == 0 )
break;
}
v33 = m - v23;
sub_BE220(v17, v23, m - v23 + 2);
*(_BYTE *)(v33 + v17 + 1) = 0;
goto LABEL_39;
}
return 31;
}
sub_BE220(v17, "/", a9);
LABEL_39:
if ( v34 ^ 1 | (a5 == 0) )
return 0;
result = sub_BDDBC(v36, a5, a6);
if ( !result )
return 0;
return result;
}