#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);
double log(int /*<<< orphan*/);
double pow(double, double);
int printf(char *, ...);
double sqrt(double);
int test_defined(void) {
  int errs = 0;
  printf("Checking lib calls that take NaN, etc, but return non-NaN.\n");
  errs += (pow(0.0, 0.0) == 1.0)
              ? 0
              : (printf("ERROR %f != %f at %d\n", pow(0.0, 0.0), 1.0, 92), 1);
  errs += (pow(NAN, 0.0) == 1.0)
              ? 0
              : (printf("ERROR %f != %f at %d\n", pow(NAN, 0.0), 1.0, 93), 1);
  errs +=
      (pow(INFINITY, 0.0) == 1.0)
          ? 0
          : (printf("ERROR %f != %f at %d\n", pow(INFINITY, 0.0), 1.0, 94), 1);
  errs +=
      isinf(sqrt(INFINITY))
          ? 0
          : (printf("ERROR %f != Inf at %d\n", (double)sqrt(INFINITY), 96), 1);
  errs += (sqrt(-0.0) == -0.0)
              ? 0
              : (printf("ERROR %f != %f at %d\n", sqrt(-0.0), -0.0, 97), 1);
  errs +=
      isinf(pow(INFINITY, 2.0))
          ? 0
          : (printf("ERROR %f != Inf at %d\n", (double)pow(INFINITY, 2.0), 98),
             1);
  errs +=
      (log(0) == -INFINITY)
          ? 0
          : (printf("ASSERT true failed! %d at %d\n", log(0) == -INFINITY, 99),
             1);
  return errs;
}


