//
// MusicDownloadManager::generateCustomContentURL from 0x82adf8 to 0x82baa8 (3248 bytes)
//
// 7 xrefs:
// > MusicDownloadManager::downloadCustomSong @ 0x82bbac
// > MusicDownloadManager::tryUpdateMusicLibrary @ 0x82bfcc
// > MusicDownloadManager::downloadMusicLibrary @ 0x82c374
// > MusicDownloadManager::downloadSFX @ 0x82c758
// > MusicDownloadManager::tryUpdateSFXLibrary @ 0x82cb78
// > MusicDownloadManager::downloadSFXLibrary @ 0x82cf20
// > ??> @ 0x9ce70
//
// 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 __usercall MusicDownloadManager::generateCustomContentURL@(
__int64 a1@,
_QWORD *a2@,
__int64 a3@)
{
int v4; // w0
cocos2d::CCString *v5; // x0
const char *CString; // x23
char *v7; // x0
char *v8; // x0
void *v9; // x0
unsigned int v10; // w0
unsigned __int64 v11; // x21
unsigned __int64 v12; // x26
unsigned int v13; // w25
__int64 v14; // x1
int v15; // w2
size_t v16; // x2
__int64 v17; // x25
unsigned int v18; // w23
unsigned __int64 v19; // x0
unsigned int v20; // w21
char *v21; // x1
unsigned __int64 v22; // x23
__int64 v23; // x23
__int64 v24; // x21
size_t v25; // x2
char *v26; // x1
unsigned __int8 *v27; // x21
char *v28; // x26
int v29; // w1
int v30; // w0
int v31; // t1
char *v32; // x0
void *v33; // x0
char *v34; // x0
void *v35; // x0
char *v36; // x0
void *v37; // x0
char *v38; // x0
void *v39; // x0
char *v40; // x0
cocos2d::CCString *v41; // x0
char *v42; // x0
void *v43; // x0
void *v44; // x0
void *v45; // x0
unsigned __int8 *v47; // x2
unsigned __int8 *v48; // x2
__int64 v49; // x5
__int64 v50; // x5
__int64 v51; // x5
__int64 v52; // x5
unsigned __int8 *v53; // x2
const char *v54; // x28
__int64 v55; // x26
const char *v56; // x1
unsigned int *v57; // x1
int v58; // w2
unsigned int *v59; // x1
int v60; // w2
unsigned int *v61; // x1
int v62; // w2
unsigned int *v63; // x1
int v64; // w2
unsigned int *v65; // x1
int v66; // w2
unsigned int *v67; // x1
int v68; // w2
unsigned int *v69; // x1
int v70; // w2
unsigned int *v71; // x1
int v72; // w2
unsigned int *v73; // x1
int v74; // w2
unsigned int *v75; // x1
int v76; // w2
unsigned int *v77; // x1
int v78; // w2
unsigned int *v79; // x1
int v80; // w2
unsigned int *v81; // x1
int v82; // w2
unsigned int *v83; // x1
int v84; // w2
__int64 v88; // [xsp+98h] [xbp+98h] BYREF
__int64 v89; // [xsp+A0h] [xbp+A0h] BYREF
std::string v90; // [xsp+A8h] [xbp+A8h] BYREF
const char *v91; // [xsp+B0h] [xbp+B0h]
__int64 v92; // [xsp+B8h] [xbp+B8h] BYREF
__int64 v93; // [xsp+C0h] [xbp+C0h] BYREF
_DWORD *v94; // [xsp+C8h] [xbp+C8h] BYREF
__int64 v95; // [xsp+D0h] [xbp+D0h] BYREF
_DWORD *v96; // [xsp+D8h] [xbp+D8h] BYREF
__int64 v97; // [xsp+E0h] [xbp+E0h] BYREF
_DWORD *v98; // [xsp+E8h] [xbp+E8h] BYREF
__int64 v99; // [xsp+F0h] [xbp+F0h] BYREF
_DWORD *v100; // [xsp+F8h] [xbp+F8h] BYREF
__int64 v101; // [xsp+100h] [xbp+100h] BYREF
__int64 v102; // [xsp+108h] [xbp+108h] BYREF
__int64 v103; // [xsp+110h] [xbp+110h]
__int64 v104; // [xsp+118h] [xbp+118h]
__int64 v105; // [xsp+120h] [xbp+120h]
unsigned __int64 v106; // [xsp+128h] [xbp+128h]
unsigned __int64 v107; // [xsp+130h] [xbp+130h]
__int64 v108; // [xsp+138h] [xbp+138h] BYREF
__int64 v109; // [xsp+140h] [xbp+140h]
__int64 v110; // [xsp+148h] [xbp+148h]
__int64 v111; // [xsp+150h] [xbp+150h]
__int64 v112; // [xsp+158h] [xbp+158h]
__int64 v113; // [xsp+160h] [xbp+160h]
__int64 v114; // [xsp+168h] [xbp+168h]
__int64 v115; // [xsp+170h] [xbp+170h]
_DWORD v116[4]; // [xsp+178h] [xbp+178h] BYREF
char v117[32]; // [xsp+188h] [xbp+188h] BYREF
__int64 v118; // [xsp+1A8h] [xbp+1A8h] BYREF
__int16 v119; // [xsp+1B0h] [xbp+1B0h] BYREF
char v120; // [xsp+1B2h] [xbp+1B2h]
char v121; // [xsp+1B3h] [xbp+1B3h]
__int16 v122; // [xsp+1B4h] [xbp+1B4h]
char v123; // [xsp+1B6h] [xbp+1B6h]
char v124; // [xsp+1B7h] [xbp+1B7h]
std::string v125; // 0:x2.8
v4 = sub_D0BBC8();
GameToolbox::intToString(&v88, (GameToolbox *)(unsigned int)(v4 / 1000000000 + 3600));
v107 = 0;
v106 = 0;
v102 = 1732584193;
v103 = 4023233417LL;
v104 = 2562383102LL;
v105 = 271733878;
sub_D153B8((int)&v89, "DQIHAV8MVAUdDgBVVh0NBwQHHQEEDw8dDAQHBAdaAVNWAQkH");
GameToolbox::intToString((__int64 *)&v90, (GameToolbox *)&elf_hash_bucket[14301] + 1);
cocos2d::ZipUtils::base64DecodeEnc((cocos2d::ZipUtils *)&v89, &v90, v125);
v5 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%s%s%s", v91, *a2, v88);
CString = cocos2d::CCString::getCString(v5);
v7 = (char *)(v91 - 24);
if ( v91 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v81 = (unsigned int *)(v91 - 8);
do
v82 = __ldaxr(v81);
while ( __stlxr(v82 - 1, v81) );
}
else
{
v82 = *((_DWORD *)v91 - 2);
*((_DWORD *)v91 - 2) = v82 - 1;
}
if ( v82 <= 0 )
operator delete(v7);
}
v8 = (char *)v90.m_data.m_data - 24;
if ( (__int64 *)v90.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v83 = (unsigned int *)((char *)v90.m_data.m_data - 8);
do
v84 = __ldaxr(v83);
while ( __stlxr(v84 - 1, v83) );
}
else
{
v84 = *((_DWORD *)v90.m_data.m_data - 2);
*((_DWORD *)v90.m_data.m_data - 2) = v84 - 1;
}
if ( v84 <= 0 )
operator delete(v8);
}
v9 = (void *)(v89 - 24);
if ( (__int64 *)(v89 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v57 = (unsigned int *)(v89 - 8);
do
v58 = __ldaxr(v57);
while ( __stlxr(v58 - 1, v57) );
}
else
{
v58 = *(_DWORD *)(v89 - 8);
*(_DWORD *)(v89 - 8) = v58 - 1;
}
if ( v58 <= 0 )
operator delete(v9);
}
v107 = 0;
v106 = 0;
v102 = 1732584193;
v103 = 4023233417LL;
v104 = 2562383102LL;
v105 = 271733878;
v10 = strlen(CString);
v11 = 8LL * v10;
v12 = (unsigned __int64)v10 >> 29;
v106 = v11;
v13 = v10;
v107 = v12;
if ( v10 > 0x3F )
{
v49 = *((_QWORD *)CString + 1);
v108 = *(_QWORD *)CString;
v109 = v49;
v50 = *((_QWORD *)CString + 3);
v110 = *((_QWORD *)CString + 2);
v111 = v50;
v51 = *((_QWORD *)CString + 5);
v112 = *((_QWORD *)CString + 4);
v113 = v51;
v52 = *((_QWORD *)CString + 7);
v114 = *((_QWORD *)CString + 6);
v115 = v52;
MD5::MD5Transform((MD5 *)&v102, (const char *)&v108, (unsigned __int8 *)&v108);
if ( v13 <= 0x7F )
{
v14 = 64;
v11 = v106;
v12 = v107;
v15 = 64;
}
else
{
v54 = CString + 64;
v55 = (v13 - 128) >> 6;
do
{
v56 = v54;
v54 += 64;
MD5::MD5Transform((MD5 *)&v102, v56, v53);
}
while ( v54 != &CString[64 * v55 + 128] );
v11 = v106;
v14 = (unsigned int)(((_DWORD)v55 + 2) << 6);
v12 = v107;
v15 = v14;
}
}
else
{
v14 = 0;
v15 = 0;
}
v16 = v13 - v15;
v17 = (v11 >> 3) & 0x3F;
memcpy(&v108, &CString[v14], v16);
v119 = v11;
v120 = BYTE2(v11);
v121 = BYTE3(v11);
v122 = v12;
v123 = BYTE2(v12);
v124 = BYTE3(v12);
if ( (unsigned int)v17 > 0x37 )
v18 = 120 - v17;
else
v18 = 56 - v17;
v19 = 8LL * v18;
v106 = v19 + v11;
if ( v19 > v19 + v11 )
v107 = v12 + 1;
v20 = 64 - v17;
if ( v18 >= 64 - (int)v17 )
{
memcpy((char *)&v102 + (unsigned int)v17 + 48, &unk_122F020, v20);
MD5::MD5Transform((MD5 *)&v102, (const char *)&v108, v48);
v21 = (char *)&unk_122F020 + v20;
LODWORD(v17) = 0;
}
else
{
v20 = 0;
v21 = (char *)&unk_122F020;
}
memcpy((char *)&v102 + (unsigned int)v17 + 48, v21, v18 - v20);
v22 = v106;
v106 += 64LL;
v23 = (v22 >> 3) & 0x3F;
if ( v106 <= 0x3F )
++v107;
v24 = (unsigned int)(64 - v23);
if ( (unsigned int)v24 <= 8 )
{
memcpy((char *)&v102 + (unsigned int)v23 + 48, &v119, (unsigned int)(64 - v23));
MD5::MD5Transform((MD5 *)&v102, (const char *)&v108, v47);
v25 = (unsigned int)(v23 - 56);
v26 = (char *)&v119 + v24;
LODWORD(v23) = 0;
}
else
{
v25 = 8;
v26 = (char *)&v119;
}
v27 = (unsigned __int8 *)v116;
v28 = v117;
memcpy((char *)&v102 + (unsigned int)v23 + 48, v26, v25);
v116[0] = v102;
v29 = v104;
v30 = v105;
v104 = 0;
v105 = 0;
v106 = 0;
v107 = 0;
v108 = 0;
v109 = 0;
v116[1] = v103;
v110 = 0;
v111 = 0;
v112 = 0;
v113 = 0;
v114 = 0;
v115 = 0;
v102 = 0;
v103 = 0;
v116[2] = v29;
v116[3] = v30;
do
{
v31 = *v27++;
v32 = v28;
v28 += 2;
sprintf(v32, "%02x", v31);
}
while ( v28 != (char *)&v118 );
sub_D153B8((int)&v92, v117);
base64_encode((const unsigned __int8 *)v116, 16, &v93);
sub_D153B8((int)&v94, "=");
sub_D153B8((int)&v95, &byte_F288A0);
sub_8265A8((__int64)&v93, (void **)&v94, &v95);
v33 = (void *)(v95 - 24);
if ( (__int64 *)(v95 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v59 = (unsigned int *)(v95 - 8);
do
v60 = __ldaxr(v59);
while ( __stlxr(v60 - 1, v59) );
}
else
{
v60 = *(_DWORD *)(v95 - 8);
*(_DWORD *)(v95 - 8) = v60 - 1;
}
if ( v60 <= 0 )
operator delete(v33);
}
v34 = (char *)(v94 - 6);
if ( v94 - 6 != (_DWORD *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v61 = v94 - 2;
do
v62 = __ldaxr(v61);
while ( __stlxr(v62 - 1, v61) );
}
else
{
v62 = *(v94 - 2);
*(v94 - 2) = v62 - 1;
}
if ( v62 <= 0 )
operator delete(v34);
}
sub_D153B8((int)&v96, &byte_F1AB78);
sub_D153B8((int)&v97, &byte_F288A0);
sub_8265A8((__int64)&v93, (void **)&v96, &v97);
v35 = (void *)(v97 - 24);
if ( (__int64 *)(v97 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v63 = (unsigned int *)(v97 - 8);
do
v64 = __ldaxr(v63);
while ( __stlxr(v64 - 1, v63) );
}
else
{
v64 = *(_DWORD *)(v97 - 8);
*(_DWORD *)(v97 - 8) = v64 - 1;
}
if ( v64 <= 0 )
operator delete(v35);
}
v36 = (char *)(v96 - 6);
if ( v96 - 6 != (_DWORD *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v65 = v96 - 2;
do
v66 = __ldaxr(v65);
while ( __stlxr(v66 - 1, v65) );
}
else
{
v66 = *(v96 - 2);
*(v96 - 2) = v66 - 1;
}
if ( v66 <= 0 )
operator delete(v36);
}
sub_D153B8((int)&v98, "+");
sub_D153B8((int)&v99, &byte_F10E40);
sub_8265A8((__int64)&v93, (void **)&v98, &v99);
v37 = (void *)(v99 - 24);
if ( (__int64 *)(v99 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v67 = (unsigned int *)(v99 - 8);
do
v68 = __ldaxr(v67);
while ( __stlxr(v68 - 1, v67) );
}
else
{
v68 = *(_DWORD *)(v99 - 8);
*(_DWORD *)(v99 - 8) = v68 - 1;
}
if ( v68 <= 0 )
operator delete(v37);
}
v38 = (char *)(v98 - 6);
if ( v98 - 6 != (_DWORD *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v69 = v98 - 2;
do
v70 = __ldaxr(v69);
while ( __stlxr(v70 - 1, v69) );
}
else
{
v70 = *(v98 - 2);
*(v98 - 2) = v70 - 1;
}
if ( v70 <= 0 )
operator delete(v38);
}
sub_D153B8((int)&v100, (char *)&word_F2A0A8);
sub_D153B8((int)&v101, "_");
sub_8265A8((__int64)&v93, (void **)&v100, &v101);
v39 = (void *)(v101 - 24);
if ( (__int64 *)(v101 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v71 = (unsigned int *)(v101 - 8);
do
v72 = __ldaxr(v71);
while ( __stlxr(v72 - 1, v71) );
}
else
{
v72 = *(_DWORD *)(v101 - 8);
*(_DWORD *)(v101 - 8) = v72 - 1;
}
if ( v72 <= 0 )
operator delete(v39);
}
v40 = (char *)(v100 - 6);
if ( v100 - 6 != (_DWORD *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v73 = v100 - 2;
do
v74 = __ldaxr(v73);
while ( __stlxr(v74 - 1, v73) );
}
else
{
v74 = *(v100 - 2);
*(v100 - 2) = v74 - 1;
}
if ( v74 <= 0 )
operator delete(v40);
}
v41 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%s%s?token=%s&expires=%s",
*(const char **)(a1 + 368),
*a2,
v93,
v88);
v42 = (char *)cocos2d::CCString::getCString(v41);
sub_D153B8(a3, v42);
v43 = (void *)(v93 - 24);
if ( (__int64 *)(v93 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v75 = (unsigned int *)(v93 - 8);
do
v76 = __ldaxr(v75);
while ( __stlxr(v76 - 1, v75) );
}
else
{
v76 = *(_DWORD *)(v93 - 8);
*(_DWORD *)(v93 - 8) = v76 - 1;
}
if ( v76 <= 0 )
operator delete(v43);
}
v44 = (void *)(v92 - 24);
if ( (__int64 *)(v92 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v77 = (unsigned int *)(v92 - 8);
do
v78 = __ldaxr(v77);
while ( __stlxr(v78 - 1, v77) );
}
else
{
v78 = *(_DWORD *)(v92 - 8);
*(_DWORD *)(v92 - 8) = v78 - 1;
}
if ( v78 <= 0 )
operator delete(v44);
}
v45 = (void *)(v88 - 24);
if ( (__int64 *)(v88 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v79 = (unsigned int *)(v88 - 8);
do
v80 = __ldaxr(v79);
while ( __stlxr(v80 - 1, v79) );
}
else
{
v80 = *(_DWORD *)(v88 - 8);
*(_DWORD *)(v88 - 8) = v80 - 1;
}
if ( v80 <= 0 )
operator delete(v45);
}
return a3;
}