#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 /*<<< orphan*/ abort();
int /*<<< orphan*/ dnear(double, double);
int /*<<< orphan*/ fnear(float, float);
double s2d(int);
float s2f(int);
double u2d(unsigned int);
float u2f(unsigned int);
test_integer_to_float() {
  if (u2f(0U) != (float)0U)
    abort();
  if (!fnear(u2f(~0U), (float)~0U))
    abort();
  if (!fnear(u2f((~0U) >> 1), (float)((~0U) >> 1)))
    abort();
  if (u2f(~((~0U) >> 1)) != (float)~((~0U) >> 1))
    abort();
  if (u2d(0U) != (double)0U)
    abort();
  if (!dnear(u2d(~0U), (double)~0U))
    abort();
  if (!dnear(u2d((~0U) >> 1), (double)((~0U) >> 1)))
    abort();
  if (u2d(~((~0U) >> 1)) != (double)~((~0U) >> 1))
    abort();
  if (s2f(0) != (float)0)
    abort();
  if (!fnear(s2f(~0), (float)~0))
    abort();
  if (!fnear(s2f((int)((~0U) >> 1)), (float)(int)((~0U) >> 1)))
    abort();
  if (s2f((int)(~((~0U) >> 1))) != (float)(int)~((~0U) >> 1))
    abort();
  if (s2d(0) != (double)0)
    abort();
  if (!dnear(s2d(~0), (double)~0))
    abort();
  if (!dnear(s2d((int)((~0U) >> 1)), (double)(int)((~0U) >> 1)))
    abort();
  if (s2d((int)~((~0U) >> 1)) != (double)(int)~((~0U) >> 1))
    abort();
}


