#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 = 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    11c3 <modff+0xa3>
movss  -0x8(%rbp),%xmm0
call   1040 <fabs@plt>
movaps %xmm0,%xmm1
movsd  0xe8c(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a0 <modff+0x80>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11c3 <modff+0xa3>
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    1160 <modff+0x40>
movapd (%rsp),%xmm0
call   1040 <fabs@plt>
movsd  0xeba(%rip),%xmm1
ucomisd %xmm0,%xmm1
movaps (%rsp),%xmm0
jbe    116d <modff+0x4d>
movl   $0x0,(%rbx)
jmp    117c <modff+0x5c>
movaps (%rsp),%xmm0
movss  %xmm0,(%rbx)
xorps  %xmm0,%xmm0
jmp    117c <modff+0x5c>
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 %28
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 %19
16: ; preds = %12
%17 = load float*, float** %5
store float 0.000000e+00, float* %17
%18 = load float, float* %4
store float %18, float* %3
br label %28
19: ; preds = %12
%20 = load float, float* %4
%21 = fptosi float %20 to i32
%22 = sitofp i32 %21 to float
%23 = load float*, float** %5
store float %22, float* %23
%24 = load float, float* %4
%25 = load float*, float** %5
%26 = load float, float* %25
%27 = fsub float %24, %26
store float %27, float* %3
br label %28
28: ; preds = %19, %16, %9
%29 = load float, float* %3
ret float %29
}

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 %14
6: ; preds = %2
%7 = tail call double @fabs(float %0)
%8 = fcmp olt double %7, 1.000000e+00
br i1 %8, label %9, label %10
9: ; preds = %6
store float 0.000000e+00, float* %1
br label %14
10: ; preds = %6
%11 = fptosi float %0 to i32
%12 = sitofp i32 %11 to float
store float %12, float* %1
%13 = fsub float %0, %12
br label %14
14: ; preds = %10, %9, %5
%15 = phi float [ 0.000000e+00, %5 ], [ %0, %9 ], [ %13, %10 ]
ret float %15
}