//
// GameManager::unloadIcon from 0x100382530 to 0x100382b35 (1541 bytes)
//
// 3 xrefs:
// > GameManager::finishedLoadingIconAsync @ 0x100381e2d
// > GameManager::loadIcon @ 0x100382367
// > GameManager::unloadIcons @ 0x100382e4e
//
// 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
//
// local variable allocation has failed, the output may be wrong!
void __fastcall GameManager::unloadIcon(GameManager *a1, int a2, int a3, int a4)
{
double v4; // xmm0_8
GameManager *v6; // r8
std::__tree_end_node *>::pointer left; // rax
int v8; // ecx
int v9; // r12d
std::__compressed_pair *>> *p_pair1; // r15
std::__compressed_pair *>> *v11; // rbx
std::__compressed_pair *>> *v12; // r13
__int64 v13; // rcx
int v14; // ecx
std::__compressed_pair *>> *v15; // rax
GameManager *v16; // rcx
std::__tree_end_node *> *v17; // rax
std::__compressed_pair *>> *v18; // rbx
std::__compressed_pair *>> *v19; // r13
int v20; // eax
std::__compressed_pair *>> *v21; // rax
GameManager *v22; // rcx
std::__tree_end_node *> *v23; // rax
std::__compressed_pair *>> *v24; // rbx
std::__compressed_pair *>> *v25; // r13
__int64 v26; // rcx
int v27; // ecx
std::__compressed_pair *>> *v28; // rax
GameManager *v29; // rcx
std::__tree_end_node *> *v30; // rax
std::__compressed_pair *>> *v31; // r13
int v32; // eax
std::__compressed_pair *>> *v33; // rbx
std::__compressed_pair *>> *v34; // rax
GameManager *v35; // rcx
std::__tree_end_node *> *v36; // rax
signed int v37; // r15d
char v38; // r13
cocos2d::CCTextureCache *v39; // rax
const char *data; // rsi
std::__compressed_pair *>> *v41; // rbx
std::__tree_end_node *>::pointer v42; // rax
_QWORD *p_left; // r13
__int64 *v44; // r12
__int64 *v45; // r15
__int64 *v46; // rax
GameManager *v47; // rcx
std::__tree_end_node *> *v48; // rax
__int64 *v49; // rdi
__int64 *v50; // r13
__int64 v51; // rcx
__int64 *v52; // rcx
__int64 *v53; // rax
__int64 *v54; // rcx
bool v55; // zf
__int64 v56; // rax
__int64 *v57; // r12
__int64 *v58; // r15
__int64 *v59; // r13
__int64 *v60; // rax
GameManager *v61; // rcx
std::__tree_end_node *> *v62; // rax
__int64 *v63; // rdi
std::__compressed_pair *>> *v64; // r15
std::__tree_end_node *>::pointer v65; // rax
std::__tree_end_node *> *v66; // rcx
std::__tree_end_node *> *v67; // rax
std::__tree_end_node *> *p_value; // rcx
__int128 v69; // [rsp+0h] [rbp-80h] BYREF
void *__p; // [rsp+10h] [rbp-70h]
__int64 v71; // [rsp+18h] [rbp-68h]
std::string v72; // [rsp+20h] [rbp-60h] BYREF
std::__compressed_pair *>> *v73; // [rsp+40h] [rbp-40h]
int v74; // [rsp+4Ch] [rbp-34h]
GameManager *v75; // [rsp+50h] [rbp-30h]
if ( a2 > 0 )
{
v6 = a1;
v74 = a3;
left = a1->m_iconLoadCounts.__tree_.__pair1_.__value_.__left_;
v8 = a1->m_keyStartForIcon.__begin_[a3];
v71 = *(_QWORD *)&a2;
v9 = a2 + v8 - 1;
p_pair1 = &a1->m_iconLoadCounts.__tree_.__pair1_;
v11 = &a1->m_iconLoadCounts.__tree_.__pair1_;
v12 = &a1->m_iconLoadCounts.__tree_.__pair1_;
v75 = a1;
if ( left )
{
v13 = (__int64)left;
while ( 1 )
{
while ( 1 )
{
v12 = (std::__compressed_pair *>> *)v13;
v14 = *(_DWORD *)(v13 + 28);
if ( v9 >= v14 )
break;
v13 = (__int64)v12->__value_.__left_;
v11 = v12;
if ( !v12->__value_.__left_ )
goto LABEL_9;
}
if ( v9 <= v14 )
break;
v13 = (__int64)v12[1].__value_.__left_;
if ( !v13 )
{
v11 = v12 + 1;
goto LABEL_9;
}
}
}
else
{
LABEL_9:
v73 = v12;
v15 = (std::__compressed_pair *>> *)operator new(0x28u);
v16 = v75;
v12 = v15;
HIDWORD(v15[3].__value_.__left_) = v9;
LODWORD(v15[4].__value_.__left_) = 0;
v4 = 0.0;
*(_OWORD *)&v15->__value_.__left_ = 0;
v15[2].__value_.__left_ = (std::__tree_end_node *>::pointer)v73;
v11->__value_.__left_ = (std::__tree_end_node *>::pointer)v15;
v17 = (std::__tree_end_node *> *)v16->m_iconLoadCounts.__tree_.__begin_node_->__left_;
if ( v17 )
v16->m_iconLoadCounts.__tree_.__begin_node_ = v17;
*(_QWORD *)&a2 = v12;
sub_100054DD0((__int64 *)v16->m_iconLoadCounts.__tree_.__pair1_.__value_.__left_, (__int64 *)v12);
v6 = v75;
++v75->m_iconLoadCounts.__tree_.__pair3_.__value_;
left = v6->m_iconLoadCounts.__tree_.__pair1_.__value_.__left_;
}
--LODWORD(v12[4].__value_.__left_);
if ( (_DWORD)v71 == 1 )
{
v18 = &a1->m_iconLoadCounts.__tree_.__pair1_;
v19 = &a1->m_iconLoadCounts.__tree_.__pair1_;
LABEL_15:
if ( left )
{
do
{
v19 = (std::__compressed_pair *>> *)left;
v20 = *((_DWORD *)left + 7);
if ( v9 < v20 )
{
left = v19->__value_.__left_;
v18 = v19;
goto LABEL_15;
}
if ( v9 <= v20 )
goto LABEL_23;
left = v19[1].__value_.__left_;
}
while ( left );
v18 = v19 + 1;
}
v73 = v19;
v21 = (std::__compressed_pair *>> *)operator new(0x28u);
v22 = v75;
v19 = v21;
HIDWORD(v21[3].__value_.__left_) = v9;
LODWORD(v21[4].__value_.__left_) = 0;
v4 = 0.0;
*(_OWORD *)&v21->__value_.__left_ = 0;
v21[2].__value_.__left_ = (std::__tree_end_node *>::pointer)v73;
v18->__value_.__left_ = (std::__tree_end_node *>::pointer)v21;
v23 = (std::__tree_end_node *> *)v22->m_iconLoadCounts.__tree_.__begin_node_->__left_;
if ( v23 )
v22->m_iconLoadCounts.__tree_.__begin_node_ = v23;
*(_QWORD *)&a2 = v19;
sub_100054DD0((__int64 *)v22->m_iconLoadCounts.__tree_.__pair1_.__value_.__left_, (__int64 *)v19);
v6 = v75;
++v75->m_iconLoadCounts.__tree_.__pair3_.__value_;
LABEL_23:
left = p_pair1->__value_.__left_;
if ( SLODWORD(v19[4].__value_.__left_) <= 0 )
{
v24 = &a1->m_iconLoadCounts.__tree_.__pair1_;
v25 = &a1->m_iconLoadCounts.__tree_.__pair1_;
if ( left )
{
v26 = (__int64)p_pair1->__value_.__left_;
while ( 1 )
{
while ( 1 )
{
v25 = (std::__compressed_pair *>> *)v26;
v27 = *(_DWORD *)(v26 + 28);
if ( v9 >= v27 )
break;
v26 = (__int64)v25->__value_.__left_;
v24 = v25;
if ( !v25->__value_.__left_ )
goto LABEL_31;
}
if ( v9 <= v27 )
break;
v26 = (__int64)v25[1].__value_.__left_;
if ( !v26 )
{
v24 = v25 + 1;
goto LABEL_31;
}
}
}
else
{
LABEL_31:
v73 = v25;
v28 = (std::__compressed_pair *>> *)operator new(0x28u);
v29 = v75;
v25 = v28;
HIDWORD(v28[3].__value_.__left_) = v9;
LODWORD(v28[4].__value_.__left_) = 0;
v4 = 0.0;
*(_OWORD *)&v28->__value_.__left_ = 0;
v28[2].__value_.__left_ = (std::__tree_end_node *>::pointer)v73;
v24->__value_.__left_ = (std::__tree_end_node *>::pointer)v28;
v30 = (std::__tree_end_node *> *)v29->m_iconLoadCounts.__tree_.__begin_node_->__left_;
if ( v30 )
v29->m_iconLoadCounts.__tree_.__begin_node_ = v30;
*(_QWORD *)&a2 = v25;
sub_100054DD0((__int64 *)v29->m_iconLoadCounts.__tree_.__pair1_.__value_.__left_, (__int64 *)v25);
v6 = v75;
++v75->m_iconLoadCounts.__tree_.__pair3_.__value_;
left = v6->m_iconLoadCounts.__tree_.__pair1_.__value_.__left_;
}
LODWORD(v25[4].__value_.__left_) = 1;
}
}
v31 = &a1->m_iconLoadCounts.__tree_.__pair1_;
LABEL_37:
if ( left )
{
do
{
v31 = (std::__compressed_pair *>> *)left;
v32 = *((_DWORD *)left + 7);
if ( v9 < v32 )
{
left = v31->__value_.__left_;
p_pair1 = v31;
goto LABEL_37;
}
if ( v9 <= v32 )
goto LABEL_45;
left = v31[1].__value_.__left_;
}
while ( left );
p_pair1 = v31 + 1;
}
v33 = v31;
v34 = (std::__compressed_pair *>> *)operator new(0x28u);
v35 = v75;
v31 = v34;
HIDWORD(v34[3].__value_.__left_) = v9;
LODWORD(v34[4].__value_.__left_) = 0;
v4 = 0.0;
*(_OWORD *)&v34->__value_.__left_ = 0;
v34[2].__value_.__left_ = (std::__tree_end_node *>::pointer)v33;
p_pair1->__value_.__left_ = (std::__tree_end_node *>::pointer)v34;
v36 = (std::__tree_end_node *> *)v35->m_iconLoadCounts.__tree_.__begin_node_->__left_;
if ( v36 )
v35->m_iconLoadCounts.__tree_.__begin_node_ = v36;
*(_QWORD *)&a2 = v31;
sub_100054DD0((__int64 *)v35->m_iconLoadCounts.__tree_.__pair1_.__value_.__left_, (__int64 *)v31);
v6 = v75;
++v75->m_iconLoadCounts.__tree_.__pair3_.__value_;
LABEL_45:
v37 = v74;
if ( SLODWORD(v31[4].__value_.__left_) <= 0 )
{
GameManager::sheetNameForIcon((size_t *)&v69, *(__int64 *)&a2, v71, v74);
v38 = v69;
if ( (v69 & 1) != 0 )
{
sub_100006B70(&v72, __p, *((unsigned __int64 *)&v69 + 1), v4);
}
else
{
v72.__r_.__value_.__r.__words[2] = (std::string::size_type)__p;
*(_OWORD *)&v72.__r_.__value_.__l.0 = v69;
}
std::string::append(&v72, ".png");
v39 = cocos2d::CCTextureCache::sharedTextureCache();
if ( (*(_BYTE *)&v72.__r_.__value_.__s.0 & 1) != 0 )
data = v72.__r_.__value_.__l.__data_;
else
data = v72.__r_.__value_.__s.__data_;
cocos2d::CCTextureCache::removeTextureForKey(v39, data);
if ( (*(_BYTE *)&v72.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v72.__r_.__value_.__l.__data_);
if ( (v38 & 1) != 0 )
operator delete(__p);
v6 = v75;
}
v41 = &v6->m_iconRequests.__tree_.__pair1_;
v42 = v6->m_iconRequests.__tree_.__pair1_.__value_.__left_;
p_left = &v6->m_iconRequests.__tree_.__pair1_.__value_.__left_;
v44 = (__int64 *)&v6->m_iconRequests.__tree_.__pair1_;
LABEL_59:
if ( v42 )
{
do
{
v44 = (__int64 *)v42;
if ( *((_DWORD *)v42 + 8) > a4 )
{
v42 = *(std::__tree_end_node *>::pointer *)v42;
p_left = v44;
goto LABEL_59;
}
if ( *((_DWORD *)v42 + 8) >= a4 )
goto LABEL_67;
v42 = *((std::__tree_end_node *>::pointer *)v42 + 1);
}
while ( v42 );
p_left = v44 + 1;
}
v45 = v44;
v46 = (__int64 *)operator new(0x40u);
v47 = v75;
v44 = v46;
*((_DWORD *)v46 + 8) = a4;
*((_OWORD *)v46 + 3) = 0;
v46[5] = (__int64)(v46 + 6);
*(_OWORD *)v46 = 0;
v46[2] = (__int64)v45;
*p_left = v46;
v48 = (std::__tree_end_node *> *)v47->m_iconRequests.__tree_.__begin_node_->__left_;
if ( v48 )
v47->m_iconRequests.__tree_.__begin_node_ = v48;
sub_100054DD0((__int64 *)v47->m_iconRequests.__tree_.__pair1_.__value_.__left_, v44);
v6 = v75;
++v75->m_iconRequests.__tree_.__pair3_.__value_;
v37 = v74;
LABEL_67:
v49 = (__int64 *)v44[6];
if ( v49 )
{
v50 = v44 + 6;
v51 = v44[6];
do
{
if ( *(_DWORD *)(v51 + 28) >= v37 )
v50 = (__int64 *)v51;
v51 = *(_QWORD *)(v51 + 8LL * (*(_DWORD *)(v51 + 28) < v37));
}
while ( v51 );
if ( v50 != v44 + 6 && *((_DWORD *)v50 + 7) <= v37 )
{
v52 = (__int64 *)v50[1];
if ( v52 )
{
do
{
v53 = v52;
v52 = (__int64 *)*v52;
}
while ( v52 );
}
else
{
v54 = v50;
do
{
v53 = (__int64 *)v54[2];
v55 = *v53 == (_QWORD)v54;
v54 = v53;
}
while ( !v55 );
}
if ( (__int64 *)v44[5] == v50 )
v44[5] = (__int64)v53;
--v44[7];
sub_100165F60(v49, v50);
operator delete(v50);
v6 = v75;
}
}
v56 = (__int64)v41->__value_.__left_;
v57 = (__int64 *)v41;
v58 = (__int64 *)v41;
LABEL_84:
if ( v56 )
{
do
{
v58 = (__int64 *)v56;
if ( *(_DWORD *)(v56 + 32) > a4 )
{
v56 = *(_QWORD *)v56;
v57 = v58;
goto LABEL_84;
}
if ( *(_DWORD *)(v56 + 32) >= a4 )
goto LABEL_92;
v56 = *(_QWORD *)(v56 + 8);
}
while ( v56 );
v57 = v58 + 1;
}
v59 = v58;
v60 = (__int64 *)operator new(0x40u);
v61 = v75;
v58 = v60;
*((_DWORD *)v60 + 8) = a4;
*((_OWORD *)v60 + 3) = 0;
v60[5] = (__int64)(v60 + 6);
*(_OWORD *)v60 = 0;
v60[2] = (__int64)v59;
*v57 = (__int64)v60;
v62 = (std::__tree_end_node *> *)v61->m_iconRequests.__tree_.__begin_node_->__left_;
if ( v62 )
v61->m_iconRequests.__tree_.__begin_node_ = v62;
sub_100054DD0((__int64 *)v61->m_iconRequests.__tree_.__pair1_.__value_.__left_, v58);
v6 = v75;
++v75->m_iconRequests.__tree_.__pair3_.__value_;
LABEL_92:
if ( !v58[7] )
{
v63 = (__int64 *)v41->__value_.__left_;
if ( v41->__value_.__left_ )
{
v64 = v41;
v65 = v41->__value_.__left_;
do
{
if ( *((_DWORD *)v65 + 8) >= a4 )
v64 = (std::__compressed_pair *>> *)v65;
v65 = *((std::__tree_end_node *>::pointer *)v65 + (*((_DWORD *)v65 + 8) < a4));
}
while ( v65 );
if ( v64 != v41 && SLODWORD(v64[4].__value_.__left_) <= a4 )
{
v66 = (std::__tree_end_node *> *)v64[1].__value_.__left_;
if ( v66 )
{
do
{
v67 = v66;
v66 = (std::__tree_end_node *> *)v66->__left_;
}
while ( v66 );
}
else
{
p_value = &v64->__value_;
do
{
v67 = (std::__tree_end_node *> *)p_value[2].__left_;
v55 = v67->__left_ == (std::__tree_end_node *>::pointer)p_value;
p_value = v67;
}
while ( !v55 );
}
if ( (std::__compressed_pair *>> *)v6->m_iconRequests.__tree_.__begin_node_ == v64 )
v6->m_iconRequests.__tree_.__begin_node_ = v67;
--v6->m_iconRequests.__tree_.__pair3_.__value_;
sub_100165F60(v63, (__int64 *)v64);
sub_100054D90((__int64)&v64[5], (_QWORD *)v64[6].__value_.__left_);
operator delete(v64);
}
}
}
}
}