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


x86 assembly (clang, -O0):
<test_constants>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eb2(%rip),%rax
movsd  (%rax),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     1163 <test_constants+0x33>
xor    %eax,%eax
mov    %eax,-0x8(%rbp)
jmp    1190 <test_constants+0x60>
mov    0x2e8e(%rip),%rax
movsd  (%rax),%xmm0
lea    0xe93(%rip),%rdi
lea    0xea7(%rip),%rsi
mov    $0x27,%edx
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    0x2e58(%rip),%rax
movsd  (%rax),%xmm0
lea    0xe7c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x2e27(%rip),%rax
movsd  (%rax),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
je     11d6 <test_constants+0xa6>
xor    %eax,%eax
mov    %eax,-0xc(%rbp)
jmp    11fc <test_constants+0xcc>
mov    0x2e03(%rip),%rax
movsd  (%rax),%xmm0
lea    0xe55(%rip),%rdi
mov    $0x29,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    0x2dd4(%rip),%rax
movsd  (%rax),%xmm0
lea    0xe3d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xdda(%rip),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
je     123f <test_constants+0x10f>
xor    %eax,%eax
mov    %eax,-0x10(%rbp)
jmp    1262 <test_constants+0x132>
lea    0xdf7(%rip),%rdi
movsd  0xdb2(%rip),%xmm0
mov    $0x2b,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_constants>:
push   %rbp
push   %r14
push   %rbx
mov    0x2ebd(%rip),%rbp
movsd  0x0(%rbp),%xmm0
call   1040 <isnan@plt>
xor    %ebx,%ebx
mov    $0x0,%r14d
test   %rax,%rax
jne    1177 <test_constants+0x47>
movsd  0x0(%rbp),%xmm0
lea    0xeaa(%rip),%rdi
lea    0xebe(%rip),%rsi
mov    $0x27,%edx
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x1,%r14d
movsd  0x0(%rbp),%xmm0
lea    0xea4(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x2e4f(%rip),%rbp
movsd  0x0(%rbp),%xmm0
call   1050 <isinf@plt>
test   %rax,%rax
jne    11bd <test_constants+0x8d>
movsd  0x0(%rbp),%xmm0
lea    0xe91(%rip),%rdi
mov    $0x29,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x1,%ebx
movsd  0x0(%rbp),%xmm0
lea    0xe8b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xe28(%rip),%xmm0
call   1050 <isinf@plt>
xor    %ecx,%ecx
test   %rax,%rax
jne    1204 <test_constants+0xd4>
lea    0xe52(%rip),%rdi
movsd  0xe0d(%rip),%xmm0
mov    $0x2b,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x1,%ecx
add    %r14d,%ebx
add    %ecx,%ebx
mov    %ebx,%eax
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
store i32 0, i32* %1
%2 = load double, double* @NAN
%3 = call i64 @isnan(double %2)
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %0
br label %9
6: ; preds = %0
%7 = load double, double* @NAN
%8 = 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 %7, i32 39)
br label %9
9: ; preds = %6, %5
%10 = phi i32 [ 0, %5 ], [ 1, %6 ]
%11 = load i32, i32* %1
%12 = add nsw i32 %11, %10
store i32 %12, i32* %1
%13 = load double, double* @NAN
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), double %13)
%15 = load double, double* @INFINITY
%16 = call i64 @isinf(double %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %9
br label %22
19: ; preds = %9
%20 = load double, double* @INFINITY
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), double %20, i32 41)
br label %22
22: ; preds = %19, %18
%23 = phi i32 [ 0, %18 ], [ 1, %19 ]
%24 = load i32, i32* %1
%25 = add nsw i32 %24, %23
store i32 %25, i32* %1
%26 = load double, double* @INFINITY
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %26)
%28 = call i64 @isinf(double 0x7FF0000000000000)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %22
br label %33
31: ; preds = %22
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), double 0x7FF0000000000000, i32 43)
br label %33
33: ; preds = %31, %30
%34 = phi i32 [ 0, %30 ], [ 1, %31 ]
%35 = load i32, i32* %1
%36 = add nsw i32 %35, %34
store i32 %36, i32* %1
%37 = load i32, i32* %1
ret i32 %37
}

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 = load double, double* @NAN
%2 = tail call i64 @isnan(double %1)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = load double, double* @NAN
%6 = 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 %5, i32 39)
br label %7
7: ; preds = %0, %4
%8 = phi i32 [ 1, %4 ], [ 0, %0 ]
%9 = load double, double* @NAN
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), double %9)
%11 = load double, double* @INFINITY
%12 = tail call i64 @isinf(double %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %7
%15 = load double, double* @INFINITY
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), double %15, i32 41)
br label %17
17: ; preds = %7, %14
%18 = phi i32 [ 1, %14 ], [ 0, %7 ]
%19 = load double, double* @INFINITY
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %19)
%21 = tail call i64 @isinf(double 0x7FF0000000000000)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), double 0x7FF0000000000000, i32 43)
br label %25
25: ; preds = %17, %23
%26 = phi i32 [ 1, %23 ], [ 0, %17 ]
%27 = add nuw nsw i32 %18, %8
%28 = add nuw nsw i32 %27, %26
ret i32 %28
}