//
// sub_1008D16E0 from 0x1008d16e0 to 0x1008d1952 (626 bytes)
//
// 2 xrefs:
// > sub_1008CDF10 @ 0x1008cec9a
// > sub_1008CDF10 @ 0x1008cefd8
//
// This function is hookable on this platform (idp: pc, 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 12:37:37 +0000
//
void __fastcall sub_1008D16E0(__int64 a1, unsigned int a2)
{
unsigned int v2; // edx
unsigned int v3; // r14d
unsigned int v4; // esi
std::string *v5; // rax
std::string::pointer data; // rdi
std::string *v7; // rax
const std::string::value_type *v8; // rsi
std::string::size_type v9; // rdx
std::string *v10; // rax
const std::string::value_type *v11; // rsi
std::string::size_type v12; // rdx
std::string *v13; // rax
std::string *v14; // rax
std::string *v15; // rax
std::string v16; // [rsp+8h] [rbp-88h] BYREF
std::string v17; // [rsp+20h] [rbp-70h] BYREF
size_t v18; // [rsp+38h] [rbp-58h] BYREF
std::string::size_type v19; // [rsp+40h] [rbp-50h]
void *__p; // [rsp+48h] [rbp-48h]
std::string v21; // [rsp+50h] [rbp-40h] BYREF
if ( (int)a2 <= 0 )
{
*(_BYTE *)a1 = 4;
strcpy((char *)(a1 + 1), "0s");
return;
}
v2 = a2 % 0xE10;
v3 = (2185 * (a2 % 0xE10)) >> 17;
if ( a2 >= 0xE10 )
{
GameToolbox::intToString((size_t *)&v16, a2 / 0xE10);
v7 = std::string::append(&v16, "h ");
v17 = *v7;
*(_OWORD *)&v7->__r_.__value_.__l.0 = 0;
v7->__r_.__value_.__r.__words[2] = 0;
GameToolbox::intToString(&v18, v3);
if ( (v18 & 1) != 0 )
{
v8 = (const std::string::value_type *)__p;
v9 = v19;
}
else
{
v9 = (unsigned __int8)v18 >> 1;
v8 = (char *)&v18 + 1;
}
v13 = std::string::append(&v17, v8, v9);
v21 = *v13;
*(_OWORD *)&v13->__r_.__value_.__l.0 = 0;
v13->__r_.__value_.__r.__words[2] = 0;
v14 = std::string::append(&v21, "m");
}
else
{
v4 = a2 % 0x3C;
if ( v2 < 0x3C )
{
GameToolbox::intToString((size_t *)&v21, v4);
v5 = std::string::append(&v21, "s");
*(std::string *)a1 = *v5;
*(_OWORD *)&v5->__r_.__value_.__l.0 = 0;
v5->__r_.__value_.__r.__words[2] = 0;
if ( (*(_BYTE *)&v21.__r_.__value_.__s.0 & 1) == 0 )
return;
data = v21.__r_.__value_.__l.__data_;
goto LABEL_24;
}
GameToolbox::intToString((size_t *)&v16, v3);
v10 = std::string::append(&v16, "m ");
v17 = *v10;
*(_OWORD *)&v10->__r_.__value_.__l.0 = 0;
v10->__r_.__value_.__r.__words[2] = 0;
GameToolbox::intToString(&v18, v4);
if ( (v18 & 1) != 0 )
{
v11 = (const std::string::value_type *)__p;
v12 = v19;
}
else
{
v12 = (unsigned __int8)v18 >> 1;
v11 = (char *)&v18 + 1;
}
v15 = std::string::append(&v17, v11, v12);
v21 = *v15;
*(_OWORD *)&v15->__r_.__value_.__l.0 = 0;
v15->__r_.__value_.__r.__words[2] = 0;
v14 = std::string::append(&v21, "s");
}
*(_QWORD *)(a1 + 16) = v14->__r_.__value_.__l.__data_;
*(_OWORD *)a1 = *(_OWORD *)&v14->__r_.__value_.__l.0;
*(_OWORD *)&v14->__r_.__value_.__l.0 = 0;
v14->__r_.__value_.__r.__words[2] = 0;
if ( (*(_BYTE *)&v21.__r_.__value_.__s.0 & 1) != 0 )
{
operator delete(v21.__r_.__value_.__l.__data_);
if ( (v18 & 1) == 0 )
{
LABEL_17:
if ( (*(_BYTE *)&v17.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_18;
LABEL_22:
operator delete(v17.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&v16.__r_.__value_.__s.0 & 1) == 0 )
return;
goto LABEL_23;
}
}
else if ( (v18 & 1) == 0 )
{
goto LABEL_17;
}
operator delete(__p);
if ( (*(_BYTE *)&v17.__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_22;
LABEL_18:
if ( (*(_BYTE *)&v16.__r_.__value_.__s.0 & 1) == 0 )
return;
LABEL_23:
data = v16.__r_.__value_.__l.__data_;
LABEL_24:
operator delete(data);
}