#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*/ fprintf(int /*<<< orphan*/, char *, double, double);
scalar_t__ isnan(double);
int /*<<< orphan*/ stderr;
int check_answer(double computed, double answer, double tol) {
  if (isnan(computed) && isnan(answer)) {
    return 1;
  }
  if (computed < answer + tol && computed > answer - tol) {
    return 1;
  } else {
    fprintf(stderr, "[ERROR] expected %.9g, got %.9g\n", answer, computed);
    return 0;
  }
}


x86 assembly (clang, -O0):
<check_answer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     116b <check_answer+0x4b>
movsd  -0x18(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     116b <check_answer+0x4b>
movl   $0x1,-0x4(%rbp)
jmp    11cf <check_answer+0xaf>
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a9 <check_answer+0x89>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a9 <check_answer+0x89>
movl   $0x1,-0x4(%rbp)
jmp    11cf <check_answer+0xaf>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    0xe3d(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_answer>:
sub    $0x18,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x10(%rsp)
call   1040 <isnan@plt>
movsd  0x10(%rsp),%xmm1
test   %rax,%rax
je     1167 <check_answer+0x47>
movsd  (%rsp),%xmm0
call   1040 <isnan@plt>
movsd  0x10(%rsp),%xmm1
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
je     1167 <check_answer+0x47>
add    $0x18,%rsp
ret
movsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
ucomisd %xmm1,%xmm0
jbe    118e <check_answer+0x6e>
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
mov    $0x1,%eax
ucomisd %xmm0,%xmm1
ja     1162 <check_answer+0x42>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    0xe62(%rip),%rsi
movsd  (%rsp),%xmm0
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"[ERROR] expected %.9g, got %.9g\0A\00"
define i32 @check_answer(double %0, double %1, double %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%8 = load double, double* %5
%9 = call i64 @isnan(double %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %3
%12 = load double, double* %6
%13 = call i64 @isnan(double %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11
store i32 1, i32* %4
br label %34
16: ; preds = %11, %3
%17 = load double, double* %5
%18 = load double, double* %6
%19 = load double, double* %7
%20 = fadd double %18, %19
%21 = fcmp olt double %17, %20
br i1 %21, label %22, label %29
22: ; preds = %16
%23 = load double, double* %5
%24 = load double, double* %6
%25 = load double, double* %7
%26 = fsub double %24, %25
%27 = fcmp ogt double %23, %26
br i1 %27, label %28, label %29
28: ; preds = %22
store i32 1, i32* %4
br label %34
29: ; preds = %22, %16
%30 = load i32, i32* @stderr
%31 = load double, double* %6
%32 = load double, double* %5
%33 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), double %31, double %32)
store i32 0, i32* %4
br label %34
34: ; preds = %29, %28, %15
%35 = load i32, i32* %4
ret i32 %35
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"[ERROR] expected %.9g, got %.9g\0A\00"
define i32 @check_answer(double %0, double %1, double %2) {
%4 = tail call i64 @isnan(double %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call i64 @isnan(double %1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %6, %3
%10 = fadd double %1, %2
%11 = fcmp ogt double %10, %0
%12 = fsub double %1, %2
%13 = fcmp olt double %12, %0
%14 = and i1 %11, %13
br i1 %14, label %18, label %15
15: ; preds = %9
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), double %1, double %0)
br label %18
18: ; preds = %9, %6, %15
%19 = phi i32 [ 0, %15 ], [ 1, %6 ], [ 1, %9 ]
ret i32 %19
}