double ft_modf(double n, double *iptr) {
  double absvalue;
  if ((absvalue = (n >= 0.0) ? n : -n) >= 4.503599627370496000E+15)
    *iptr = n;
  else {
    *iptr = absvalue + 4.503599627370496000E+15;
    *iptr -= 4.503599627370496000E+15;
    while (*iptr > absvalue)
      *iptr -= 1.0;
    if (n < 0.0)
      *iptr = -*iptr;
  }
  return (n - *iptr);
}


x86 assembly (clang, -O0):
<ft_modf>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     112e <ft_modf+0x2e>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    114f <ft_modf+0x4f>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe9f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     117d <ft_modf+0x7d>
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1214 <ft_modf+0x114>
movsd  0xe7b(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe5e(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11da <ft_modf+0xda>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe3b(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
jmp    11aa <ft_modf+0xaa>
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    120f <ft_modf+0x10f>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1214 <ft_modf+0x114>
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_modf>:
movapd 0xef8(%rip),%xmm1
xorpd  %xmm0,%xmm1
xorpd  %xmm2,%xmm2
cmplesd %xmm0,%xmm2
movapd %xmm2,%xmm3
andpd  %xmm0,%xmm3
andnpd %xmm1,%xmm2
orpd   %xmm3,%xmm2
ucomisd 0xee3(%rip),%xmm2
movapd %xmm0,%xmm1
jae    1180 <ft_modf+0x80>
movsd  0xed5(%rip),%xmm1
addsd  %xmm2,%xmm1
addsd  0xed1(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    116a <ft_modf+0x6a>
movsd  0xecb(%rip),%xmm3
cs nopw 0x0(%rax,%rax,1)
nop
addsd  %xmm3,%xmm1
ucomisd %xmm2,%xmm1
ja     1160 <ft_modf+0x60>
movsd  %xmm1,(%rdi)
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
jbe    1184 <ft_modf+0x84>
xorpd  0xe80(%rip),%xmm1
movsd  %xmm1,(%rdi)
subsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @ft_modf(double %0, double* %1) {
%3 = alloca double
%4 = alloca double*
%5 = alloca double
store double %0, double* %3
store double* %1, double** %4
%6 = load double, double* %3
%7 = fcmp oge double %6, 0.000000e+00
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = load double, double* %3
br label %13
10: ; preds = %2
%11 = load double, double* %3
%12 = fneg double %11
br label %13
13: ; preds = %10, %8
%14 = phi double [ %9, %8 ], [ %12, %10 ]
store double %14, double* %5
%15 = fcmp oge double %14, 0x4330000000000000
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load double, double* %3
%18 = load double*, double** %4
store double %17, double* %18
br label %44
19: ; preds = %13
%20 = load double, double* %5
%21 = fadd double %20, 0x4330000000000000
%22 = load double*, double** %4
store double %21, double* %22
%23 = load double*, double** %4
%24 = load double, double* %23
%25 = fsub double %24, 0x4330000000000000
store double %25, double* %23
br label %26
26: ; preds = %31, %19
%27 = load double*, double** %4
%28 = load double, double* %27
%29 = load double, double* %5
%30 = fcmp ogt double %28, %29
br i1 %30, label %31, label %35
31: ; preds = %26
%32 = load double*, double** %4
%33 = load double, double* %32
%34 = fsub double %33, 1.000000e+00
store double %34, double* %32
br label %26
35: ; preds = %26
%36 = load double, double* %3
%37 = fcmp olt double %36, 0.000000e+00
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = load double*, double** %4
%40 = load double, double* %39
%41 = fneg double %40
%42 = load double*, double** %4
store double %41, double* %42
br label %43
43: ; preds = %38, %35
br label %44
44: ; preds = %43, %16
%45 = load double, double* %3
%46 = load double*, double** %4
%47 = load double, double* %46
%48 = fsub double %45, %47
ret double %48
}

LLVM IR (-O2):
define double @ft_modf(double %0, double* nocapture %1) {
%3 = fcmp oge double %0, 0.000000e+00
%4 = fneg double %0
%5 = select i1 %3, double %0, double %4
%6 = fcmp ult double %5, 0x4330000000000000
br i1 %6, label %7, label %20
7: ; preds = %2
%8 = fadd double %5, 0x4330000000000000
%9 = fadd double %8, 0xC330000000000000
%10 = fcmp ogt double %9, %5
br i1 %10, label %11, label %15
11: ; preds = %7, %11
%12 = phi double [ %13, %11 ], [ %9, %7 ]
%13 = fadd double %12, -1.000000e+00
%14 = fcmp ogt double %13, %5
br i1 %14, label %11, label %15
15: ; preds = %11, %7
%16 = phi double [ %9, %7 ], [ %13, %11 ]
store double %16, double* %1
%17 = fcmp olt double %0, 0.000000e+00
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = fneg double %16
br label %20
20: ; preds = %2, %18
%21 = phi double [ %19, %18 ], [ %0, %2 ]
store double %21, double* %1
br label %22
22: ; preds = %20, %15
%23 = phi double [ %16, %15 ], [ %21, %20 ]
%24 = fsub double %0, %23
ret double %24
}