#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 fabs(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, double, double,
                           double);
int /*<<< orphan*/ stdout;
int compare(double x, double y, char *label, int verbose, double tiny) {
  int check = 0;
  double d;
  if (fabs(x) > tiny) {
    d = fabs((x - y) / x);
  } else if (fabs(y) > tiny) {
    d = fabs((x - y) / y);
  } else {
    d = fabs(x - y);
  }
  if (d > tiny) {
    if (verbose != 0) {
      fprintf(stdout, "%s %e %e %e\n", label, x, y, d);
    }
    check++;
  }
  return (check);
}


x86 assembly (clang, -O0):
<compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
movsd  %xmm2,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movsd  -0x8(%rbp),%xmm0
movaps 0xebf(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1174 <compare+0x64>
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
movaps 0xe9a(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11d2 <compare+0xc2>
movsd  -0x10(%rbp),%xmm0
movaps 0xe80(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11b3 <compare+0xa3>
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movaps 0xe5b(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11cd <compare+0xbd>
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movaps 0xe3c(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11d2 <compare+0xc2>
movsd  -0x38(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    121d <compare+0x10d>
cmpl   $0x0,-0x1c(%rbp)
je     1214 <compare+0x104>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
lea    0xe01(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare>:
push   %rbx
movapd %xmm2,%xmm3
mov    %rdi,%rdx
movapd 0xee0(%rip),%xmm2
andpd  %xmm0,%xmm2
ucomisd %xmm3,%xmm2
jbe    1138 <compare+0x28>
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
divsd  %xmm0,%xmm2
jmp    1156 <compare+0x46>
movapd 0xec0(%rip),%xmm2
andpd  %xmm1,%xmm2
ucomisd %xmm3,%xmm2
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
jbe    1156 <compare+0x46>
divsd  %xmm1,%xmm2
andpd  0xea2(%rip),%xmm2
xor    %ebx,%ebx
ucomisd %xmm3,%xmm2
jbe    1184 <compare+0x74>
mov    $0x1,%ebx
test   %esi,%esi
je     1184 <compare+0x74>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
call   1030 <fprintf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [13 x i8] c"%s %e %e %e\0A\00"
define i32 @compare(double %0, double %1, i8* %2, i32 %3, double %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca i8*
%9 = alloca i32
%10 = alloca double
%11 = alloca i32
%12 = alloca double
store double %0, double* %6
store double %1, double* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store double %4, double* %10
store i32 0, i32* %11
%13 = load double, double* %6
%14 = call double @llvm.fabs.f64(double %13)
%15 = load double, double* %10
%16 = fcmp ogt double %14, %15
br i1 %16, label %17, label %24
17: ; preds = %5
%18 = load double, double* %6
%19 = load double, double* %7
%20 = fsub double %18, %19
%21 = load double, double* %6
%22 = fdiv double %20, %21
%23 = call double @llvm.fabs.f64(double %22)
store double %23, double* %12
br label %42
24: ; preds = %5
%25 = load double, double* %7
%26 = call double @llvm.fabs.f64(double %25)
%27 = load double, double* %10
%28 = fcmp ogt double %26, %27
br i1 %28, label %29, label %36
29: ; preds = %24
%30 = load double, double* %6
%31 = load double, double* %7
%32 = fsub double %30, %31
%33 = load double, double* %7
%34 = fdiv double %32, %33
%35 = call double @llvm.fabs.f64(double %34)
store double %35, double* %12
br label %41
36: ; preds = %24
%37 = load double, double* %6
%38 = load double, double* %7
%39 = fsub double %37, %38
%40 = call double @llvm.fabs.f64(double %39)
store double %40, double* %12
br label %41
41: ; preds = %36, %29
br label %42
42: ; preds = %41, %17
%43 = load double, double* %12
%44 = load double, double* %10
%45 = fcmp ogt double %43, %44
br i1 %45, label %46, label %59
46: ; preds = %42
%47 = load i32, i32* %9
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %56
49: ; preds = %46
%50 = load i32, i32* @stdout
%51 = load i8*, i8** %8
%52 = load double, double* %6
%53 = load double, double* %7
%54 = load double, double* %12
%55 = call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %51, double %52, double %53, double %54)
br label %56
56: ; preds = %49, %46
%57 = load i32, i32* %11
%58 = add nsw i32 %57, 1
store i32 %58, i32* %11
br label %59
59: ; preds = %56, %42
%60 = load i32, i32* %11
ret i32 %60
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [13 x i8] c"%s %e %e %e\0A\00"
define i32 @compare(double %0, double %1, i8* %2, i32 %3, double %4) {
%6 = tail call double @llvm.fabs.f64(double %0)
%7 = fcmp ogt double %6, %4
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = fsub double %0, %1
%10 = fdiv double %9, %0
br label %17
11: ; preds = %5
%12 = tail call double @llvm.fabs.f64(double %1)
%13 = fcmp ogt double %12, %4
%14 = fsub double %0, %1
br i1 %13, label %15, label %17
15: ; preds = %11
%16 = fdiv double %14, %1
br label %17
17: ; preds = %11, %15, %8
%18 = phi double [ %16, %15 ], [ %10, %8 ], [ %14, %11 ]
%19 = tail call double @llvm.fabs.f64(double %18)
%20 = fcmp ogt double %19, %4
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = icmp eq i32 %3, 0
br i1 %22, label %26, label %23
23: ; preds = %21
%24 = load i32, i32* @stdout
%25 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %2, double %0, double %1, double %19)
br label %26
26: ; preds = %21, %23, %17
%27 = phi i32 [ 0, %17 ], [ 1, %23 ], [ 1, %21 ]
ret i32 %27
}