x86 assembly (clang, -O0):
<test_integer_to_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
call   1060 <u2f@plt>
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1196 <test_integer_to_float+0x26>
jp     1196 <test_integer_to_float+0x26>
jmp    119d <test_integer_to_float+0x2d>
mov    $0x0,%al
call   1040 <abort@plt>
mov    $0xffffffff,%edi
call   1060 <u2f@plt>
movss  0xe51(%rip),%xmm1
call   1030 <fnear@plt>
cmp    $0x0,%eax
jne    11c4 <test_integer_to_float+0x54>
mov    $0x0,%al
call   1040 <abort@plt>
mov    $0x7fffffff,%edi
call   1060 <u2f@plt>
movss  0xe2e(%rip),%xmm1
call   1030 <fnear@plt>
cmp    $0x0,%eax
jne    11eb <test_integer_to_float+0x7b>
mov    $0x0,%al
call   1040 <abort@plt>
mov    $0x80000000,%edi
call   1060 <u2f@plt>
movss  0xe07(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    1211 <test_integer_to_float+0xa1>
jp     1211 <test_integer_to_float+0xa1>
jmp    1218 <test_integer_to_float+0xa8>
mov    $0x0,%al
call   1040 <abort@plt>
xor    %edi,%edi
call   1050 <u2d@plt>
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1237 <test_integer_to_float+0xc7>
jp     1237 <test_integer_to_float+0xc7>
jmp    123e <test_integer_to_float+0xce>
mov    $0x0,%al
call   1040 <abort@plt>
mov    $0xffffffff,%edi
call   1050 <u2d@plt>
movsd  0xdc0(%rip),%xmm1
call   1080 <dnear@plt>
cmp    $0x0,%eax
jne    1265 <test_integer_to_float+0xf5>
mov    $0x0,%al
call   1040 <abort@plt>
mov    $0x7fffffff,%edi
call   1050 <u2d@plt>
movsd  0xda1(%rip),%xmm1
call   1080 <dnear@plt>
cmp    $0x0,%eax
jne    128c <test_integer_to_float+0x11c>
mov    $0x0,%al
call   1040 <abort@plt>
mov    $0x80000000,%edi
call   1050 <u2d@plt>
movsd  0xd82(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    12b3 <test_integer_to_float+0x143>
jp     12b3 <test_integer_to_float+0x143>
jmp    12ba <test_integer_to_float+0x14a>
mov    $0x0,%al
call   1040 <abort@plt>
xor    %edi,%edi
call   1070 <s2f@plt>
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    12d8 <test_integer_to_float+0x168>
jp     12d8 <test_integer_to_float+0x168>
jmp    12df <test_integer_to_float+0x16f>
mov    $0x0,%al
call   1040 <abort@plt>
mov    $0xffffffff,%edi
call   1070 <s2f@plt>
movss  0xd17(%rip),%xmm1
call   1030 <fnear@plt>
cmp    $0x0,%eax
jne    1306 <test_integer_to_float+0x196>
mov    $0x0,%al
call   1040 <abort@plt>
mov    $0x7fffffff,%edi
call   1070 <s2f@plt>
movss  0xcec(%rip),%xmm1
call   1030 <fnear@plt>
cmp    $0x0,%eax
jne    132d <test_integer_to_float+0x1bd>
mov    $0x0,%al
call   1040 <abort@plt>
mov    $0x80000000,%edi
call   1070 <s2f@plt>
movss  0xccd(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    1353 <test_integer_to_float+0x1e3>
jp     1353 <test_integer_to_float+0x1e3>
jmp    135a <test_integer_to_float+0x1ea>
mov    $0x0,%al
call   1040 <abort@plt>
xor    %edi,%edi
call   1090 <s2d@plt>
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1379 <test_integer_to_float+0x209>
jp     1379 <test_integer_to_float+0x209>
jmp    1380 <test_integer_to_float+0x210>
mov    $0x0,%al
call   1040 <abort@plt>
mov    $0xffffffff,%edi
call   1090 <s2d@plt>
movsd  0xc96(%rip),%xmm1
call   1080 <dnear@plt>
cmp    $0x0,%eax
jne    13a7 <test_integer_to_float+0x237>
mov    $0x0,%al
call   1040 <abort@plt>
mov    $0x7fffffff,%edi
call   1090 <s2d@plt>
movsd  0xc5f(%rip),%xmm1
call   1080 <dnear@plt>
cmp    $0x0,%eax
jne    13ce <test_integer_to_float+0x25e>
mov    $0x0,%al
call   1040 <abort@plt>
mov    $0x80000000,%edi
call   1090 <s2d@plt>
movsd  0xc50(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    13f5 <test_integer_to_float+0x285>
jp     13f5 <test_integer_to_float+0x285>
jmp    13fc <test_integer_to_float+0x28c>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_integer_to_float>:
push   %rax
xor    %edi,%edi
call   1060 <u2f@plt>
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1325 <test_integer_to_float+0x1b5>
jp     1325 <test_integer_to_float+0x1b5>
mov    $0xffffffff,%edi
call   1060 <u2f@plt>
movss  0xe64(%rip),%xmm1
call   1030 <fnear@plt>
test   %eax,%eax
je     1325 <test_integer_to_float+0x1b5>
mov    $0x7fffffff,%edi
call   1060 <u2f@plt>
movss  0xe49(%rip),%xmm1
call   1030 <fnear@plt>
test   %eax,%eax
je     1325 <test_integer_to_float+0x1b5>
mov    $0x80000000,%edi
call   1060 <u2f@plt>
ucomiss 0xe2b(%rip),%xmm0
jne    1325 <test_integer_to_float+0x1b5>
jp     1325 <test_integer_to_float+0x1b5>
xor    %edi,%edi
call   1050 <u2d@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1325 <test_integer_to_float+0x1b5>
jp     1325 <test_integer_to_float+0x1b5>
mov    $0xffffffff,%edi
call   1050 <u2d@plt>
movsd  0xdfe(%rip),%xmm1
call   1080 <dnear@plt>
test   %eax,%eax
je     1325 <test_integer_to_float+0x1b5>
mov    $0x7fffffff,%edi
call   1050 <u2d@plt>
movsd  0xde7(%rip),%xmm1
call   1080 <dnear@plt>
test   %eax,%eax
je     1325 <test_integer_to_float+0x1b5>
mov    $0x80000000,%edi
call   1050 <u2d@plt>
ucomisd 0xdd0(%rip),%xmm0
jne    1325 <test_integer_to_float+0x1b5>
jp     1325 <test_integer_to_float+0x1b5>
xor    %edi,%edi
call   1070 <s2f@plt>
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1325 <test_integer_to_float+0x1b5>
jp     1325 <test_integer_to_float+0x1b5>
mov    $0xffffffff,%edi
call   1070 <s2f@plt>
movss  0xd81(%rip),%xmm1
call   1030 <fnear@plt>
test   %eax,%eax
je     1325 <test_integer_to_float+0x1b5>
mov    $0x7fffffff,%edi
call   1070 <s2f@plt>
movss  0xd5e(%rip),%xmm1
call   1030 <fnear@plt>
test   %eax,%eax
je     1325 <test_integer_to_float+0x1b5>
mov    $0x80000000,%edi
call   1070 <s2f@plt>
ucomiss 0xd4c(%rip),%xmm0
jne    1325 <test_integer_to_float+0x1b5>
jp     1325 <test_integer_to_float+0x1b5>
xor    %edi,%edi
call   1090 <s2d@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1325 <test_integer_to_float+0x1b5>
jp     1325 <test_integer_to_float+0x1b5>
mov    $0xffffffff,%edi
call   1090 <s2d@plt>
movsd  0xd3f(%rip),%xmm1
call   1080 <dnear@plt>
test   %eax,%eax
je     1325 <test_integer_to_float+0x1b5>
mov    $0x7fffffff,%edi
call   1090 <s2d@plt>
movsd  0xd14(%rip),%xmm1
call   1080 <dnear@plt>
test   %eax,%eax
je     1325 <test_integer_to_float+0x1b5>
mov    $0x80000000,%edi
call   1090 <s2d@plt>
ucomisd 0xd11(%rip),%xmm0
jne    1325 <test_integer_to_float+0x1b5>
jp     1325 <test_integer_to_float+0x1b5>
pop    %rcx
ret
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
define i32 @test_integer_to_float() {
%1 = alloca i32
%2 = call float @u2f(i32 0)
%3 = fcmp une float %2, 0.000000e+00
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 (...) @abort()
unreachable
6: ; preds = %0
%7 = call float @u2f(i32 -1)
%8 = call i32 @fnear(float %7, float 0x41F0000000000000)
%9 = icmp ne i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = call i32 (...) @abort()
unreachable
12: ; preds = %6
%13 = call float @u2f(i32 2147483647)
%14 = call i32 @fnear(float %13, float 0x41E0000000000000)
%15 = icmp ne i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = call i32 (...) @abort()
unreachable
18: ; preds = %12
%19 = call float @u2f(i32 -2147483648)
%20 = fcmp une float %19, 0x41E0000000000000
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 (...) @abort()
unreachable
23: ; preds = %18
%24 = call double @u2d(i32 0)
%25 = fcmp une double %24, 0.000000e+00
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 (...) @abort()
unreachable
28: ; preds = %23
%29 = call double @u2d(i32 -1)
%30 = call i32 @dnear(double %29, double 0x41EFFFFFFFE00000)
%31 = icmp ne i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %28
%33 = call i32 (...) @abort()
unreachable
34: ; preds = %28
%35 = call double @u2d(i32 2147483647)
%36 = call i32 @dnear(double %35, double 0x41DFFFFFFFC00000)
%37 = icmp ne i32 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %34
%39 = call i32 (...) @abort()
unreachable
40: ; preds = %34
%41 = call double @u2d(i32 -2147483648)
%42 = fcmp une double %41, 0x41E0000000000000
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 (...) @abort()
unreachable
45: ; preds = %40
%46 = call float @s2f(i32 0)
%47 = fcmp une float %46, 0.000000e+00
br i1 %47, label %48, label %50
48: ; preds = %45
%49 = call i32 (...) @abort()
unreachable
50: ; preds = %45
%51 = call float @s2f(i32 -1)
%52 = call i32 @fnear(float %51, float -1.000000e+00)
%53 = icmp ne i32 %52, 0
br i1 %53, label %56, label %54
54: ; preds = %50
%55 = call i32 (...) @abort()
unreachable
56: ; preds = %50
%57 = call float @s2f(i32 2147483647)
%58 = call i32 @fnear(float %57, float 0x41E0000000000000)
%59 = icmp ne i32 %58, 0
br i1 %59, label %62, label %60
60: ; preds = %56
%61 = call i32 (...) @abort()
unreachable
62: ; preds = %56
%63 = call float @s2f(i32 -2147483648)
%64 = fcmp une float %63, 0xC1E0000000000000
br i1 %64, label %65, label %67
65: ; preds = %62
%66 = call i32 (...) @abort()
unreachable
67: ; preds = %62
%68 = call double @s2d(i32 0)
%69 = fcmp une double %68, 0.000000e+00
br i1 %69, label %70, label %72
70: ; preds = %67
%71 = call i32 (...) @abort()
unreachable
72: ; preds = %67
%73 = call double @s2d(i32 -1)
%74 = call i32 @dnear(double %73, double -1.000000e+00)
%75 = icmp ne i32 %74, 0
br i1 %75, label %78, label %76
76: ; preds = %72
%77 = call i32 (...) @abort()
unreachable
78: ; preds = %72
%79 = call double @s2d(i32 2147483647)
%80 = call i32 @dnear(double %79, double 0x41DFFFFFFFC00000)
%81 = icmp ne i32 %80, 0
br i1 %81, label %84, label %82
82: ; preds = %78
%83 = call i32 (...) @abort()
unreachable
84: ; preds = %78
%85 = call double @s2d(i32 -2147483648)
%86 = fcmp une double %85, 0xC1E0000000000000
br i1 %86, label %87, label %89
87: ; preds = %84
%88 = call i32 (...) @abort()
unreachable
89: ; preds = %84
%90 = load i32, i32* %1
ret i32 %90
}

LLVM IR (-O2):
define i32 @test_integer_to_float() {
%1 = tail call float @u2f(i32 0)
%2 = fcmp une float %1, 0.000000e+00
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 (...) @abort()
unreachable
5: ; preds = %0
%6 = tail call float @u2f(i32 -1)
%7 = tail call i32 @fnear(float %6, float 0x41F0000000000000)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i32 (...) @abort()
unreachable
11: ; preds = %5
%12 = tail call float @u2f(i32 2147483647)
%13 = tail call i32 @fnear(float %12, float 0x41E0000000000000)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = tail call i32 (...) @abort()
unreachable
17: ; preds = %11
%18 = tail call float @u2f(i32 -2147483648)
%19 = fcmp une float %18, 0x41E0000000000000
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = tail call i32 (...) @abort()
unreachable
22: ; preds = %17
%23 = tail call double @u2d(i32 0)
%24 = fcmp une double %23, 0.000000e+00
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = tail call i32 (...) @abort()
unreachable
27: ; preds = %22
%28 = tail call double @u2d(i32 -1)
%29 = tail call i32 @dnear(double %28, double 0x41EFFFFFFFE00000)
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = tail call i32 (...) @abort()
unreachable
33: ; preds = %27
%34 = tail call double @u2d(i32 2147483647)
%35 = tail call i32 @dnear(double %34, double 0x41DFFFFFFFC00000)
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = tail call i32 (...) @abort()
unreachable
39: ; preds = %33
%40 = tail call double @u2d(i32 -2147483648)
%41 = fcmp une double %40, 0x41E0000000000000
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = tail call i32 (...) @abort()
unreachable
44: ; preds = %39
%45 = tail call float @s2f(i32 0)
%46 = fcmp une float %45, 0.000000e+00
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = tail call i32 (...) @abort()
unreachable
49: ; preds = %44
%50 = tail call float @s2f(i32 -1)
%51 = tail call i32 @fnear(float %50, float -1.000000e+00)
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %49
%54 = tail call i32 (...) @abort()
unreachable
55: ; preds = %49
%56 = tail call float @s2f(i32 2147483647)
%57 = tail call i32 @fnear(float %56, float 0x41E0000000000000)
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = tail call i32 (...) @abort()
unreachable
61: ; preds = %55
%62 = tail call float @s2f(i32 -2147483648)
%63 = fcmp une float %62, 0xC1E0000000000000
br i1 %63, label %64, label %66
64: ; preds = %61
%65 = tail call i32 (...) @abort()
unreachable
66: ; preds = %61
%67 = tail call double @s2d(i32 0)
%68 = fcmp une double %67, 0.000000e+00
br i1 %68, label %69, label %71
69: ; preds = %66
%70 = tail call i32 (...) @abort()
unreachable
71: ; preds = %66
%72 = tail call double @s2d(i32 -1)
%73 = tail call i32 @dnear(double %72, double -1.000000e+00)
%74 = icmp eq i32 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %71
%76 = tail call i32 (...) @abort()
unreachable
77: ; preds = %71
%78 = tail call double @s2d(i32 2147483647)
%79 = tail call i32 @dnear(double %78, double 0x41DFFFFFFFC00000)
%80 = icmp eq i32 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %77
%82 = tail call i32 (...) @abort()
unreachable
83: ; preds = %77
%84 = tail call double @s2d(i32 -2147483648)
%85 = fcmp une double %84, 0xC1E0000000000000
br i1 %85, label %86, label %88
86: ; preds = %83
%87 = tail call i32 (...) @abort()
unreachable
88: ; preds = %83
ret i32 undef
}