//
// sub_10047C660 from 0x10047c660 to 0x10047c854 (500 bytes)
//
// 3 xrefs:
// > EditorUI::updateEditColorButton @ 0x10047c028
// > sub_10047C854 @ 0x10047c8b8
// > sub_10047C974 @ 0x10047c9a0
//
// This function is hookable on this platform (idp: arm, 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:05:44 +0000
//
__int64 __fastcall sub_10047C660(__int64 a1, __int64 *a2, __int64 *a3, __int64 *a4)
{
__int64 result; // x0
int *v8; // x0
int v9; // w21
__int64 v10; // x8
unsigned int *v11; // x9
__int64 v12; // x8
__int64 *v13; // x24
unsigned __int64 v14; // x25
__int64 v15; // x22
__int64 v16; // x23
int *v17; // x0
int v18; // w8
int v19; // w10
bool v20; // w26
__int64 v21; // x8
__int64 v22; // x0
double v23; // d0
double v24; // d1
__int64 v25; // x0
double v26; // d0
double v27; // d1
result = *(_QWORD *)(a1 + 1496);
if ( !result )
{
result = sub_1002E757C(*(_QWORD *)(a1 + 896));
if ( !(_DWORD)result )
goto LABEL_47;
v10 = *(_QWORD *)(a1 + 896);
if ( !v10 )
goto LABEL_47;
v11 = *(unsigned int **)(v10 + 56);
v12 = *v11;
if ( !(_DWORD)v12 )
goto LABEL_47;
v13 = *((__int64 **)v11 + 2);
v14 = (unsigned __int64)&v13[v12 - 1];
v9 = -2;
v15 = 4294967294LL;
while ( 1 )
{
v16 = *v13;
if ( !*v13 )
goto LABEL_43;
result = sub_1002FEFE8(*v13);
if ( !(_DWORD)result )
goto LABEL_47;
if ( sub_1002FF01C(v16) )
{
v17 = (int *)sub_1002FEFD8(v16);
v18 = v17[1];
if ( *v17 )
v18 = *v17;
v19 = v9 == -2 ? v18 : v9;
v20 = v9 != v18 && v9 != -2;
v9 = v19;
}
else
{
v20 = 0;
}
result = sub_1002FF030(v16);
if ( !(_DWORD)result )
break;
result = sub_1002FEFE0(v16);
LODWORD(v21) = *(_DWORD *)(result + 4);
if ( *(_DWORD *)result )
v21 = *(unsigned int *)result;
else
v21 = (unsigned int)v21;
if ( (_DWORD)v15 == -2 )
goto LABEL_35;
if ( (_DWORD)v15 != (_DWORD)v21 || v20 )
goto LABEL_47;
LABEL_36:
if ( (unsigned __int64)++v13 > v14 )
goto LABEL_43;
}
v21 = v15;
LABEL_35:
v15 = v21;
if ( v20 )
goto LABEL_47;
goto LABEL_36;
}
if ( *(_DWORD *)(result + 1248) == 1 && ((*(_BYTE *)(result + 1254) & 1) != 0 || *(_DWORD *)(result + 1028) == 1006) )
{
*a4 = result;
goto LABEL_47;
}
if ( sub_1002FF01C(result) )
{
v8 = (int *)sub_1002FEFD8(*(_QWORD *)(a1 + 1496));
if ( *v8 )
v9 = *v8;
else
v9 = v8[1];
}
else
{
v9 = -1;
}
result = sub_1002FF030(*(_QWORD *)(a1 + 1496));
if ( (_DWORD)result )
{
result = sub_1002FEFE0(*(_QWORD *)(a1 + 1496));
if ( *(_DWORD *)result )
LODWORD(v15) = *(_DWORD *)result;
else
LODWORD(v15) = *(_DWORD *)(result + 4);
LABEL_43:
if ( v9 < 0 )
goto LABEL_45;
goto LABEL_44;
}
LODWORD(v15) = -1;
if ( (v9 & 0x80000000) == 0 )
{
LABEL_44:
v22 = GameManager::sharedState();
result = (__int64)sub_10000F52C(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(v22 + 552) + 3272LL) + 320LL), v9, v23, v24);
*a2 = result;
}
LABEL_45:
if ( (v15 & 0x80000000) == 0 )
{
v25 = GameManager::sharedState();
result = (__int64)sub_10000F52C(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(v25 + 552) + 3272LL) + 320LL), v15, v26, v27);
*a3 = result;
}
LABEL_47:
if ( !*a2 )
{
if ( *a3 )
{
*a2 = *a3;
*a3 = 0;
}
}
return result;
}