#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 ceill(long double);
long double floorl(long double);
double fmodl(long double, int);
long double truncl(long double x) {
  return fmodl(x, 1) == 0.0 ? x : (x < 0.0 ? ceill(x) : floorl(x));
}


x86 assembly (clang, -O0):
<truncl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
fldt   0x10(%rbp)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
mov    $0x1,%edi
call   1030 <fmodl@plt>
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    116e <truncl+0x3e>
jp     116e <truncl+0x3e>
fldt   -0x10(%rbp)
fstpt  -0x1c(%rbp)
jmp    11ad <truncl+0x7d>
fldt   -0x10(%rbp)
fldz
fucomip %st(1),%st
fstp   %st(0)
jbe    1197 <truncl+0x67>
jmp    1182 <truncl+0x52>
fldt   -0x10(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <ceill@plt>
fstpt  -0x28(%rbp)
jmp    11a7 <truncl+0x77>
fldt   -0x10(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1050 <floorl@plt>
fstpt  -0x28(%rbp)
fldt   -0x28(%rbp)
fstpt  -0x1c(%rbp)
fldt   -0x1c(%rbp)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<truncl>:
sub    $0x28,%rsp
fldt   0x30(%rsp)
fld    %st(0)
fstpt  0x1c(%rsp)
fstpt  (%rsp)
mov    $0x1,%edi
call   1030 <fmodl@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1160 <truncl+0x30>
jp     1160 <truncl+0x30>
fldt   0x1c(%rsp)
add    $0x28,%rsp
ret
fldz
fldt   0x1c(%rsp)
fxch   %st(1)
fucomip %st(1),%st
jbe    1179 <truncl+0x49>
fstpt  (%rsp)
call   1040 <ceill@plt>
add    $0x28,%rsp
ret
fstpt  (%rsp)
call   1050 <floorl@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
define x86_fp80 @truncl(x86_fp80 %0) {
%2 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %2
%3 = load x86_fp80, x86_fp80* %2
%4 = call double @fmodl(x86_fp80 %3, i32 1)
%5 = fcmp oeq double %4, 0.000000e+00
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = load x86_fp80, x86_fp80* %2
br label %19
8: ; preds = %1
%9 = load x86_fp80, x86_fp80* %2
%10 = fcmp olt x86_fp80 %9, 0xK00000000000000000000
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load x86_fp80, x86_fp80* %2
%13 = call x86_fp80 @llvm.ceil.f80(x86_fp80 %12)
br label %17
14: ; preds = %8
%15 = load x86_fp80, x86_fp80* %2
%16 = call x86_fp80 @llvm.floor.f80(x86_fp80 %15)
br label %17
17: ; preds = %14, %11
%18 = phi x86_fp80 [ %13, %11 ], [ %16, %14 ]
br label %19
19: ; preds = %17, %6
%20 = phi x86_fp80 [ %7, %6 ], [ %18, %17 ]
ret x86_fp80 %20
}

LLVM IR (-O2):
define x86_fp80 @truncl(x86_fp80 %0) {
%2 = tail call double @fmodl(x86_fp80 %0, i32 1)
%3 = fcmp oeq double %2, 0.000000e+00
br i1 %3, label %10, label %4
4: ; preds = %1
%5 = fcmp olt x86_fp80 %0, 0xK00000000000000000000
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call x86_fp80 @llvm.ceil.f80(x86_fp80 %0)
br label %10
8: ; preds = %4
%9 = tail call x86_fp80 @llvm.floor.f80(x86_fp80 %0)
br label %10
10: ; preds = %1, %6, %8
%11 = phi x86_fp80 [ %7, %6 ], [ %9, %8 ], [ %0, %1 ]
ret x86_fp80 %11
}