//
// sub_1006535B0 from 0x1006535b0 to 0x1006536d8 (296 bytes)
//
// 13 xrefs:
// > sub_100647420 @ 0x1006477c8
// > sub_1006536E0 @ 0x100653a1c
// > sub_100653AF0 @ 0x100653e6c
// > sub_100653FC0 @ 0x100654419
// > sub_100654470 @ 0x1006547ac
// > sub_1006547E0 @ 0x100654bd9
// > sub_100654CB0 @ 0x100655159
// > sub_100655220 @ 0x10065561c
// > sub_100655740 @ 0x100655a89
// > sub_100655B60 @ 0x100655e2c
// > sub_100655F20 @ 0x1006561dc
// > sub_1006562A0 @ 0x1006565ec
// > sub_1006566C0 @ 0x1006569dc
//
// 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
//
unsigned __int8 *__fastcall sub_1006535B0(
unsigned __int8 *a1,
unsigned __int64 a2,
unsigned __int8 *a3,
char *a4,
double a5,
__m128d a6)
{
unsigned __int64 v6; // rax
__m128d *v7; // rcx
unsigned __int64 v8; // r13
bool v9; // cf
unsigned __int64 v10; // r13
__m128d *v11; // r14
__int64 v13; // rbx
__m128d *v14; // r15
double v15; // xmm0_8
__m128d v16; // xmm0
unsigned __int8 *result; // rax
__m128d v18; // [rsp+0h] [rbp-60h] BYREF
__int64 v19; // [rsp+10h] [rbp-50h]
unsigned __int64 v20; // [rsp+18h] [rbp-48h]
char *v21; // [rsp+28h] [rbp-38h]
unsigned __int8 *v22; // [rsp+30h] [rbp-30h]
v21 = a4;
v6 = *((_QWORD *)a1 + 1);
v22 = a1;
v7 = *((__m128d **)a1 + 2);
v8 = (__int64)((__int64)v7 - v6) >> 4;
v9 = v8 < a2;
v10 = v8 - a2;
if ( v9 )
sub_1007CE970();
v11 = (__m128d *)(v6 + 16 * a2);
if ( v11 == v7 )
{
v14 = (__m128d *)(v6 + 16 * a2);
v11 = *((__m128d **)a1 + 2);
if ( v6 > (unsigned __int64)v14 )
goto LABEL_15;
goto LABEL_13;
}
v13 = 1;
v14 = (__m128d *)(v6 + 16 * a2);
do
{
v16 = *v11;
v18 = *v11;
v19 = v13;
v20 = v10;
if ( a3[1] == 2 )
{
a1 = a3;
a2 = (unsigned __int64)&v18;
v15 = sub_100646190(a3, &v18, v21, v16, a6).f64[0];
a6 = _mm_sub_pd(
(__m128d)_mm_unpacklo_epi32((__m128i)(unsigned __int64)v13, (__m128i)xmmword_100816540),
(__m128d)xmmword_100816550);
if ( v15 != _mm_unpackhi_pd(a6, a6).f64[0] + a6.f64[0] )
goto LABEL_6;
LABEL_5:
*v14++ = *v11;
goto LABEL_6;
}
a1 = a3;
a2 = (unsigned __int64)&v18;
if ( (unsigned __int8)sub_100644D00((__int64)a3, &v18, v21, v16) )
goto LABEL_5;
LABEL_6:
++v11;
++v13;
}
while ( v11 != *((__m128d **)v22 + 2) );
if ( *((_QWORD *)v22 + 1) > (unsigned __int64)v14 )
LABEL_15:
sub_1007CE940(a1, a2, a3, v7);
LABEL_13:
if ( v11 < v14 )
goto LABEL_15;
result = v22;
*((_QWORD *)v22 + 2) = v14;
return result;
}