#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 */
long double FLT_EPSILON;
float truncf(float x) {
  float y;
  if (x < 0.0L) {
    y = -(1.0L / FLT_EPSILON - x - 1.0 / FLT_EPSILON);
    if (y < x)
      y = y + 1.0L;
  } else {
    y = 1.0L / FLT_EPSILON + x - 1.0 / FLT_EPSILON;
    if (y > x)
      y = y - 1.0L;
  }
  return y;
}


x86 assembly (clang, -O0):
<truncf>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
flds   -0x4(%rbp)
fldz
fucomip %st(1),%st
fstp   %st(0)
jbe    116c <truncf+0x6c>
jmp    111d <truncf+0x1d>
mov    0x2ebc(%rip),%rax
fldt   (%rax)
fld1
fdivp  %st,%st(1)
flds   -0x4(%rbp)
fsubr  %st(1),%st
fsubp  %st,%st(1)
fchs
fstps  -0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm1
movss  -0x4(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1167 <truncf+0x67>
flds   -0x8(%rbp)
fld1
faddp  %st,%st(1)
fstps  -0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11b7 <truncf+0xb7>
mov    0x2e6d(%rip),%rax
fldt   (%rax)
fld1
fdivp  %st,%st(1)
flds   -0x4(%rbp)
fadd   %st(1),%st
fsubp  %st,%st(1)
fstps  -0xc(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    11b2 <truncf+0xb2>
flds   -0x8(%rbp)
fld1
fchs
faddp  %st,%st(1)
fstps  -0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11b7 <truncf+0xb7>
movss  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<truncf>:
movaps %xmm0,%xmm1
movss  %xmm0,-0x4(%rsp)
flds   -0x4(%rsp)
xorps  %xmm0,%xmm0
ucomiss %xmm1,%xmm0
mov    0x2ec6(%rip),%rax
fldt   (%rax)
fld1
fdivp  %st,%st(1)
jbe    114c <truncf+0x4c>
fsub   %st,%st(1)
fsubrp %st,%st(1)
fstps  -0xc(%rsp)
movss  -0xc(%rsp),%xmm2
movaps 0xed9(%rip),%xmm0
xorps  %xmm2,%xmm0
ucomiss %xmm0,%xmm1
jbe    1167 <truncf+0x67>
movss  0xebd(%rip),%xmm0
subss  %xmm2,%xmm0
ret
fadd   %st,%st(1)
fsubrp %st,%st(1)
fstps  -0x8(%rsp)
movss  -0x8(%rsp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1167 <truncf+0x67>
addss  0xe99(%rip),%xmm0
ret

LLVM IR (-O0):
@FLT_EPSILON = global x86_fp80 0xK00000000000000000000
define float @truncf(float %0) {
%2 = alloca float
%3 = alloca float
store float %0, float* %2
%4 = load float, float* %2
%5 = fpext float %4 to x86_fp80
%6 = fcmp olt x86_fp80 %5, 0xK00000000000000000000
br i1 %6, label %7, label %27
7: ; preds = %1
%8 = load x86_fp80, x86_fp80* @FLT_EPSILON
%9 = fdiv x86_fp80 0xK3FFF8000000000000000, %8
%10 = load float, float* %2
%11 = fpext float %10 to x86_fp80
%12 = fsub x86_fp80 %9, %11
%13 = load x86_fp80, x86_fp80* @FLT_EPSILON
%14 = fdiv x86_fp80 0xK3FFF8000000000000000, %13
%15 = fsub x86_fp80 %12, %14
%16 = fneg x86_fp80 %15
%17 = fptrunc x86_fp80 %16 to float
store float %17, float* %3
%18 = load float, float* %3
%19 = load float, float* %2
%20 = fcmp olt float %18, %19
br i1 %20, label %21, label %26
21: ; preds = %7
%22 = load float, float* %3
%23 = fpext float %22 to x86_fp80
%24 = fadd x86_fp80 %23, 0xK3FFF8000000000000000
%25 = fptrunc x86_fp80 %24 to float
store float %25, float* %3
br label %26
26: ; preds = %21, %7
br label %46
27: ; preds = %1
%28 = load x86_fp80, x86_fp80* @FLT_EPSILON
%29 = fdiv x86_fp80 0xK3FFF8000000000000000, %28
%30 = load float, float* %2
%31 = fpext float %30 to x86_fp80
%32 = fadd x86_fp80 %29, %31
%33 = load x86_fp80, x86_fp80* @FLT_EPSILON
%34 = fdiv x86_fp80 0xK3FFF8000000000000000, %33
%35 = fsub x86_fp80 %32, %34
%36 = fptrunc x86_fp80 %35 to float
store float %36, float* %3
%37 = load float, float* %3
%38 = load float, float* %2
%39 = fcmp ogt float %37, %38
br i1 %39, label %40, label %45
40: ; preds = %27
%41 = load float, float* %3
%42 = fpext float %41 to x86_fp80
%43 = fsub x86_fp80 %42, 0xK3FFF8000000000000000
%44 = fptrunc x86_fp80 %43 to float
store float %44, float* %3
br label %45
45: ; preds = %40, %27
br label %46
46: ; preds = %45, %26
%47 = load float, float* %3
ret float %47
}

LLVM IR (-O2):
@FLT_EPSILON = global x86_fp80 0xK00000000000000000000
define float @truncf(float %0) {
%2 = fpext float %0 to x86_fp80
%3 = fcmp olt float %0, 0.000000e+00
%4 = load x86_fp80, x86_fp80* @FLT_EPSILON
%5 = fdiv x86_fp80 0xK3FFF8000000000000000, %4
br i1 %3, label %6, label %14
6: ; preds = %1
%7 = fsub x86_fp80 %5, %2
%8 = fsub x86_fp80 %7, %5
%9 = fptrunc x86_fp80 %8 to float
%10 = fneg float %9
%11 = fcmp olt float %10, %0
br i1 %11, label %12, label %21
12: ; preds = %6
%13 = fsub float 1.000000e+00, %9
br label %21
14: ; preds = %1
%15 = fadd x86_fp80 %5, %2
%16 = fsub x86_fp80 %15, %5
%17 = fptrunc x86_fp80 %16 to float
%18 = fcmp ogt float %17, %0
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = fadd float %17, -1.000000e+00
br label %21
21: ; preds = %14, %19, %6, %12
%22 = phi float [ %13, %12 ], [ %10, %6 ], [ %20, %19 ], [ %17, %14 ]
ret float %22
}