#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 */

/* Variables and functions */
double fabs(float);
double fabsf(float);
float modff(float x, float *iptr) {
  if (fabsf(x) >= 8388608.0) {
    *iptr = x;
    return 0.0;
  } else if (fabs(x) < 1.0) {
    *iptr = (x * 0.0);
    return x;
  } else {
    *iptr = (float)(int)x;
    return (x - *iptr);
  }
}


x86 assembly (clang, -O0):
<modff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <fabsf@plt>
movsd  0xebd(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1167 <modff+0x47>
movss  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11d4 <modff+0xb4>
movss  -0x8(%rbp),%xmm0
call   1040 <fabs@plt>
movaps %xmm0,%xmm1
movsd  0xe8c(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b1 <modff+0x91>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11d4 <modff+0xb4>
cvttss2si -0x8(%rbp),%eax
cvtsi2ss %eax,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
subss  (%rax),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<modff>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movapd %xmm0,(%rsp)
call   1030 <fabsf@plt>
ucomisd 0xec6(%rip),%xmm0
jae    1166 <modff+0x46>
movapd (%rsp),%xmm0
call   1040 <fabs@plt>
movsd  0xeba(%rip),%xmm1
ucomisd %xmm0,%xmm1
movaps (%rsp),%xmm0
jbe    1173 <modff+0x53>
xorpd  %xmm1,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,(%rbx)
jmp    1182 <modff+0x62>
movaps (%rsp),%xmm0
movss  %xmm0,(%rbx)
xorps  %xmm0,%xmm0
jmp    1182 <modff+0x62>
cvttps2dq %xmm0,%xmm1
cvtdq2ps %xmm1,%xmm1
movss  %xmm1,(%rbx)
subss  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @modff(float %0, float* %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float*
store float %0, float* %4
store float* %1, float** %5
%6 = load float, float* %4
%7 = call double @fabsf(float %6)
%8 = fcmp oge double %7, 0x4160000000000000
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load float, float* %4
%11 = load float*, float** %5
store float %10, float* %11
store float 0.000000e+00, float* %3
br label %32
12: ; preds = %2
%13 = load float, float* %4
%14 = call double @fabs(float %13)
%15 = fcmp olt double %14, 1.000000e+00
br i1 %15, label %16, label %23
16: ; preds = %12
%17 = load float, float* %4
%18 = fpext float %17 to double
%19 = fmul double %18, 0.000000e+00
%20 = fptrunc double %19 to float
%21 = load float*, float** %5
store float %20, float* %21
%22 = load float, float* %4
store float %22, float* %3
br label %32
23: ; preds = %12
%24 = load float, float* %4
%25 = fptosi float %24 to i32
%26 = sitofp i32 %25 to float
%27 = load float*, float** %5
store float %26, float* %27
%28 = load float, float* %4
%29 = load float*, float** %5
%30 = load float, float* %29
%31 = fsub float %28, %30
store float %31, float* %3
br label %32
32: ; preds = %23, %16, %9
%33 = load float, float* %3
ret float %33
}

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