#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 int ulong;

/* Variables and functions */
int /*<<< orphan*/ SIGFPE;
int /*<<< orphan*/ raise(int /*<<< orphan*/);
float __truncdfsf2(double a) {
  long lc;
  if ((((const long *)&a)[1] & 0x7ff00000) < 0x38100000)
    lc = ((const long *)&a)[1] & 0x80000000;
  else if ((((const long *)&a)[1] & 0x7ff00000) >= 0x47f00000) {
    raise(SIGFPE);
    lc = (((const long *)&a)[1] & 0x80000000) + 0x7f800000;
  } else {
    lc = (((const long *)&a)[1] & 0xc0000000) +
         ((((const long *)&a)[1] & 0x07ffffff) << 3) +
         (((const ulong *)&a)[0] >> 29);
    if (((const ulong *)&a)[0] & 0x10000000)
      ++lc;
  }
  return (*(const float *)&lc);
}


x86 assembly (clang, -O0):
<__truncdfsf2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    0x0(%rbp),%rax
and    $0x7ff00000,%rax
cmp    $0x38100000,%rax
jge    114a <__truncdfsf2+0x3a>
movabs $0x80000000,%rax
and    0x0(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    11e2 <__truncdfsf2+0xd2>
mov    0x0(%rbp),%rax
and    $0x7ff00000,%rax
cmp    $0x47f00000,%rax
jl     118b <__truncdfsf2+0x7b>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
call   1030 <raise@plt>
movabs $0x80000000,%rax
and    0x0(%rbp),%rax
add    $0x7f800000,%rax
mov    %rax,-0x10(%rbp)
jmp    11dd <__truncdfsf2+0xcd>
movabs $0xc0000000,%rax
and    0x0(%rbp),%rax
mov    0x0(%rbp),%rcx
and    $0x7ffffff,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    -0x8(%rbp),%ecx
sar    $0x1d,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
and    $0x10000000,%eax
cmp    $0x0,%eax
je     11d8 <__truncdfsf2+0xc8>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11dd <__truncdfsf2+0xcd>
jmp    11e2 <__truncdfsf2+0xd2>
movss  -0x10(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__truncdfsf2>:
ret

LLVM IR (-O0):
@SIGFPE = global i32 0
define float @__truncdfsf2(double %0) {
%2 = alloca double
%3 = alloca i64
store double %0, double* %2
%4 = bitcast double* %2 to i64*
%5 = getelementptr inbounds i64, i64* %4, i64 1
%6 = load i64, i64* %5
%7 = and i64 %6, 2146435072
%8 = icmp slt i64 %7, 940572672
br i1 %8, label %9, label %14
9: ; preds = %1
%10 = bitcast double* %2 to i64*
%11 = getelementptr inbounds i64, i64* %10, i64 1
%12 = load i64, i64* %11
%13 = and i64 %12, 2147483648
store i64 %13, i64* %3
br label %55
14: ; preds = %1
%15 = bitcast double* %2 to i64*
%16 = getelementptr inbounds i64, i64* %15, i64 1
%17 = load i64, i64* %16
%18 = and i64 %17, 2146435072
%19 = icmp sge i64 %18, 1206910976
br i1 %19, label %20, label %28
20: ; preds = %14
%21 = load i32, i32* @SIGFPE
%22 = call i32 @raise(i32 %21)
%23 = bitcast double* %2 to i64*
%24 = getelementptr inbounds i64, i64* %23, i64 1
%25 = load i64, i64* %24
%26 = and i64 %25, 2147483648
%27 = add nsw i64 %26, 2139095040
store i64 %27, i64* %3
br label %54
28: ; preds = %14
%29 = bitcast double* %2 to i64*
%30 = getelementptr inbounds i64, i64* %29, i64 1
%31 = load i64, i64* %30
%32 = and i64 %31, 3221225472
%33 = bitcast double* %2 to i64*
%34 = getelementptr inbounds i64, i64* %33, i64 1
%35 = load i64, i64* %34
%36 = and i64 %35, 134217727
%37 = shl i64 %36, 3
%38 = add nsw i64 %32, %37
%39 = bitcast double* %2 to i32*
%40 = getelementptr inbounds i32, i32* %39, i64 0
%41 = load i32, i32* %40
%42 = ashr i32 %41, 29
%43 = sext i32 %42 to i64
%44 = add nsw i64 %38, %43
store i64 %44, i64* %3
%45 = bitcast double* %2 to i32*
%46 = getelementptr inbounds i32, i32* %45, i64 0
%47 = load i32, i32* %46
%48 = and i32 %47, 268435456
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %28
%51 = load i64, i64* %3
%52 = add nsw i64 %51, 1
store i64 %52, i64* %3
br label %53
53: ; preds = %50, %28
br label %54
54: ; preds = %53, %20
br label %55
55: ; preds = %54, %9
%56 = bitcast i64* %3 to float*
%57 = load float, float* %56
ret float %57
}

LLVM IR (-O2):
@SIGFPE = global i32 0
define float @__truncdfsf2(double %0) {
ret float poison
}