//
// MusicBrowser::setupMusicBrowser from 0x14047c380 to 0x14047c858 (1240 bytes)
//
// 2 xrefs:
// > MusicBrowser::trySetupMusicBrowser @ 0x14047c359
// > ??> @ 0x140928634
//
// This function is hookable on this platform (idp: pc, 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:32:43 +0000
//
// Hidden C++ exception states: #wind=10
__int64 __fastcall MusicBrowser::setupMusicBrowser(__int64 a1)
{
__int64 v2; // rcx
bool v3; // r13
int v4; // ebx
cocos2d::CCObject *v5; // rax
cocos2d::CCObject *v6; // rsi
void **v7; // r15
void **v8; // rdx
__int64 v9; // rax
unsigned int *v10; // rdi
__int64 v11; // rax
__int64 *v12; // rdi
__int64 *i; // r12
__int64 v14; // rbp
__int64 v15; // rbx
__int64 v16; // rax
unsigned int *v17; // rdi
__int64 v18; // rax
__int64 *v19; // rdi
__int64 *j; // r12
__int64 v21; // rbp
__int64 v22; // rbx
int v23; // ebx
__int64 v24; // rcx
_QWORD *SongIDs; // rax
__int64 v26; // rdx
int v27; // eax
int v28; // edx
int v29; // ecx
__int64 *v30; // rdi
__int64 v31; // rbx
__int64 v32; // rdx
__int64 v33; // rcx
cocos2d::CCSpriteFrameCache *v34; // rax
struct cocos2d::CCSpriteFrame *v35; // rax
__int64 v36; // rdx
__int64 v37; // rdx
__int64 v38; // rdx
size_t v39; // r8
__int64 v40; // rdx
__int64 result; // rax
__int64 v42; // rcx
bool v43; // [rsp+20h] [rbp-68h] BYREF
void *v44; // [rsp+28h] [rbp-60h]
__int128 v45; // [rsp+30h] [rbp-58h] BYREF
__int64 v46; // [rsp+40h] [rbp-48h]
__int64 v47; // [rsp+48h] [rbp-40h]
v2 = qword_14090C070;
if ( !qword_14090C070 )
{
v44 = operator new(0x3D0u);
qword_14090C070 = MusicDownloadManager::MusicDownloadManager(v44);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090C070 + 72LL))(qword_14090C070);
v2 = qword_14090C070;
}
if ( !*(_QWORD *)(v2 + 384) )
((void (*)(void))MusicDownloadManager::getCustomContentURL)();
v3 = !*(_QWORD *)(a1 + 712) && byte_1409097A6 && dword_1408FE358 == *(_DWORD *)(a1 + 704);
v4 = *(_DWORD *)(a1 + 704);
v44 = operator new(0xB0u);
v5 = (cocos2d::CCObject *)MusicSearchResult::MusicSearchResult(v44);
v6 = v5;
if ( v5 )
{
*((_DWORD *)v5 + 36) = v4;
cocos2d::CCObject::autorelease(v5);
}
v7 = &qword_1408FE500;
if ( v3 )
{
if ( (void **)((char *)v6 + 104) != &qword_1408FE500 )
{
v8 = &qword_1408FE500;
if ( (unsigned __int64)qword_1408FE518 > 0xF )
v8 = (void **)qword_1408FE500;
sub_1400405A0((void **)v6 + 13, v8, qword_1408FE510);
}
*((_BYTE *)v6 + 142) = byte_1409097A7;
MusicSearchResult::createTagFilterObjects(v6);
MusicSearchResult::createArtistFilterObjects(v6);
v9 = *((_QWORD *)v6 + 9);
if ( v9 )
{
v10 = *(unsigned int **)(v9 + 56);
v11 = *v10;
if ( (_DWORD)v11 )
{
v12 = *((__int64 **)v10 + 2);
for ( i = &v12[v11 - 1]; v12 <= i; ++v12 )
{
v14 = *v12;
if ( !*v12 )
break;
v15 = qword_14090B318;
if ( sub_140677130(qword_14090B310, qword_14090B318, *(unsigned int *)(v14 + 56)) != v15 )
*(_BYTE *)(v14 + 60) = 1;
}
}
}
v16 = *((_QWORD *)v6 + 10);
if ( v16 )
{
v17 = *(unsigned int **)(v16 + 56);
v18 = *v17;
if ( (_DWORD)v18 )
{
v19 = *((__int64 **)v17 + 2);
for ( j = &v19[v18 - 1]; v19 <= j; ++v19 )
{
v21 = *v19;
if ( !*v19 )
break;
v22 = qword_14090B300;
if ( sub_140677130(qword_14090B2F8, qword_14090B300, *(unsigned int *)(v21 + 56)) != v22 )
*(_BYTE *)(v21 + 60) = 1;
}
}
}
v23 = dword_1409097A8;
v24 = qword_14090BFD0;
if ( dword_1409097A8 == 3 )
{
if ( !qword_14090BFD0 )
{
v44 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v44);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v24 = qword_14090BFD0;
}
if ( !*(_QWORD *)(v24 + 568) )
{
*((_DWORD *)v6 + 37) = 0;
goto LABEL_43;
}
}
*((_DWORD *)v6 + 37) = v23;
if ( v23 == 3 )
{
v43 = 0;
if ( !v24 )
{
v44 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v44);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v24 = qword_14090BFD0;
}
SongIDs = LevelEditorLayer::getSongIDs(*(_QWORD *)(v24 + 568), &v45, &v43);
MusicDownloadManager::splitIDString(SongIDs, (char *)v6 + 152);
sub_14003D310((__int64)&v45);
goto LABEL_43;
}
}
v26 = 0;
if ( *(_DWORD *)(a1 + 704) == 1 )
v26 = 6;
if ( !v3 )
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v6 + 72LL))(v6, v26);
goto LABEL_57;
}
LABEL_43:
(*(void (__fastcall **)(cocos2d::CCObject *, _QWORD))(*(_QWORD *)v6 + 72LL))(v6, (unsigned int)dword_1409097AC);
v27 = cocos2d::CCArray::count(*((cocos2d::CCArray **)v6 + 8));
if ( v27 <= 0 )
v28 = 0;
else
v28 = (v27 - 1) / 10;
v29 = 0;
if ( dword_1409097B0 >= 0 )
v29 = dword_1409097B0;
if ( v29 > v28 )
v29 = v28;
*((_DWORD *)v6 + 24) = v29;
if ( qword_1408FE510 )
{
*(_BYTE *)(a1 + 800) = 1;
v30 = (__int64 *)(*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 768) + 952LL))(*(_QWORD *)(a1 + 768));
v31 = *v30;
v34 = (cocos2d::CCSpriteFrameCache *)cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache(v33, v32);
v35 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v34, "gj_findBtnOff_001.png");
(*(void (__fastcall **)(__int64 *, struct cocos2d::CCSpriteFrame *))(v31 + 1008))(v30, v35);
LOBYTE(v36) = 1;
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 784) + 336LL))(*(_QWORD *)(a1 + 784), v36);
LOBYTE(v37) = 1;
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 776) + 336LL))(*(_QWORD *)(a1 + 776), v37);
LOBYTE(v38) = 1;
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 776) + 920LL))(*(_QWORD *)(a1 + 776), v38);
if ( (unsigned __int64)qword_1408FE518 > 0xF )
v7 = (void **)qword_1408FE500;
v45 = 0;
v46 = 0;
v47 = 0;
v39 = -1;
do
++v39;
while ( *((_BYTE *)v7 + v39) );
sub_14003D230(&v45, v7, v39);
CCTextInputNode::setString(*(_QWORD **)(a1 + 776), &v45);
LOBYTE(v40) = 1;
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 792) + 336LL))(*(_QWORD *)(a1 + 792), v40);
MusicBrowser::setupSongControls(a1);
}
LABEL_57:
result = MusicBrowser::setupList(a1, v6);
v42 = qword_14090C070;
if ( !qword_14090C070 )
{
v44 = operator new(0x3D0u);
qword_14090C070 = MusicDownloadManager::MusicDownloadManager(v44);
result = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)qword_14090C070 + 72LL))(qword_14090C070);
v42 = qword_14090C070;
}
if ( !*(_BYTE *)(v42 + 516) )
{
*(_BYTE *)(a1 + 912) = 1;
if ( *(_QWORD *)(v42 + 384) )
{
*(_BYTE *)(a1 + 872) = 0;
return MusicDownloadManager::tryUpdateMusicLibrary(v42);
}
else
{
*(_BYTE *)(a1 + 872) = 1;
return MusicDownloadManager::getCustomContentURL(v42);
}
}
return result;
}