//
// GameManager::finishedLoadingIconAsync from 0x100381a80 to 0x100381e32 (946 bytes)
//
// 1 xrefs:
// > GameManager::loadIconAsync @ 0x10038132e
//
// 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
//
void __fastcall GameManager::finishedLoadingIconAsync(GameManager *a1, cocos2d::CCObject *a2)
{
int v2; // r14d
std::__vector_base::pointer begin; // rax
unsigned int v4; // ecx
int v5; // r15d
int v6; // edx
std::__tree_end_node *>::pointer left; // rax
std::__compressed_pair *>> *p_pair1; // rbx
std::__compressed_pair *>> *v9; // r13
int v10; // eax
std::__compressed_pair *>> *v11; // r15
std::__tree_end_node *> *v12; // rax
std::__compressed_pair *>> *v13; // r15
std::__compressed_pair *>> *v14; // r12
std::__tree_end_node *>::pointer v15; // rax
std::__compressed_pair *>> *v16; // rbx
std::__compressed_pair *>> *v17; // r12
int v18; // eax
char *v19; // r13
std::__tree_end_node *> *v20; // rax
__int64 v21; // rax
std::__compressed_pair *>> *v22; // rbx
int v23; // eax
char *v24; // r13
std::__tree_end_node *> *v25; // rax
char *v26; // r13
int v27; // edx
int v28; // eax
char *v29; // rbx
std::__tree_end_node *> *v30; // rax
int v31; // esi
unsigned __int64 i; // [rsp-48h] [rbp-48h]
IconType v33; // [rsp-38h] [rbp-38h]
int v34; // [rsp-34h] [rbp-34h]
if ( a2 )
{
v2 = ((__int64 (__fastcall *)(cocos2d::CCObject *))a2->getTag)(a2);
begin = a1->m_keyStartForIcon.__begin_;
v4 = 0;
if ( begin[1] > v2 )
goto LABEL_10;
v4 = 1;
if ( begin[2] > v2 )
goto LABEL_10;
v4 = 2;
if ( begin[3] > v2
|| (v4 = 3, begin[4] > v2)
|| (v4 = 4, begin[5] > v2)
|| (v4 = 5, begin[6] > v2)
|| (v4 = 6, begin[7] > v2)
|| (v5 = 0, v4 = 7, v6 = 0, begin[8] > v2) )
{
LABEL_10:
v5 = v2 - begin[v4] + 1;
v6 = v4;
}
v33 = v6;
GameManager::loadIcon(a1, v5, v6, -1);
left = a1->m_isIconBeingLoaded.__tree_.__pair1_.__value_.__left_;
v34 = v5;
if ( left )
{
while ( 1 )
{
while ( 1 )
{
v9 = (std::__compressed_pair *>> *)left;
v10 = *((_DWORD *)left + 7);
if ( v2 >= v10 )
break;
left = v9->__value_.__left_;
p_pair1 = v9;
if ( !v9->__value_.__left_ )
goto LABEL_18;
}
if ( v2 <= v10 )
break;
left = v9[1].__value_.__left_;
if ( !left )
{
p_pair1 = v9 + 1;
goto LABEL_18;
}
}
}
else
{
p_pair1 = &a1->m_isIconBeingLoaded.__tree_.__pair1_;
v9 = &a1->m_isIconBeingLoaded.__tree_.__pair1_;
LABEL_18:
v11 = v9;
v9 = (std::__compressed_pair *>> *)operator new(0x28u);
HIDWORD(v9[3].__value_.__left_) = v2;
LOBYTE(v9[4].__value_.__left_) = 0;
*(_OWORD *)&v9->__value_.__left_ = 0;
v9[2].__value_.__left_ = (std::__tree_end_node *>::pointer)v11;
p_pair1->__value_.__left_ = (std::__tree_end_node *>::pointer)v9;
v12 = (std::__tree_end_node *> *)a1->m_isIconBeingLoaded.__tree_.__begin_node_->__left_;
if ( v12 )
a1->m_isIconBeingLoaded.__tree_.__begin_node_ = v12;
sub_100054DD0((__int64 *)a1->m_isIconBeingLoaded.__tree_.__pair1_.__value_.__left_, (__int64 *)v9);
++a1->m_isIconBeingLoaded.__tree_.__pair3_.__value_;
}
LOBYTE(v9[4].__value_.__left_) = 0;
v13 = &a1->m_iconDelegates.__tree_.__pair1_;
for ( i = 0; ; ++i )
{
v15 = v13->__value_.__left_;
v16 = &a1->m_iconDelegates.__tree_.__pair1_;
v17 = &a1->m_iconDelegates.__tree_.__pair1_;
LABEL_26:
if ( v15 )
{
do
{
v17 = (std::__compressed_pair *>> *)v15;
v18 = *((_DWORD *)v15 + 8);
if ( v2 < v18 )
{
v15 = v17->__value_.__left_;
v16 = v17;
goto LABEL_26;
}
if ( v2 <= v18 )
goto LABEL_34;
v15 = v17[1].__value_.__left_;
}
while ( v15 );
v16 = v17 + 1;
}
v19 = (char *)operator new(0x40u);
*((_DWORD *)v19 + 8) = v2;
*(_OWORD *)(v19 + 40) = 0;
*((_QWORD *)v19 + 7) = 0;
*(_OWORD *)v19 = 0;
*((_QWORD *)v19 + 2) = v17;
v16->__value_.__left_ = (std::__tree_end_node *>::pointer)v19;
v20 = (std::__tree_end_node *> *)a1->m_iconDelegates.__tree_.__begin_node_->__left_;
if ( v20 )
a1->m_iconDelegates.__tree_.__begin_node_ = v20;
sub_100054DD0((__int64 *)a1->m_iconDelegates.__tree_.__pair1_.__value_.__left_, (__int64 *)v19);
++a1->m_iconDelegates.__tree_.__pair3_.__value_;
v17 = (std::__compressed_pair *>> *)v19;
LABEL_34:
v21 = (__int64)v13->__value_.__left_;
if ( (v17[6].__value_.__left_ - v17[5].__value_.__left_) >> 3 <= i )
break;
v22 = &a1->m_iconDelegates.__tree_.__pair1_;
v14 = &a1->m_iconDelegates.__tree_.__pair1_;
LABEL_37:
if ( v21 )
{
do
{
v14 = (std::__compressed_pair *>> *)v21;
v23 = *(_DWORD *)(v21 + 32);
if ( v2 < v23 )
{
v21 = (__int64)v14->__value_.__left_;
v22 = v14;
goto LABEL_37;
}
if ( v2 <= v23 )
goto LABEL_23;
v21 = (__int64)v14[1].__value_.__left_;
}
while ( v21 );
v22 = v14 + 1;
}
v24 = (char *)operator new(0x40u);
*((_DWORD *)v24 + 8) = v2;
*(_OWORD *)(v24 + 40) = 0;
*((_QWORD *)v24 + 7) = 0;
*(_OWORD *)v24 = 0;
*((_QWORD *)v24 + 2) = v14;
v22->__value_.__left_ = (std::__tree_end_node *>::pointer)v24;
v25 = (std::__tree_end_node *> *)a1->m_iconDelegates.__tree_.__begin_node_->__left_;
if ( v25 )
a1->m_iconDelegates.__tree_.__begin_node_ = v25;
sub_100054DD0((__int64 *)a1->m_iconDelegates.__tree_.__pair1_.__value_.__left_, (__int64 *)v24);
++a1->m_iconDelegates.__tree_.__pair3_.__value_;
v14 = (std::__compressed_pair *>> *)v24;
LABEL_23:
SimplePlayer::iconFinishedLoading(*((SimplePlayer **)v14[5].__value_.__left_ + i), v34, v33);
}
v26 = (char *)&a1->m_iconDelegates.__tree_.__pair1_;
v27 = v33;
if ( v21 )
{
while ( 1 )
{
while ( 1 )
{
v26 = (char *)v21;
v28 = *(_DWORD *)(v21 + 32);
if ( v2 >= v28 )
break;
v21 = *(_QWORD *)v26;
v13 = (std::__compressed_pair *>> *)v26;
if ( !*(_QWORD *)v26 )
goto LABEL_51;
}
if ( v2 <= v28 )
break;
v21 = *((_QWORD *)v26 + 1);
if ( !v21 )
{
v13 = (std::__compressed_pair *>> *)(v26 + 8);
goto LABEL_51;
}
}
v31 = v34;
}
else
{
LABEL_51:
v29 = v26;
v26 = (char *)operator new(0x40u);
*((_DWORD *)v26 + 8) = v2;
*(_OWORD *)(v26 + 40) = 0;
*((_QWORD *)v26 + 7) = 0;
*(_OWORD *)v26 = 0;
*((_QWORD *)v26 + 2) = v29;
v13->__value_.__left_ = (std::__tree_end_node *>::pointer)v26;
v30 = (std::__tree_end_node *> *)a1->m_iconDelegates.__tree_.__begin_node_->__left_;
if ( v30 )
a1->m_iconDelegates.__tree_.__begin_node_ = v30;
sub_100054DD0((__int64 *)a1->m_iconDelegates.__tree_.__pair1_.__value_.__left_, (__int64 *)v26);
++a1->m_iconDelegates.__tree_.__pair3_.__value_;
v31 = v34;
v27 = v33;
}
*((_QWORD *)v26 + 6) = *((_QWORD *)v26 + 5);
GameManager::unloadIcon(a1, v31, v27, -1);
}
}