#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 */
double INFINITY;
double NAN;
scalar_t__ isinf(double volatile);
scalar_t__ isnan(double);
int printf(char *, ...);
int test_constants(void) {
  int errs = 0;
  volatile double x = 1.0;
  volatile double y = 0.0;
  errs +=
      isnan(NAN)
          ? 0
          : (printf("ERROR %s(%f) != NaN at %d\n", "NAN", (double)NAN, 42), 1);
  printf("Print out of NaN: %f\n", NAN);
  errs += isinf(INFINITY)
              ? 0
              : (printf("ERROR %f != Inf at %d\n", (double)INFINITY, 44), 1);
  printf("Print out of Infinity: %f\n", INFINITY);
  errs += isinf(x / y)
              ? 0
              : (printf("ERROR %f != Inf at %d\n", (double)x / y, 46), 1);
  return errs;
}


x86 assembly (clang, -O0):
<test_constants>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xeb9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    0x2e9d(%rip),%rax
movsd  (%rax),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     1178 <test_constants+0x48>
xor    %eax,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a5 <test_constants+0x75>
mov    0x2e79(%rip),%rax
movsd  (%rax),%xmm0
lea    0xe7e(%rip),%rdi
lea    0xe92(%rip),%rsi
mov    $0x2a,%edx
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    0x2e43(%rip),%rax
movsd  (%rax),%xmm0
lea    0xe67(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x2e12(%rip),%rax
movsd  (%rax),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
je     11eb <test_constants+0xbb>
xor    %eax,%eax
mov    %eax,-0x20(%rbp)
jmp    1211 <test_constants+0xe1>
mov    0x2dee(%rip),%rax
movsd  (%rax),%xmm0
lea    0xe40(%rip),%rdi
mov    $0x2c,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    0x2dbf(%rip),%rax
movsd  (%rax),%xmm0
lea    0xe28(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
je     125a <test_constants+0x12a>
xor    %eax,%eax
mov    %eax,-0x24(%rbp)
jmp    1283 <test_constants+0x153>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xdce(%rip),%rdi
mov    $0x2e,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_constants>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movabs $0x3ff0000000000000,%rax
mov    %rax,0x8(%rsp)
movq   $0x0,(%rsp)
mov    0x2ea2(%rip),%rbp
movsd  0x0(%rbp),%xmm0
call   1040 <isnan@plt>
xor    %ebx,%ebx
mov    $0x0,%r14d
test   %rax,%rax
jne    1192 <test_constants+0x62>
movsd  0x0(%rbp),%xmm0
lea    0xe87(%rip),%rdi
lea    0xe9b(%rip),%rsi
mov    $0x2a,%edx
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x1,%r14d
movsd  0x0(%rbp),%xmm0
lea    0xe81(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x2e34(%rip),%rbp
movsd  0x0(%rbp),%xmm0
call   1050 <isinf@plt>
test   %rax,%rax
jne    11d8 <test_constants+0xa8>
movsd  0x0(%rbp),%xmm0
lea    0xe6e(%rip),%rdi
mov    $0x2c,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x1,%ebx
movsd  0x0(%rbp),%xmm0
lea    0xe68(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm0
divsd  (%rsp),%xmm0
call   1050 <isinf@plt>
xor    %ecx,%ecx
test   %rax,%rax
jne    1225 <test_constants+0xf5>
movsd  0x8(%rsp),%xmm0
divsd  (%rsp),%xmm0
lea    0xe21(%rip),%rdi
mov    $0x2e,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x1,%ecx
add    %r14d,%ebx
add    %ecx,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@NAN = global double 0.000000e+00
@.str = [27 x i8] c"ERROR %s(%f) != NaN at %d\0A\00"
@.str.1 = [4 x i8] c"NAN\00"
@.str.2 = [22 x i8] c"Print out of NaN: %f\0A\00"
@INFINITY = global double 0.000000e+00
@.str.3 = [23 x i8] c"ERROR %f != Inf at %d\0A\00"
@.str.4 = [27 x i8] c"Print out of Infinity: %f\0A\00"
define i32 @test_constants() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
store i32 0, i32* %1
store volatile double 1.000000e+00, double* %2
store volatile double 0.000000e+00, double* %3
%4 = load double, double* @NAN
%5 = call i64 @isnan(double %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %0
br label %11
8: ; preds = %0
%9 = load double, double* @NAN
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %9, i32 42)
br label %11
11: ; preds = %8, %7
%12 = phi i32 [ 0, %7 ], [ 1, %8 ]
%13 = load i32, i32* %1
%14 = add nsw i32 %13, %12
store i32 %14, i32* %1
%15 = load double, double* @NAN
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), double %15)
%17 = load double, double* @INFINITY
%18 = call i64 @isinf(double %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %11
br label %24
21: ; preds = %11
%22 = load double, double* @INFINITY
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), double %22, i32 44)
br label %24
24: ; preds = %21, %20
%25 = phi i32 [ 0, %20 ], [ 1, %21 ]
%26 = load i32, i32* %1
%27 = add nsw i32 %26, %25
store i32 %27, i32* %1
%28 = load double, double* @INFINITY
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %28)
%30 = load volatile double, double* %2
%31 = load volatile double, double* %3
%32 = fdiv double %30, %31
%33 = call i64 @isinf(double %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %24
br label %41
36: ; preds = %24
%37 = load volatile double, double* %2
%38 = load volatile double, double* %3
%39 = fdiv double %37, %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), double %39, i32 46)
br label %41
41: ; preds = %36, %35
%42 = phi i32 [ 0, %35 ], [ 1, %36 ]
%43 = load i32, i32* %1
%44 = add nsw i32 %43, %42
store i32 %44, i32* %1
%45 = load i32, i32* %1
ret i32 %45
}

