#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef scalar_t__ int64_t;

/* Variables and functions */
double fabs(double);
double modf(double x, double *iptr) {
  if (fabs(x) >= 4503599627370496.0) {
    *iptr = x;
    return 0.0;
  } else if (fabs(x) < 1.0) {
    *iptr = 0.0;
    return x;
  } else {
    *iptr = (double)(int64_t)x;
    return (x - *iptr);
  }
}


x86 assembly (clang, -O0):
<modf>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xef7(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xedb(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1149 <modf+0x49>
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11aa <modf+0xaa>
movsd  -0x10(%rbp),%xmm1
movaps 0xebb(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xea7(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1185 <modf+0x85>
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11aa <modf+0xaa>
cvttsd2si -0x10(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<modf>:
movapd 0xef8(%rip),%xmm1
andpd  %xmm0,%xmm1
ucomisd 0xefc(%rip),%xmm1
jae    112c <modf+0x2c>
movsd  0xefa(%rip),%xmm2
ucomisd %xmm1,%xmm2
jbe    1135 <modf+0x35>
movq   $0x0,(%rdi)
ret
movsd  %xmm0,(%rdi)
xorpd  %xmm0,%xmm0
ret
cvttsd2si %xmm0,%rax
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
movsd  %xmm1,(%rdi)
subsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @modf(double %0, double* %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double*
store double %0, double* %4
store double* %1, double** %5
%6 = load double, double* %4
%7 = call double @llvm.fabs.f64(double %6)
%8 = fcmp oge double %7, 0x4330000000000000
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load double, double* %4
%11 = load double*, double** %5
store double %10, double* %11
store double 0.000000e+00, double* %3
br label %28
12: ; preds = %2
%13 = load double, double* %4
%14 = call double @llvm.fabs.f64(double %13)
%15 = fcmp olt double %14, 1.000000e+00
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load double*, double** %5
store double 0.000000e+00, double* %17
%18 = load double, double* %4
store double %18, double* %3
br label %28
19: ; preds = %12
%20 = load double, double* %4
%21 = fptosi double %20 to i64
%22 = sitofp i64 %21 to double
%23 = load double*, double** %5
store double %22, double* %23
%24 = load double, double* %4
%25 = load double*, double** %5
%26 = load double, double* %25
%27 = fsub double %24, %26
store double %27, double* %3
br label %28
28: ; preds = %19, %16, %9
%29 = load double, double* %3
ret double %29
}

LLVM IR (-O2):
define double @modf(double %0, double* nocapture writeonly %1) {
%3 = tail call double @llvm.fabs.f64(double %0)
%4 = fcmp ult double %3, 0x4330000000000000
br i1 %4, label %6, label %5
5: ; preds = %2
store double %0, double* %1
br label %13
6: ; preds = %2
%7 = fcmp olt double %3, 1.000000e+00
br i1 %7, label %8, label %9
8: ; preds = %6
store double 0.000000e+00, double* %1
br label %13
9: ; preds = %6
%10 = fptosi double %0 to i64
%11 = sitofp i64 %10 to double
store double %11, double* %1
%12 = fsub double %0, %11
br label %13
13: ; preds = %9, %8, %5
%14 = phi double [ 0.000000e+00, %5 ], [ %0, %8 ], [ %12, %9 ]
ret double %14
}