//
// GameManager::calculateBaseKeyForIcons from 0x100376bd0 to 0x100376d1d (333 bytes)
//
// 1 xrefs:
// > GameManager::init @ 0x100376b46
//
// 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::calculateBaseKeyForIcons(GameManager *a1)
{
std::__vector_base::pointer begin; // rax
unsigned __int64 v2; // rdx
int i; // r12d
std::__compressed_pair *>> *v4; // r13
std::__tree_end_node *>::pointer left; // rax
std::__compressed_pair *>> *p_pair1; // r15
int v7; // eax
std::__compressed_pair *>> *v8; // r14
std::__tree_end_node *> *v9; // rax
begin = a1->m_keyStartForIcon.__begin_;
v2 = a1->m_keyStartForIcon.__end_ - begin;
if ( v2 > 8 )
{
if ( (std::__vector_base::pointer)((char *)a1->m_keyStartForIcon.__end_ - (char *)begin) != (std::__vector_base::pointer)36 )
a1->m_keyStartForIcon.__end_ = begin + 9;
}
else
{
sub_100165950((void **)&a1->m_keyStartForIcon.__begin_, 9 - v2);
begin = a1->m_keyStartForIcon.__begin_;
}
*(_OWORD *)begin = xmmword_10081A090;
*((_OWORD *)begin + 1) = xmmword_10081A0A0;
begin[8] = 1197;
for ( i = 0; i != 1205; ++i )
{
left = a1->m_iconLoadCounts.__tree_.__pair1_.__value_.__left_;
p_pair1 = &a1->m_iconLoadCounts.__tree_.__pair1_;
v4 = &a1->m_iconLoadCounts.__tree_.__pair1_;
LABEL_10:
if ( left )
{
do
{
v4 = (std::__compressed_pair *>> *)left;
v7 = *((_DWORD *)left + 7);
if ( i < v7 )
{
left = v4->__value_.__left_;
p_pair1 = v4;
goto LABEL_10;
}
if ( i <= v7 )
goto LABEL_7;
left = v4[1].__value_.__left_;
}
while ( left );
p_pair1 = v4 + 1;
}
v8 = (std::__compressed_pair *>> *)operator new(0x28u);
HIDWORD(v8[3].__value_.__left_) = i;
LODWORD(v8[4].__value_.__left_) = 0;
*(_OWORD *)&v8->__value_.__left_ = 0;
v8[2].__value_.__left_ = (std::__tree_end_node *>::pointer)v4;
p_pair1->__value_.__left_ = (std::__tree_end_node *>::pointer)v8;
v9 = (std::__tree_end_node *> *)a1->m_iconLoadCounts.__tree_.__begin_node_->__left_;
if ( v9 )
a1->m_iconLoadCounts.__tree_.__begin_node_ = v9;
sub_100054DD0((__int64 *)a1->m_iconLoadCounts.__tree_.__pair1_.__value_.__left_, (__int64 *)v8);
++a1->m_iconLoadCounts.__tree_.__pair3_.__value_;
v4 = v8;
LABEL_7:
LODWORD(v4[4].__value_.__left_) = 0;
}
}