//
// ColorSelectPopup::colorToHex from 0x7400d0 to 0x74046c (924 bytes)
//
// 3 xrefs:
// > ColorSelectPopup::updateColorLabels @ 0x74058c
// > SetupPulsePopup::updateColorLabels @ 0x8ed260
// > ??> @ 0x2f3d0
//
// 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
//
_QWORD *__usercall ColorSelectPopup::colorToHex@(int a1@, _QWORD *a2@)
{
__int64 v3; // x1
int i; // w25
int v5; // w26
int v6; // w20
__int64 v7; // x1
unsigned int v8; // w23
char *v9; // x0
unsigned int *v10; // x1
int v11; // w2
void *v13; // x0
unsigned int *v14; // x1
int v15; // w2
unsigned int *v16; // x1
int v17; // w2
char *v19; // [xsp+90h] [xbp+90h] BYREF
__int64 v20; // [xsp+98h] [xbp+98h] BYREF
__int64 v21; // [xsp+A0h] [xbp+A0h] BYREF
_BYTE v22[16]; // [xsp+A8h] [xbp+A8h] BYREF
__int64 v23; // [xsp+B8h] [xbp+B8h]
v3 = _stack_chk_guard;
*a2 = &byte_124B6C8;
qmemcpy(v22, "0123456789ABCDEF", sizeof(v22));
v23 = v3;
for ( i = 0; i != 3; ++i )
{
if ( !i )
{
v5 = BYTE2(a1);
LABEL_5:
if ( !v5 )
goto LABEL_19;
goto LABEL_6;
}
if ( i == 1 )
{
v5 = BYTE1(a1);
goto LABEL_5;
}
v5 = (unsigned __int8)a1;
if ( !(_BYTE)a1 )
{
LABEL_19:
sub_583094("00", a2, &v21);
sub_D163D4(a2, &v21);
v13 = (void *)(v21 - 24);
if ( (__int64 *)(v21 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v14 = (unsigned int *)(v21 - 8);
do
v15 = __ldaxr(v14);
while ( __stlxr(v15 - 1, v14) );
}
else
{
v15 = *(_DWORD *)(v21 - 8);
*(_DWORD *)(v21 - 8) = v15 - 1;
}
if ( v15 <= 0 )
goto LABEL_24;
}
continue;
}
LABEL_6:
v6 = v5;
do
{
while ( 1 )
{
v7 = *(_QWORD *)(*a2 - 24LL);
v19 = &byte_124B6C8;
v8 = (unsigned __int8)v22[v6 & 0xF];
sub_D15888(&v19, v7 + 1);
sub_D1603C(&v19, 1, v8);
sub_D15E14(&v19, a2);
sub_D163D4(a2, &v19);
v9 = v19 - 24;
if ( v19 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v10 = (unsigned int *)(v19 - 8);
do
v11 = __ldaxr(v10);
while ( __stlxr(v11 - 1, v10) );
}
else
{
v11 = *((_DWORD *)v19 - 2);
*((_DWORD *)v19 - 2) = v11 - 1;
}
if ( v11 <= 0 )
break;
}
v6 >>= 4;
if ( !v6 )
goto LABEL_14;
}
v6 >>= 4;
operator delete(v9);
}
while ( v6 );
LABEL_14:
if ( v5 <= 15 )
{
sub_583094("0", a2, &v20);
sub_D163D4(a2, &v20);
v13 = (void *)(v20 - 24);
if ( (__int64 *)(v20 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)(v20 - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *(_DWORD *)(v20 - 8);
*(_DWORD *)(v20 - 8) = v17 - 1;
}
if ( v17 <= 0 )
{
LABEL_24:
operator delete(v13);
continue;
}
}
}
}
return a2;
}