#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 */
int INT_MAX;
double UINT_MAX;
int /*<<< orphan*/ testCase(int, int);
int main() {
  testCase(UINT_MAX, -1);
  testCase(UINT_MAX - 0.03, -2);
  testCase(UINT_MAX - 1, -2);
  testCase(UINT_MAX - 2, -3);
  testCase(UINT_MAX - 5, -6);
  testCase(UINT_MAX - 2.5, -4);
  testCase(UINT_MAX - 2.4, -4);
  testCase(UINT_MAX - 2.6, -4);
  testCase(UINT_MAX / 2, 2147483647);
  testCase(UINT_MAX / 2 + 1, -2147483648);
  testCase(UINT_MAX / 2 - 1.0, 2147483646);
  testCase(UINT_MAX / 2 + 1.999999999, -2147483647);
  testCase(-1, -1);
  testCase(0, 0);
  testCase(1.5, 1);
  testCase(INT_MAX + 1, -2147483648);
  testCase(INT_MAX, 2147483647);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
mov    0x2ec5(%rip),%rax
cvttsd2si (%rax),%edi
mov    $0xffffffff,%esi
call   1030 <testCase@plt>
mov    0x2eb0(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xefc(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    $0xfffffffe,%esi
call   1030 <testCase@plt>
mov    0x2e8b(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xeaf(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    $0xfffffffe,%esi
call   1030 <testCase@plt>
mov    0x2e66(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe82(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    $0xfffffffd,%esi
call   1030 <testCase@plt>
mov    0x2e41(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe85(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    $0xfffffffa,%esi
call   1030 <testCase@plt>
mov    0x2e1c(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe58(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    $0xfffffffc,%esi
call   1030 <testCase@plt>
mov    0x2df7(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe2b(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    $0xfffffffc,%esi
call   1030 <testCase@plt>
mov    0x2dd2(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xdfe(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    $0xfffffffc,%esi
call   1030 <testCase@plt>
mov    0x2dad(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xdc9(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    $0x7fffffff,%esi
call   1030 <testCase@plt>
mov    0x2d88(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xda4(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xda0(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    $0x80000000,%esi
call   1030 <testCase@plt>
mov    0x2d57(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xd73(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd6f(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    $0x7ffffffe,%esi
call   1030 <testCase@plt>
mov    0x2d26(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xd42(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd2e(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    $0x80000001,%esi
call   1030 <testCase@plt>
mov    $0xffffffff,%esi
mov    %esi,%edi
call   1030 <testCase@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1030 <testCase@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1030 <testCase@plt>
mov    0x2cdc(%rip),%rax
mov    (%rax),%edi
add    $0x1,%edi
mov    $0x80000000,%esi
call   1030 <testCase@plt>
mov    0x2cc6(%rip),%rax
mov    (%rax),%edi
mov    $0x7fffffff,%esi
call   1030 <testCase@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2ec8(%rip),%rbx
cvttsd2si (%rbx),%edi
mov    $0xffffffff,%esi
call   1030 <testCase@plt>
movsd  (%rbx),%xmm0
addsd  0xece(%rip),%xmm0
cvttsd2si %xmm0,%edi
mov    $0xfffffffe,%esi
call   1030 <testCase@plt>
movsd  (%rbx),%xmm0
addsd  0xebc(%rip),%xmm0
cvttsd2si %xmm0,%edi
mov    $0xfffffffe,%esi
call   1030 <testCase@plt>
movsd  (%rbx),%xmm0
addsd  0xeaa(%rip),%xmm0
cvttsd2si %xmm0,%edi
mov    $0xfffffffd,%esi
call   1030 <testCase@plt>
movsd  (%rbx),%xmm0
addsd  0xe98(%rip),%xmm0
cvttsd2si %xmm0,%edi
mov    $0xfffffffa,%esi
call   1030 <testCase@plt>
movsd  (%rbx),%xmm0
addsd  0xe86(%rip),%xmm0
cvttsd2si %xmm0,%edi
mov    $0xfffffffc,%esi
call   1030 <testCase@plt>
movsd  (%rbx),%xmm0
addsd  0xe74(%rip),%xmm0
cvttsd2si %xmm0,%edi
mov    $0xfffffffc,%esi
call   1030 <testCase@plt>
movsd  (%rbx),%xmm0
addsd  0xe62(%rip),%xmm0
cvttsd2si %xmm0,%edi
mov    $0xfffffffc,%esi
call   1030 <testCase@plt>
movsd  (%rbx),%xmm0
mulsd  0xe50(%rip),%xmm0
cvttsd2si %xmm0,%edi
mov    $0x7fffffff,%esi
call   1030 <testCase@plt>
movsd  (%rbx),%xmm0
mulsd  0xe36(%rip),%xmm0
addsd  0xe36(%rip),%xmm0
cvttsd2si %xmm0,%edi
mov    $0x80000000,%esi
call   1030 <testCase@plt>
movsd  (%rbx),%xmm0
mulsd  0xe14(%rip),%xmm0
addsd  0xddc(%rip),%xmm0
cvttsd2si %xmm0,%edi
mov    $0x7ffffffe,%esi
call   1030 <testCase@plt>
movsd  0xdf6(%rip),%xmm0
mulsd  (%rbx),%xmm0
addsd  0xdfa(%rip),%xmm0
cvttsd2si %xmm0,%edi
mov    $0x80000001,%esi
call   1030 <testCase@plt>
mov    $0xffffffff,%edi
mov    $0xffffffff,%esi
call   1030 <testCase@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <testCase@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1030 <testCase@plt>
mov    0x2d5e(%rip),%rbx
mov    (%rbx),%edi
add    $0x1,%edi
mov    $0x80000000,%esi
call   1030 <testCase@plt>
mov    (%rbx),%edi
mov    $0x7fffffff,%esi
call   1030 <testCase@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@UINT_MAX = global double 0.000000e+00
@INT_MAX = global i32 0
define i32 @main() {
%1 = load double, double* @UINT_MAX
%2 = fptosi double %1 to i32
%3 = call i32 @testCase(i32 %2, i32 -1)
%4 = load double, double* @UINT_MAX
%5 = fsub double %4, 3.000000e-02
%6 = fptosi double %5 to i32
%7 = call i32 @testCase(i32 %6, i32 -2)
%8 = load double, double* @UINT_MAX
%9 = fsub double %8, 1.000000e+00
%10 = fptosi double %9 to i32
%11 = call i32 @testCase(i32 %10, i32 -2)
%12 = load double, double* @UINT_MAX
%13 = fsub double %12, 2.000000e+00
%14 = fptosi double %13 to i32
%15 = call i32 @testCase(i32 %14, i32 -3)
%16 = load double, double* @UINT_MAX
%17 = fsub double %16, 5.000000e+00
%18 = fptosi double %17 to i32
%19 = call i32 @testCase(i32 %18, i32 -6)
%20 = load double, double* @UINT_MAX
%21 = fsub double %20, 2.500000e+00
%22 = fptosi double %21 to i32
%23 = call i32 @testCase(i32 %22, i32 -4)
%24 = load double, double* @UINT_MAX
%25 = fsub double %24, 2.400000e+00
%26 = fptosi double %25 to i32
%27 = call i32 @testCase(i32 %26, i32 -4)
%28 = load double, double* @UINT_MAX
%29 = fsub double %28, 2.600000e+00
%30 = fptosi double %29 to i32
%31 = call i32 @testCase(i32 %30, i32 -4)
%32 = load double, double* @UINT_MAX
%33 = fdiv double %32, 2.000000e+00
%34 = fptosi double %33 to i32
%35 = call i32 @testCase(i32 %34, i32 2147483647)
%36 = load double, double* @UINT_MAX
%37 = fdiv double %36, 2.000000e+00
%38 = fadd double %37, 1.000000e+00
%39 = fptosi double %38 to i32
%40 = call i32 @testCase(i32 %39, i32 -2147483648)
%41 = load double, double* @UINT_MAX
%42 = fdiv double %41, 2.000000e+00
%43 = fsub double %42, 1.000000e+00
%44 = fptosi double %43 to i32
%45 = call i32 @testCase(i32 %44, i32 2147483646)
%46 = load double, double* @UINT_MAX
%47 = fdiv double %46, 2.000000e+00
%48 = fadd double %47, 0x3FFFFFFFFFBB47D0
%49 = fptosi double %48 to i32
%50 = call i32 @testCase(i32 %49, i32 -2147483647)
%51 = call i32 @testCase(i32 -1, i32 -1)
%52 = call i32 @testCase(i32 0, i32 0)
%53 = call i32 @testCase(i32 1, i32 1)
%54 = load i32, i32* @INT_MAX
%55 = add nsw i32 %54, 1
%56 = call i32 @testCase(i32 %55, i32 -2147483648)
%57 = load i32, i32* @INT_MAX
%58 = call i32 @testCase(i32 %57, i32 2147483647)
ret i32 0
}

LLVM IR (-O2):
@UINT_MAX = global double 0.000000e+00
@INT_MAX = global i32 0
define i32 @main() {
%1 = load double, double* @UINT_MAX
%2 = fptosi double %1 to i32
%3 = tail call i32 @testCase(i32 %2, i32 -1)
%4 = load double, double* @UINT_MAX
%5 = fadd double %4, -3.000000e-02
%6 = fptosi double %5 to i32
%7 = tail call i32 @testCase(i32 %6, i32 -2)
%8 = load double, double* @UINT_MAX
%9 = fadd double %8, -1.000000e+00
%10 = fptosi double %9 to i32
%11 = tail call i32 @testCase(i32 %10, i32 -2)
%12 = load double, double* @UINT_MAX
%13 = fadd double %12, -2.000000e+00
%14 = fptosi double %13 to i32
%15 = tail call i32 @testCase(i32 %14, i32 -3)
%16 = load double, double* @UINT_MAX
%17 = fadd double %16, -5.000000e+00
%18 = fptosi double %17 to i32
%19 = tail call i32 @testCase(i32 %18, i32 -6)
%20 = load double, double* @UINT_MAX
%21 = fadd double %20, -2.500000e+00
%22 = fptosi double %21 to i32
%23 = tail call i32 @testCase(i32 %22, i32 -4)
%24 = load double, double* @UINT_MAX
%25 = fadd double %24, -2.400000e+00
%26 = fptosi double %25 to i32
%27 = tail call i32 @testCase(i32 %26, i32 -4)
%28 = load double, double* @UINT_MAX
%29 = fadd double %28, -2.600000e+00
%30 = fptosi double %29 to i32
%31 = tail call i32 @testCase(i32 %30, i32 -4)
%32 = load double, double* @UINT_MAX
%33 = fmul double %32, 5.000000e-01
%34 = fptosi double %33 to i32
%35 = tail call i32 @testCase(i32 %34, i32 2147483647)
%36 = load double, double* @UINT_MAX
%37 = fmul double %36, 5.000000e-01
%38 = fadd double %37, 1.000000e+00
%39 = fptosi double %38 to i32
%40 = tail call i32 @testCase(i32 %39, i32 -2147483648)
%41 = load double, double* @UINT_MAX
%42 = fmul double %41, 5.000000e-01
%43 = fadd double %42, -1.000000e+00
%44 = fptosi double %43 to i32
%45 = tail call i32 @testCase(i32 %44, i32 2147483646)
%46 = load double, double* @UINT_MAX
%47 = fmul double %46, 5.000000e-01
%48 = fadd double %47, 0x3FFFFFFFFFBB47D0
%49 = fptosi double %48 to i32
%50 = tail call i32 @testCase(i32 %49, i32 -2147483647)
%51 = tail call i32 @testCase(i32 -1, i32 -1)
%52 = tail call i32 @testCase(i32 0, i32 0)
%53 = tail call i32 @testCase(i32 1, i32 1)
%54 = load i32, i32* @INT_MAX
%55 = add nsw i32 %54, 1
%56 = tail call i32 @testCase(i32 %55, i32 -2147483648)
%57 = load i32, i32* @INT_MAX
%58 = tail call i32 @testCase(i32 %57, i32 2147483647)
ret i32 0
}