//
// PlayerObject::enablePlayerControls from 0x10041a840 to 0x10041aa5d (541 bytes)
//
// 6 xrefs:
// > GJBaseGameLayer::processOptionsTrigger @ 0x10013cd64
// > GJBaseGameLayer::processOptionsTrigger @ 0x10013ce43
// > GJBaseGameLayer::toggleLockPlayer @ 0x10013cf05
// > GJBaseGameLayer::toggleLockPlayer @ 0x10013cf1f
// > GJBaseGameLayer::loadUpToPosition @ 0x10014e9a1
// > GJBaseGameLayer::loadUpToPosition @ 0x10014e9ad
//
// 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 PlayerObject::enablePlayerControls(PlayerObject *a1)
{
std::__compressed_pair *>> *p_pair1; // r15
std::__tree_end_node *>::pointer left; // rax
std::__compressed_pair *>> *v3; // r12
std::__compressed_pair *>> *v4; // r14
int v5; // eax
std::__compressed_pair *>> *v6; // r13
std::__tree_end_node *> *v7; // rax
PlayerButton v8; // esi
__int64 v9; // rax
std::__compressed_pair *>> *v10; // r12
__int64 *v11; // r14
int v12; // eax
__int64 *v13; // r13
std::__tree_end_node *> *v14; // rax
__int64 v15; // rax
__int64 *v16; // r14
int v17; // eax
__int64 *v18; // r12
std::__tree_end_node *> *v19; // rax
a1->m_controlsDisabled = 0;
p_pair1 = &a1->m_holdingButtons.__tree_.__pair1_;
left = a1->m_holdingButtons.__tree_.__pair1_.__value_.__left_;
v3 = &a1->m_holdingButtons.__tree_.__pair1_;
v4 = &a1->m_holdingButtons.__tree_.__pair1_;
LABEL_3:
if ( left )
{
do
{
v4 = (std::__compressed_pair *>> *)left;
v5 = *((_DWORD *)left + 7);
if ( v5 >= 3 )
{
left = v4->__value_.__left_;
v3 = v4;
goto LABEL_3;
}
if ( v5 == 2 )
goto LABEL_11;
left = v4[1].__value_.__left_;
}
while ( left );
v3 = v4 + 1;
}
v6 = v4;
v4 = (std::__compressed_pair *>> *)operator new(0x28u);
HIDWORD(v4[3].__value_.__left_) = 2;
LOBYTE(v4[4].__value_.__left_) = 0;
*(_OWORD *)&v4->__value_.__left_ = 0;
v4[2].__value_.__left_ = (std::__tree_end_node *>::pointer)v6;
v3->__value_.__left_ = (std::__tree_end_node *>::pointer)v4;
v7 = (std::__tree_end_node *> *)a1->m_holdingButtons.__tree_.__begin_node_->__left_;
if ( v7 )
a1->m_holdingButtons.__tree_.__begin_node_ = v7;
sub_100054DD0((__int64 *)a1->m_holdingButtons.__tree_.__pair1_.__value_.__left_, (__int64 *)v4);
++a1->m_holdingButtons.__tree_.__pair3_.__value_;
LABEL_11:
v8 = 2;
if ( LOBYTE(v4[4].__value_.__left_) )
goto LABEL_23;
v9 = (__int64)p_pair1->__value_.__left_;
v10 = &a1->m_holdingButtons.__tree_.__pair1_;
v11 = (__int64 *)&a1->m_holdingButtons.__tree_.__pair1_;
LABEL_14:
if ( v9 )
{
do
{
v11 = (__int64 *)v9;
v12 = *(_DWORD *)(v9 + 28);
if ( v12 >= 4 )
{
v9 = *v11;
v10 = (std::__compressed_pair *>> *)v11;
goto LABEL_14;
}
if ( v12 == 3 )
goto LABEL_22;
v9 = v11[1];
}
while ( v9 );
v10 = (std::__compressed_pair *>> *)(v11 + 1);
}
v13 = v11;
v11 = (__int64 *)operator new(0x28u);
*((_DWORD *)v11 + 7) = 3;
*((_BYTE *)v11 + 32) = 0;
*(_OWORD *)v11 = 0;
v11[2] = (__int64)v13;
v10->__value_.__left_ = (std::__tree_end_node *>::pointer)v11;
v14 = (std::__tree_end_node *> *)a1->m_holdingButtons.__tree_.__begin_node_->__left_;
if ( v14 )
a1->m_holdingButtons.__tree_.__begin_node_ = v14;
sub_100054DD0((__int64 *)a1->m_holdingButtons.__tree_.__pair1_.__value_.__left_, v11);
++a1->m_holdingButtons.__tree_.__pair3_.__value_;
LABEL_22:
v8 = 3;
if ( *((_BYTE *)v11 + 32) == 1 )
LABEL_23:
PlayerObject::switchedDirTo(a1, v8);
v15 = (__int64)p_pair1->__value_.__left_;
v16 = (__int64 *)&a1->m_holdingButtons.__tree_.__pair1_;
LABEL_26:
if ( v15 )
{
do
{
v16 = (__int64 *)v15;
v17 = *(_DWORD *)(v15 + 28);
if ( v17 >= 2 )
{
v15 = *v16;
p_pair1 = (std::__compressed_pair *>> *)v16;
goto LABEL_26;
}
if ( v17 == 1 )
goto LABEL_34;
v15 = v16[1];
}
while ( v15 );
p_pair1 = (std::__compressed_pair *>> *)(v16 + 1);
}
v18 = v16;
v16 = (__int64 *)operator new(0x28u);
*((_DWORD *)v16 + 7) = 1;
*((_BYTE *)v16 + 32) = 0;
*(_OWORD *)v16 = 0;
v16[2] = (__int64)v18;
p_pair1->__value_.__left_ = (std::__tree_end_node *>::pointer)v16;
v19 = (std::__tree_end_node *> *)a1->m_holdingButtons.__tree_.__begin_node_->__left_;
if ( v19 )
a1->m_holdingButtons.__tree_.__begin_node_ = v19;
sub_100054DD0((__int64 *)a1->m_holdingButtons.__tree_.__pair1_.__value_.__left_, v16);
++a1->m_holdingButtons.__tree_.__pair3_.__value_;
LABEL_34:
if ( *((_BYTE *)v16 + 32) == 1 )
PlayerObject::pushButton(a1, Jump);
}