//
// MusicDownloadManager::handleIt from 0x836c88 to 0x836f2c (676 bytes)
//
// 3 xrefs:
// > MusicDownloadManager::onProcessHttpRequestCompleted @ 0x836fac
// > MusicDownloadManager::handleItND @ 0x8371c8
// > ??> @ 0x94aa0
//
// 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 MusicDownloadManager::handleIt(MusicDownloadManager *a1, char a2, __int64 a3, __int64 a4, int a5)
{
char *v6; // x0
char *v7; // x1
char *v8; // x0
char *v10; // x0
unsigned int *v11; // x1
int v12; // w2
unsigned int *v13; // x1
unsigned int *v14; // x1
int v15; // w2
unsigned int *v16; // x1
int v17; // w2
int v18; // [xsp+30h] [xbp+30h]
char *v19; // [xsp+48h] [xbp+48h] BYREF
const char *v20; // [xsp+50h] [xbp+50h] BYREF
if ( !a2 )
{
v18 = a5;
sub_D1798C(a3, "-1", 2);
a5 = v18;
}
if ( a5 != 19 )
{
if ( a5 != 59 )
return _stack_chk_guard;
sub_D18D28(&v19);
sub_D18D28(&v20);
MusicDownloadManager::onGetCustomContentURLCompleted(a1, (const void **)&v19);
v6 = (char *)(v20 - 24);
if ( v20 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v14 = (unsigned int *)(v20 - 8);
do
v15 = __ldaxr(v14);
while ( __stlxr(v15 - 1, v14) );
}
else
{
v15 = *((_DWORD *)v20 - 2);
*((_DWORD *)v20 - 2) = v15 - 1;
}
if ( v15 <= 0 )
operator delete(v6);
}
v7 = v19;
v8 = v19 - 24;
if ( v19 - 24 == (char *)&qword_124B6B0 )
return _stack_chk_guard;
if ( &pthread_create )
{
v13 = (unsigned int *)(v19 - 8);
do
v12 = __ldaxr(v13);
while ( __stlxr(v12 - 1, v13) );
goto LABEL_13;
}
goto LABEL_29;
}
sub_D18D28(&v19);
sub_D18D28(&v20);
MusicDownloadManager::onGetSongInfoCompleted(a1, (const void **)&v19, &v20);
v10 = (char *)(v20 - 24);
if ( v20 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)(v20 - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *((_DWORD *)v20 - 2);
*((_DWORD *)v20 - 2) = v17 - 1;
}
if ( v17 <= 0 )
operator delete(v10);
}
v7 = v19;
v8 = v19 - 24;
if ( v19 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v11 = (unsigned int *)(v19 - 8);
do
v12 = __ldaxr(v11);
while ( __stlxr(v12 - 1, v11) );
LABEL_13:
if ( v12 <= 0 )
operator delete(v8);
return _stack_chk_guard;
}
LABEL_29:
v12 = *((_DWORD *)v7 - 2);
*((_DWORD *)v7 - 2) = v12 - 1;
goto LABEL_13;
}
return _stack_chk_guard;
}