//
// sub_100519720 from 0x100519720 to 0x1005198c4 (420 bytes)
//
// 2 xrefs:
// > sub_100518264 @ 0x100519130
// > sub_100518264 @ 0x100519140
//
// 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:07:08 +0000
//
void __fastcall sub_100519720(__int64 a1, signed int a2)
{
__int64 v3; // x8
__int64 v4; // x21
__int64 v5; // x8
__int64 *v6; // x21
__int64 v7; // x25
__int64 v8; // x23
__int64 v9; // x24
__int64 v10; // x26
__int64 v11; // x20
__int128 v12; // q0
char v13; // w0
char v14; // w20
__int64 v15; // x20
__int128 v16; // q0
void *v17[2]; // [xsp+0h] [xbp-80h] BYREF
__int64 v18; // [xsp+10h] [xbp-70h]
void *__p[2]; // [xsp+20h] [xbp-60h] BYREF
__int64 v20; // [xsp+30h] [xbp-50h]
if ( (a2 & 0x80000000) == 0 )
{
v3 = *(_QWORD *)(a1 + 680);
if ( (int)(-858993459 * ((unsigned __int64)(*(_QWORD *)(a1 + 688) - v3) >> 4)) > a2 )
{
v4 = v3 + 80LL * (unsigned int)a2;
v7 = *(_QWORD *)(v4 + 56);
v5 = *(_QWORD *)(v4 + 64);
v6 = (__int64 *)(v4 + 56);
if ( (int)(-1431655765 * ((unsigned __int64)(v5 - v7) >> 5)) >= 1 )
{
v8 = 0;
v9 = 0;
do
{
if ( *(_DWORD *)(v7 + v8) == 1 )
{
v10 = v7 + v8;
if ( (*(char *)(v7 + v8 + 55) & 0x8000000000000000LL) != 0 )
{
if ( !*(_QWORD *)(v10 + 40) )
goto LABEL_23;
}
else if ( !*(_BYTE *)(v7 + v8 + 55) )
{
goto LABEL_23;
}
if ( !sub_1000D9098(a1 + 792, (const void **)(v10 + 32)) )
{
v11 = MusicDownloadManager::sharedState();
if ( *(char *)(v10 + 55) < 0 )
{
sub_1000097D0(__p, *(void **)(v10 + 32), *(_QWORD *)(v7 + v8 + 40));
}
else
{
v12 = *(_OWORD *)(v10 + 32);
v20 = *(_QWORD *)(v10 + 48);
*(_OWORD *)__p = v12;
}
v13 = sub_1001E1488(v11, (__int64)__p);
v14 = v13;
if ( SHIBYTE(v20) < 0 )
{
operator delete(__p[0]);
if ( (v14 & 1) == 0 )
{
LABEL_18:
v15 = MusicDownloadManager::sharedState();
if ( *(char *)(v10 + 55) < 0 )
{
sub_1000097D0(v17, *(void **)(v10 + 32), *(_QWORD *)(v7 + v8 + 40));
}
else
{
v16 = *(_OWORD *)(v10 + 32);
v18 = *(_QWORD *)(v10 + 48);
*(_OWORD *)v17 = v16;
}
sub_1001E159C(v15, (__int128 *)v17);
if ( SHIBYTE(v18) < 0 )
operator delete(v17[0]);
}
}
else if ( (v13 & 1) == 0 )
{
goto LABEL_18;
}
}
}
LABEL_23:
++v9;
v7 = *v6;
v8 += 96;
}
while ( v9 < (int)(-1431655765 * ((unsigned __int64)(v6[1] - *v6) >> 5)) );
}
}
}
}