#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*/ abort();
double fabs(double);
int /*<<< orphan*/ printf(char *, char *, ...);
void assert_range(double exp, double act, char *str) {
  double diff = fabs(exp - act);
  if (diff > 0.000001f) {
    printf("FAIL: %s diff exp=%f act=%f is over %f\n", str, exp, act,
           0.000001f);
    abort();
  } else {
    printf("PASS: %s\n", str);
  }
}


x86 assembly (clang, -O0):
<assert_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movaps 0xec9(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xea3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1192 <assert_range+0x72>
mov    -0x18(%rbp),%rsi
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    0xea4(%rip),%rdi
movsd  0xe7c(%rip),%xmm2
mov    $0x3,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x18(%rbp),%rsi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assert_range>:
push   %rax
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
andpd  0xecf(%rip),%xmm2
mov    %rdi,%rsi
ucomisd 0xed4(%rip),%xmm2
ja     114d <assert_range+0x2d>
lea    0xefb(%rip),%rdi
xor    %eax,%eax
pop    %rcx
jmp    1040 <printf@plt>
lea    0xec4(%rip),%rdi
movsd  0xeb4(%rip),%xmm2
mov    $0x3,%al
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [40 x i8] c"FAIL: %s diff exp=%f act=%f is over %f\0A\00"
@.str.1 = [10 x i8] c"PASS: %s\0A\00"
define void @assert_range(double %0, double %1, i8* %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca i8*
%7 = alloca double
store double %0, double* %4
store double %1, double* %5
store i8* %2, i8** %6
%8 = load double, double* %4
%9 = load double, double* %5
%10 = fsub double %8, %9
%11 = call double @llvm.fabs.f64(double %10)
store double %11, double* %7
%12 = load double, double* %7
%13 = fcmp ogt double %12, 0x3EB0C6F7A0000000
br i1 %13, label %14, label %20
14: ; preds = %3
%15 = load i8*, i8** %6
%16 = load double, double* %4
%17 = load double, double* %5
%18 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %15, double %16, double %17, double 0x3EB0C6F7A0000000)
%19 = call i32 (...) @abort()
unreachable
20: ; preds = %3
%21 = load i8*, i8** %6
%22 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %20
ret void
}

LLVM IR (-O2):
@.str = [40 x i8] c"FAIL: %s diff exp=%f act=%f is over %f\0A\00"
@.str.1 = [10 x i8] c"PASS: %s\0A\00"
define void @assert_range(double %0, double %1, i8* %2) {
%4 = fsub double %0, %1
%5 = tail call double @llvm.fabs.f64(double %4)
%6 = fcmp ogt double %5, 0x3EB0C6F7A0000000
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %2, double %0, double %1, double 0x3EB0C6F7A0000000)
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %3
%11 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret void
}