//
// sub_140100470 from 0x140100470 to 0x140100559 (233 bytes)
//
// 9 xrefs:
// > ThreadViewPopup::sortMessagesByID @ 0x1400daa83
// > sub_140100560 @ 0x14010058d
// > sub_140100690 @ 0x1401006fd
// > sub_140100690 @ 0x140100711
// > sub_140100690 @ 0x14010088a
// > OptionsScrollLayer::init @ 0x14047e64d
// > ??> @ 0x1408953dc
// > ??> @ 0x140895418
// > ??> @ 0x1409156f8
//
// 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 11:26:42 +0000
//
char *__fastcall sub_140100470(char *Src, char *a2, unsigned __int8 (__fastcall *a3)(__int64, __int64))
{
char *v6; // r13
char *i; // rdi
__int64 v8; // rsi
char *v9; // r14
char *v10; // rbx
__int64 v11; // rdx
if ( Src == a2 )
return a2;
v6 = Src + 8;
for ( i = Src + 8; i != a2; i += 8 )
{
v8 = *(_QWORD *)i;
v9 = i;
if ( a3(*(_QWORD *)i, *(_QWORD *)Src) )
{
memmove(v6, Src, i - Src);
*(_QWORD *)Src = v8;
}
else
{
v10 = i - 8;
if ( a3(v8, *((_QWORD *)i - 1)) )
{
do
{
*(_QWORD *)v9 = *(_QWORD *)v10;
v9 = v10;
v11 = *((_QWORD *)v10 - 1);
v10 -= 8;
}
while ( a3(v8, v11) );
}
*(_QWORD *)v9 = v8;
}
}
return a2;
}