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


x86 assembly (clang, -O0):
<compare_max>:
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)
mov    %rdx,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movsd  -0x8(%rbp),%xmm0
movaps 0xebb(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1178 <compare_max+0x68>
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
movaps 0xe96(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    11d6 <compare_max+0xc6>
movsd  -0x10(%rbp),%xmm0
movaps 0xe7c(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11b7 <compare_max+0xa7>
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movaps 0xe57(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    11d1 <compare_max+0xc1>
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movaps 0xe38(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    11d6 <compare_max+0xc6>
movsd  -0x40(%rbp),%xmm0
mov    -0x30(%rbp),%rax
ucomisd (%rax),%xmm0
jbe    11f6 <compare_max+0xe6>
movsd  -0x40(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1241 <compare_max+0x131>
cmpl   $0x0,-0x1c(%rbp)
je     1238 <compare_max+0x128>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
lea    0xddd(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

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

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

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