//
// sub_18004B6A0 from 0x18004b6a0 to 0x18004b873 (467 bytes)
//
// 2 xrefs:
// > sub_18004B460 @ 0x18004b513
// > ??> @ 0x1801f8544
//
// 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
//
__int64 __fastcall sub_18004B6A0(int a1, int a2, int a3, int a4, int a5, __int64 a6)
{
int v7; // ebx
int v8; // r14d
__int64 v9; // r15
int v10; // r8d
signed int v11; // r12d
unsigned int v12; // edi
__int64 v13; // rcx
__int64 result; // rax
__int64 v15; // rdx
unsigned __int64 v16; // rsi
int v17; // r8d
__int64 v18; // r11
__int64 v19; // r11
int v20; // r8d
__int64 v21; // rcx
__int64 v22; // r11
int v23; // r8d
__int64 v24; // rcx
__int64 v25; // r11
__int64 v26; // rcx
v7 = a3 - a2;
v8 = a3;
v9 = (a5 - a4) / (a3 - a2);
v10 = 0;
v11 = v9 + (((a5 - a4) >> 31) & 0xFFFFFFFE) + 1;
v12 = abs32(a5 - a4) - abs32(v7 * ((a5 - a4) / v7));
v13 = a4;
if ( a1 <= v8 )
v8 = a1;
if ( a2 < v8 )
*(float *)(a6 + 4LL * a2) = *(float *)&dword_180166580[a4] * *(float *)(a6 + 4LL * a2);
result = (unsigned int)(a2 + 1);
v15 = (int)result;
if ( (int)result < (__int64)v8 )
{
if ( v8 - (__int64)(int)result < 4 )
goto LABEL_28;
result = a6 + 8 + 4LL * (int)result;
v16 = ((unsigned __int64)(v8 - v15 - 4) >> 2) + 1;
v15 += 4 * v16;
do
{
v17 = v12 + v10;
if ( v17 < v7 )
{
v18 = v9;
}
else
{
v17 -= v7;
v18 = v11;
}
v19 = v13 + v18;
v20 = v12 + v17;
*(float *)(result - 8) = *(float *)&dword_180166580[v19] * *(float *)(result - 8);
if ( v20 < v7 )
{
v21 = v9;
}
else
{
v20 -= v7;
v21 = v11;
}
v22 = v21 + v19;
v23 = v12 + v20;
*(float *)(result - 4) = *(float *)&dword_180166580[v22] * *(float *)(result - 4);
if ( v23 < v7 )
{
v24 = v9;
}
else
{
v23 -= v7;
v24 = v11;
}
v25 = v24 + v22;
v10 = v12 + v23;
*(float *)result = *(float *)&dword_180166580[v25] * *(float *)result;
if ( v10 < v7 )
{
v26 = v9;
}
else
{
v10 -= v7;
v26 = v11;
}
v13 = v25 + v26;
*(float *)(result + 4) = *(float *)&dword_180166580[v13] * *(float *)(result + 4);
result += 16;
--v16;
}
while ( v16 );
if ( v15 < v8 )
{
LABEL_28:
do
{
v10 += v12;
if ( v10 < v7 )
{
result = v9;
}
else
{
v10 -= v7;
result = v11;
}
v13 += result;
*(float *)(a6 + 4 * v15) = *(float *)&dword_180166580[v13] * *(float *)(a6 + 4 * v15);
++v15;
}
while ( v15 < v8 );
}
}
return result;
}