#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 */
float INFINITY;
float NAN;
int add_and_test(float, float);
int /*<<< orphan*/ printf(char *, int);
int sub_and_test(float, float);
int main() {
  float a = INFINITY;
  float b = INFINITY;
  float aNan = NAN;
  float bNan = NAN;
  float negZero = -0.0;
  float zeroExp = 0.0E126;
  printf("Inf + Inf == Inf ? %d\n", add_and_test(a, b));
  printf("Inf + small number == Inf ? %d\n", add_and_test(a, 0.0000000001));
  printf("5.0 + -0.0 == 5.0 ? %d\n", add_and_test(5.0, negZero));
  printf("Inf - Inf == Inf ? %d\n", sub_and_test(a, b));
  printf("Inf - Inf == 0 ? %d\n", (a - b) == 0.0);
  printf("Inf - Inf == %f\n", a - b);
  printf("nan + nan == nan ? %d\n", add_and_test(aNan, bNan));
  printf("0.0 == -0.0 ? %d\n", 0.0 == -0.0);
  printf("0.0 == -0.0 ? %d\n", 0.0 == zeroExp);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2ea1(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x4(%rbp)
mov    0x2e91(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x8(%rbp)
mov    0x2e99(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    0x2e89(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xe88(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
call   1040 <add_and_test@plt>
mov    %eax,%esi
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
movss  -0x4(%rbp),%xmm0
movss  0xe4d(%rip),%xmm1
call   1040 <add_and_test@plt>
mov    %eax,%esi
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
movss  -0x14(%rbp),%xmm1
movss  0xe29(%rip),%xmm0
call   1040 <add_and_test@plt>
mov    %eax,%esi
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
call   1050 <sub_and_test@plt>
mov    %eax,%esi
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
movss  -0x4(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%esi
lea    0xe42(%rip),%rdi
call   1030 <printf@plt>
movss  -0x4(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
cvttss2si %xmm0,%esi
lea    0xe3d(%rip),%rdi
call   1030 <printf@plt>
movss  -0xc(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
call   1040 <add_and_test@plt>
mov    %eax,%esi
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
lea    0xe3c(%rip),%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%esi
lea    0xe0e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    0x2ea4(%rip),%rax
movss  (%rax),%xmm1
movss  %xmm1,0x8(%rsp)
mov    0x2eab(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,0xc(%rsp)
movaps %xmm1,%xmm0
call   1040 <add_and_test@plt>
lea    0xea6(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
movss  0xe8b(%rip),%xmm1
movss  0x8(%rsp),%xmm0
call   1040 <add_and_test@plt>
lea    0xe9c(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
movss  0xe6e(%rip),%xmm0
movss  0xe6a(%rip),%xmm1
call   1040 <add_and_test@plt>
lea    0xe99(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
movss  0x8(%rsp),%xmm0
movaps %xmm0,%xmm1
call   1050 <sub_and_test@plt>
lea    0xe95(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
movss  0x8(%rsp),%xmm1
subss  %xmm1,%xmm1
movss  %xmm1,0x8(%rsp)
xorps  %xmm0,%xmm0
cmpeqss %xmm1,%xmm0
movd   %xmm0,%esi
and    $0x1,%esi
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
cvttss2si 0x8(%rsp),%esi
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
movss  0xc(%rsp),%xmm0
movaps %xmm0,%xmm1
call   1040 <add_and_test@plt>
lea    0xe79(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xe82(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@INFINITY = global float 0.000000e+00
@NAN = global float 0.000000e+00
@.str = [23 x i8] c"Inf + Inf == Inf ? %d\0A\00"
@.str.1 = [32 x i8] c"Inf + small number == Inf ? %d\0A\00"
@.str.2 = [24 x i8] c"5.0 + -0.0 == 5.0 ? %d\0A\00"
@.str.3 = [23 x i8] c"Inf - Inf == Inf ? %d\0A\00"
@.str.4 = [21 x i8] c"Inf - Inf == 0 ? %d\0A\00"
@.str.5 = [17 x i8] c"Inf - Inf == %f\0A\00"
@.str.6 = [23 x i8] c"nan + nan == nan ? %d\0A\00"
@.str.7 = [18 x i8] c"0.0 == -0.0 ? %d\0A\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = load float, float* @INFINITY
store float %7, float* %1
%8 = load float, float* @INFINITY
store float %8, float* %2
%9 = load float, float* @NAN
store float %9, float* %3
%10 = load float, float* @NAN
store float %10, float* %4
store float -0.000000e+00, float* %5
store float 0.000000e+00, float* %6
%11 = load float, float* %1
%12 = load float, float* %2
%13 = call i32 @add_and_test(float %11, float %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load float, float* %1
%16 = call i32 @add_and_test(float %15, float 0x3DDB7CDFE0000000)
%17 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load float, float* %5
%19 = call i32 @add_and_test(float 5.000000e+00, float %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = load float, float* %1
%22 = load float, float* %2
%23 = call i32 @sub_and_test(float %21, float %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = load float, float* %1
%26 = load float, float* %2
%27 = fsub float %25, %26
%28 = fpext float %27 to double
%29 = fcmp oeq double %28, 0.000000e+00
%30 = zext i1 %29 to i32
%31 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%32 = load float, float* %1
%33 = load float, float* %2
%34 = fsub float %32, %33
%35 = fptosi float %34 to i32
%36 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %35)
%37 = load float, float* %3
%38 = load float, float* %4
%39 = call i32 @add_and_test(float %37, float %38)
%40 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %39)
%41 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 1)
%42 = load float, float* %6
%43 = fpext float %42 to double
%44 = fcmp oeq double 0.000000e+00, %43
%45 = zext i1 %44 to i32
%46 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 %45)
ret i32 0
}

LLVM IR (-O2):
@INFINITY = global float 0.000000e+00
@NAN = global float 0.000000e+00
@.str = [23 x i8] c"Inf + Inf == Inf ? %d\0A\00"
@.str.1 = [32 x i8] c"Inf + small number == Inf ? %d\0A\00"
@.str.2 = [24 x i8] c"5.0 + -0.0 == 5.0 ? %d\0A\00"
@.str.3 = [23 x i8] c"Inf - Inf == Inf ? %d\0A\00"
@.str.4 = [21 x i8] c"Inf - Inf == 0 ? %d\0A\00"
@.str.5 = [17 x i8] c"Inf - Inf == %f\0A\00"
@.str.6 = [23 x i8] c"nan + nan == nan ? %d\0A\00"
@.str.7 = [18 x i8] c"0.0 == -0.0 ? %d\0A\00"
define i32 @main() {
%1 = load float, float* @INFINITY
%2 = load float, float* @NAN
%3 = tail call i32 @add_and_test(float %1, float %1)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 @add_and_test(float %1, float 0x3DDB7CDFE0000000)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = tail call i32 @add_and_test(float 5.000000e+00, float -0.000000e+00)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = tail call i32 @sub_and_test(float %1, float %1)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%11 = fsub float %1, %1
%12 = fcmp oeq float %11, 0.000000e+00
%13 = zext i1 %12 to i32
%14 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %13)
%15 = fptosi float %11 to i32
%16 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %15)
%17 = tail call i32 @add_and_test(float %2, float %2)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %17)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 1)
%20 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 1)
ret i32 0
}