//
// sub_14018C300 from 0x14018c300 to 0x14018c453 (339 bytes)
//
// 6 xrefs:
// > EditorSFXManager::playAction @ 0x1401858c4
// > SecretLayer5::init @ 0x140589973
// > SecretLayer5::onSubmit @ 0x14058c988
// > ??> @ 0x14089ee5c
// > ??> @ 0x14089ee9c
// > ??> @ 0x140918fbc
//
// 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:27:41 +0000
//
__int64 __fastcall sub_14018C300(_DWORD *a1, _DWORD *a2, unsigned int *a3)
{
__int64 result; // rax
unsigned __int64 i; // rsi
unsigned __int64 v7; // r13
char v8; // r11
unsigned __int64 v9; // r12
unsigned __int64 v10; // rbp
unsigned __int64 j; // rdi
__int64 v12; // rbp
__int64 k; // rax
_DWORD *v14; // r8
unsigned __int64 v15; // rdx
int v16; // ecx
_DWORD *v17; // [rsp+60h] [rbp+8h]
char v19; // [rsp+70h] [rbp+18h]
result = 64;
for ( i = -1; i > 0xFFFFFFFF; i >>= 1 )
--result;
v19 = result;
if ( a1 != a2 )
{
result = (__int64)(a1 + 1);
v17 = a1 + 1;
v7 = 1;
if ( a1 + 1 != a2 )
{
do
{
v8 = v19;
v9 = v7 + 1;
do
{
v10 = 0;
for ( j = 0; j < v7; j = i | (2 * (j << (v8 - 1))) )
{
v12 = 2 * (v10 << (v8 - 1));
for ( k = (unsigned int)sub_1400768C0(a3); (unsigned int)k > i; k = (unsigned int)sub_1400768C0(a3) )
;
v10 = k | v12;
}
}
while ( v10 / v9 >= j / v9 && j % v9 != v7 );
v14 = v17;
result = v10 / v9;
v15 = v10 % v9;
if ( v10 % v9 != v7 )
{
v16 = *v17;
result = (unsigned int)a1[v15];
*v17 = result;
a1[v15] = v16;
}
++v7;
++v17;
}
while ( v14 + 1 != a2 );
}
}
return result;
}