LLVM IR (-O2):
@NAN = global double 0.000000e+00
@.str = [27 x i8] c"ERROR %s(%f) != NaN at %d\0A\00"
@.str.1 = [4 x i8] c"NAN\00"
@.str.2 = [22 x i8] c"Print out of NaN: %f\0A\00"
@INFINITY = global double 0.000000e+00
@.str.3 = [23 x i8] c"ERROR %f != Inf at %d\0A\00"
@.str.4 = [27 x i8] c"Print out of Infinity: %f\0A\00"
define i32 @test_constants() {
%1 = alloca double
%2 = alloca double
%3 = bitcast double* %1 to i8*
store volatile double 1.000000e+00, double* %1
%4 = bitcast double* %2 to i8*
store volatile double 0.000000e+00, double* %2
%5 = load double, double* @NAN
%6 = tail call i64 @isnan(double %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = load double, double* @NAN
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %9, i32 42)
br label %11
11: ; preds = %0, %8
%12 = phi i32 [ 1, %8 ], [ 0, %0 ]
%13 = load double, double* @NAN
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), double %13)
%15 = load double, double* @INFINITY
%16 = tail call i64 @isinf(double %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %11
%19 = load double, double* @INFINITY
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), double %19, i32 44)
br label %21
21: ; preds = %11, %18
%22 = phi i32 [ 1, %18 ], [ 0, %11 ]
%23 = load double, double* @INFINITY
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %23)
%25 = load volatile double, double* %1
%26 = load volatile double, double* %2
%27 = fdiv double %25, %26
%28 = tail call i64 @isinf(double %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %21
%31 = load volatile double, double* %1
%32 = load volatile double, double* %2
%33 = fdiv double %31, %32
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), double %33, i32 46)
br label %35
35: ; preds = %21, %30
%36 = phi i32 [ 1, %30 ], [ 0, %21 ]
%37 = add nuw nsw i32 %22, %12
%38 = add nuw nsw i32 %37, %36
ret i32 %38
}