x86 assembly (clang, -O0):
<test_defined>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xorps  %xmm1,%xmm1
movaps %xmm1,%xmm0
call   1050 <pow@plt>
movsd  0xe80(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    119a <test_defined+0x4a>
jp     119a <test_defined+0x4a>
xor    %eax,%eax
mov    %eax,-0x8(%rbp)
jmp    11c8 <test_defined+0x78>
xorps  %xmm1,%xmm1
movaps %xmm1,%xmm0
call   1050 <pow@plt>
lea    0xea8(%rip),%rdi
movsd  0xe4c(%rip),%xmm1
mov    $0x5c,%esi
mov    $0x2,%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    0x2e20(%rip),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
call   1050 <pow@plt>
movsd  0xe14(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1206 <test_defined+0xb6>
jp     1206 <test_defined+0xb6>
xor    %eax,%eax
mov    %eax,-0xc(%rbp)
jmp    123c <test_defined+0xec>
mov    0x2deb(%rip),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
call   1050 <pow@plt>
lea    0xe34(%rip),%rdi
movsd  0xdd8(%rip),%xmm1
mov    $0x5d,%esi
mov    $0x2,%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    0x2d94(%rip),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
call   1050 <pow@plt>
movsd  0xda0(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    127a <test_defined+0x12a>
jp     127a <test_defined+0x12a>
xor    %eax,%eax
mov    %eax,-0x10(%rbp)
jmp    12b0 <test_defined+0x160>
mov    0x2d5f(%rip),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
call   1050 <pow@plt>
lea    0xdc0(%rip),%rdi
movsd  0xd64(%rip),%xmm1
mov    $0x5e,%esi
mov    $0x2,%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    0x2d20(%rip),%rax
movsd  (%rax),%xmm0
call   1060 <sqrt@plt>
call   1070 <isinf@plt>
cmp    $0x0,%rax
je     12e2 <test_defined+0x192>
xor    %eax,%eax
mov    %eax,-0x14(%rbp)
jmp    130d <test_defined+0x1bd>
mov    0x2cf7(%rip),%rax
movsd  (%rax),%xmm0
call   1060 <sqrt@plt>
lea    0xd71(%rip),%rdi
mov    $0x60,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
movsd  0xcea(%rip),%xmm0
call   1060 <sqrt@plt>
movsd  0xcdd(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1345 <test_defined+0x1f5>
jp     1345 <test_defined+0x1f5>
xor    %eax,%eax
mov    %eax,-0x18(%rbp)
jmp    1375 <test_defined+0x225>
movsd  0xcbb(%rip),%xmm0
call   1060 <sqrt@plt>
lea    0xcfb(%rip),%rdi
movsd  0xca7(%rip),%xmm1
mov    $0x61,%esi
mov    $0x2,%al
call   1030 <printf@plt>
mov    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    0x2c5b(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xc7f(%rip),%xmm1
call   1050 <pow@plt>
call   1070 <isinf@plt>
cmp    $0x0,%rax
je     13af <test_defined+0x25f>
xor    %eax,%eax
mov    %eax,-0x1c(%rbp)
jmp    13e2 <test_defined+0x292>
mov    0x2c2a(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xc4e(%rip),%xmm1
call   1050 <pow@plt>
lea    0xc9c(%rip),%rdi
mov    $0x62,%esi
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)
xor    %edi,%edi
call   1040 <log@plt>
mov    0x2be7(%rip),%rax
movsd  (%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
ucomisd %xmm1,%xmm0
jne    142e <test_defined+0x2de>
jp     142e <test_defined+0x2de>
xor    %eax,%eax
mov    %eax,-0x20(%rbp)
jmp    1483 <test_defined+0x333>
xor    %edi,%edi
call   1040 <log@plt>
mov    0x2ba4(%rip),%rax
movsd  (%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%esi
lea    0xc12(%rip),%rdi
mov    $0x63,%edx
mov    $0x0,%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    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_defined>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xf0c(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e7d(%rip),%r14
movsd  (%r14),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1180 <test_defined+0x30>
sqrtsd %xmm0,%xmm0
jmp    1185 <test_defined+0x35>
call   1060 <sqrt@plt>
call   1070 <isinf@plt>
xor    %ebx,%ebx
mov    $0x0,%r15d
test   %rax,%rax
jne    11ca <test_defined+0x7a>
movsd  (%r14),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11ac <test_defined+0x5c>
sqrtsd %xmm0,%xmm0
jmp    11b1 <test_defined+0x61>
call   1060 <sqrt@plt>
lea    0xe7e(%rip),%rdi
mov    $0x60,%esi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x1,%r15d
movsd  0xe2e(%rip),%xmm1
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jne    11e5 <test_defined+0x95>
jnp    11fd <test_defined+0xad>
lea    0xe34(%rip),%rdi
mov    $0x61,%esi
mov    $0x2,%al
call   1040 <printf@plt>
mov    $0x1,%ebx
movsd  (%r14),%xmm0
mulsd  %xmm0,%xmm0
call   1070 <isinf@plt>
xor    %ebp,%ebp
mov    $0x0,%r12d
test   %rax,%rax
jne    123a <test_defined+0xea>
movsd  (%r14),%xmm0
mulsd  %xmm0,%xmm0
lea    0xe0e(%rip),%rdi
mov    $0x62,%esi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x1,%r12d
xor    %edi,%edi
call   1050 <log@plt>
movsd  (%r14),%xmm1
xorpd  0xdc2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1256 <test_defined+0x106>
jnp    128f <test_defined+0x13f>
xor    %edi,%edi
call   1050 <log@plt>
movsd  (%r14),%xmm1
xorpd  0xda6(%rip),%xmm1
cmpeqsd %xmm0,%xmm1
movq   %xmm1,%rsi
and    $0x1,%esi
lea    0xdcf(%rip),%rdi
mov    $0x63,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebp
add    %r15d,%ebx
add    %r12d,%ebx
add    %ebp,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [60 x i8] c"Checking lib calls that take NaN, etc, but return non-NaN.\0A\00"
@.str.1 = [22 x i8] c"ERROR %f != %f at %d\0A\00"
@NAN = global double 0.000000e+00
@INFINITY = global double 0.000000e+00
@.str.2 = [23 x i8] c"ERROR %f != Inf at %d\0A\00"
@.str.3 = [30 x i8] c"ASSERT true failed! %d at %d\0A\00"
define i32 @test_defined() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
%3 = call double @pow(double 0.000000e+00, double 0.000000e+00)
%4 = fcmp oeq double %3, 1.000000e+00
br i1 %4, label %5, label %6
5: ; preds = %0
br label %9
6: ; preds = %0
%7 = call double @pow(double 0.000000e+00, double 0.000000e+00)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %7, double 1.000000e+00, i32 92)
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 double @pow(double %13, double 0.000000e+00)
%15 = fcmp oeq double %14, 1.000000e+00
br i1 %15, label %16, label %17
16: ; preds = %9
br label %21
17: ; preds = %9
%18 = load double, double* @NAN
%19 = call double @pow(double %18, double 0.000000e+00)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %19, double 1.000000e+00, i32 93)
br label %21
21: ; preds = %17, %16
%22 = phi i32 [ 0, %16 ], [ 1, %17 ]
%23 = load i32, i32* %1
%24 = add nsw i32 %23, %22
store i32 %24, i32* %1
%25 = load double, double* @INFINITY
%26 = call double @pow(double %25, double 0.000000e+00)
%27 = fcmp oeq double %26, 1.000000e+00
br i1 %27, label %28, label %29
28: ; preds = %21
br label %33
29: ; preds = %21
%30 = load double, double* @INFINITY
%31 = call double @pow(double %30, double 0.000000e+00)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %31, double 1.000000e+00, i32 94)
br label %33
33: ; preds = %29, %28
%34 = phi i32 [ 0, %28 ], [ 1, %29 ]
%35 = load i32, i32* %1
%36 = add nsw i32 %35, %34
store i32 %36, i32* %1
%37 = load double, double* @INFINITY
%38 = call double @sqrt(double %37)
%39 = call i64 @isinf(double %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %33
br label %46
42: ; preds = %33
%43 = load double, double* @INFINITY
%44 = call double @sqrt(double %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %44, i32 96)
br label %46
46: ; preds = %42, %41
%47 = phi i32 [ 0, %41 ], [ 1, %42 ]
%48 = load i32, i32* %1
%49 = add nsw i32 %48, %47
store i32 %49, i32* %1
%50 = call double @sqrt(double -0.000000e+00)
%51 = fcmp oeq double %50, -0.000000e+00
br i1 %51, label %52, label %53
52: ; preds = %46
br label %56
53: ; preds = %46
%54 = call double @sqrt(double -0.000000e+00)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %54, double -0.000000e+00, i32 97)
br label %56
56: ; preds = %53, %52
%57 = phi i32 [ 0, %52 ], [ 1, %53 ]
%58 = load i32, i32* %1
%59 = add nsw i32 %58, %57
store i32 %59, i32* %1
%60 = load double, double* @INFINITY
%61 = call double @pow(double %60, double 2.000000e+00)
%62 = call i64 @isinf(double %61)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %65
64: ; preds = %56
br label %69
65: ; preds = %56
%66 = load double, double* @INFINITY
%67 = call double @pow(double %66, double 2.000000e+00)
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %67, i32 98)
br label %69
69: ; preds = %65, %64
%70 = phi i32 [ 0, %64 ], [ 1, %65 ]
%71 = load i32, i32* %1
%72 = add nsw i32 %71, %70
store i32 %72, i32* %1
%73 = call double @log(i32 0)
%74 = load double, double* @INFINITY
%75 = fneg double %74
%76 = fcmp oeq double %73, %75
br i1 %76, label %77, label %78
77: ; preds = %69
br label %85
78: ; preds = %69
%79 = call double @log(i32 0)
%80 = load double, double* @INFINITY
%81 = fneg double %80
%82 = fcmp oeq double %79, %81
%83 = zext i1 %82 to i32
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %83, i32 99)
br label %85
85: ; preds = %78, %77
%86 = phi i32 [ 0, %77 ], [ 1, %78 ]
%87 = load i32, i32* %1
%88 = add nsw i32 %87, %86
store i32 %88, i32* %1
%89 = load i32, i32* %1
ret i32 %89
}

LLVM IR (-O2):
@.str.1 = [22 x i8] c"ERROR %f != %f at %d\0A\00"
@NAN = global double 0.000000e+00
@INFINITY = global double 0.000000e+00
@.str.2 = [23 x i8] c"ERROR %f != Inf at %d\0A\00"
@.str.3 = [30 x i8] c"ASSERT true failed! %d at %d\0A\00"
@str = [59 x i8] c"Checking lib calls that take NaN, etc, but return non-NaN.\00"
define i32 @test_defined() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str, i64 0, i64 0))
%2 = load double, double* @INFINITY
%3 = tail call double @sqrt(double %2)
%4 = tail call i64 @isinf(double %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = load double, double* @INFINITY
%8 = tail call double @sqrt(double %7)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %8, i32 96)
br label %10
10: ; preds = %0, %6
%11 = phi i32 [ 1, %6 ], [ 0, %0 ]
%12 = tail call double @sqrt(double -0.000000e+00)
%13 = fcmp oeq double %12, 0.000000e+00
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = tail call double @sqrt(double -0.000000e+00)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %15, double -0.000000e+00, i32 97)
br label %17
17: ; preds = %10, %14
%18 = phi i32 [ 1, %14 ], [ 0, %10 ]
%19 = load double, double* @INFINITY
%20 = fmul double %19, %19
%21 = tail call i64 @isinf(double %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %17
%24 = load double, double* @INFINITY
%25 = fmul double %24, %24
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %25, i32 98)
br label %27
27: ; preds = %17, %23
%28 = phi i32 [ 1, %23 ], [ 0, %17 ]
%29 = tail call double @log(i32 0)
%30 = load double, double* @INFINITY
%31 = fneg double %30
%32 = fcmp oeq double %29, %31
br i1 %32, label %40, label %33
33: ; preds = %27
%34 = tail call double @log(i32 0)
%35 = load double, double* @INFINITY
%36 = fneg double %35
%37 = fcmp oeq double %34, %36
%38 = zext i1 %37 to i32
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %38, i32 99)
br label %40
40: ; preds = %27, %33
%41 = phi i32 [ 1, %33 ], [ 0, %27 ]
%42 = add nuw nsw i32 %18, %11
%43 = add nuw nsw i32 %42, %28
%44 = add nuw nsw i32 %43, %41
ret i32 %44
}