//
// __remainder_piby2d2f_forC from 0x1801368a0 to 0x180136a2c (396 bytes)
//
// 3 xrefs:
// > sinf @ 0x18012a0d4
// > ??> @ 0x18020353c
// > ??> @ 0x180203548
//
// 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 10:55:00 +0000
//
unsigned __int64 __fastcall _remainder_piby2d2f_forC(unsigned __int64 a1, double *a2, _DWORD *a3)
{
unsigned __int64 v4; // r11
__int64 v5; // r10
__int64 v7; // rcx
__m128i v8; // xmm0
__int64 v9; // r8
unsigned __int64 v10; // r11
unsigned __int64 v11; // r9
__int64 v12; // r10
unsigned __int128 v13; // kr10_16
unsigned __int64 v14; // rdx
bool v15; // cf
unsigned __int64 result; // rax
unsigned __int64 v17; // r10
unsigned __int64 v18; // r11
__int64 v20; // rcx
__int64 v21; // r11
__int64 v22; // rcx
__int64 v23; // rcx
v4 = (a1 >> 52) - 1023;
v5 = 134 - (v4 >> 3);
v7 = a1 & 0xFFFFFFFFFFFFFLL | 0x10000000000000LL;
v8 = _mm_loadu_si128((const __m128i *)((char *)&unk_180175740 + v5 + 8));
v9 = v7 * *(_QWORD *)((char *)&unk_180175740 + v5);
v10 = v4 & 7;
v13 = __PAIR128__(
v7 * _mm_srli_si128(v8, 8).m128i_u64[0],
((unsigned __int64)v7 * (unsigned __int128)*(unsigned __int64 *)((char *)&unk_180175740 + v5)) >> 64)
+ (unsigned __int64)v7 * (unsigned __int128)v8.m128i_u64[0];
v12 = *((_QWORD *)&v13 + 1);
v11 = v13;
v14 = 0;
v15 = __CFSHR__(*((_QWORD *)&v13 + 1), 54 - v10);
if ( v15 )
{
v12 = ~*((_QWORD *)&v13 + 1);
v11 = ~(_QWORD)v13;
v9 = ~v9;
v14 = 0x8000000000000000uLL;
}
result = (v15 + (unsigned __int8)(*((_QWORD *)&v13 + 1) >> (54 - (unsigned __int8)v10))) & 3;
*a3 = result;
v17 = (unsigned __int64)(v12 << ((unsigned __int8)v10 + 10)) >> ((unsigned __int8)v10 + 10);
v18 = v10 - 54;
if ( !_BitScanReverse64((unsigned __int64 *)&v20, v17) )
{
v17 = v11;
v11 = v9;
_BitScanReverse64((unsigned __int64 *)&v20, v17);
v18 -= 64LL;
}
v21 = v20 + v18;
v22 = v20 - 52;
if ( v22 < 0 )
{
v23 = -v22;
result = v11 >> (64 - (unsigned __int8)v23);
v17 = result | (v17 << v23);
}
else if ( v22 )
{
v17 >>= v22;
}
*a2 = COERCE_DOUBLE(((v21 + 1023) << 52) | v14 | v17 & 0xFFEFFFFFFFFFFFFFuLL) * 1.570796326794897;
return result;
}