#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);
double lw6sys_dmax(double, double);
int lw6mat_is_similar_d(double d_a, double d_b) {
  double diff = fabs(d_a - d_b);
  double scale = lw6sys_dmax(fabs(d_a), fabs(d_b));
  return (scale <= 0.0000001f) ? 1 : ((diff / scale) <= 0.00001f);
}


x86 assembly (clang, -O0):
<lw6mat_is_similar_d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movaps 0xedd(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movaps 0xec8(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
movaps 0xeb8(%rip),%xmm2
pand   %xmm2,%xmm1
call   1030 <lw6sys_dmax@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xe92(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     1186 <lw6mat_is_similar_d+0x76>
mov    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a7 <lw6mat_is_similar_d+0x97>
movsd  -0x18(%rbp),%xmm1
divsd  -0x20(%rbp),%xmm1
movsd  0xe70(%rip),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lw6mat_is_similar_d>:
sub    $0x28,%rsp
movapd %xmm1,%xmm2
movapd 0xee0(%rip),%xmm1
movapd %xmm0,0x10(%rsp)
andpd  %xmm1,%xmm0
movapd %xmm2,(%rsp)
andpd  %xmm2,%xmm1
call   1030 <lw6sys_dmax@plt>
mov    $0x1,%eax
movsd  0xecb(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    1173 <lw6mat_is_similar_d+0x63>
movapd 0x10(%rsp),%xmm1
subsd  (%rsp),%xmm1
andpd  0xea2(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0xeae(%rip),%xmm0
xor    %eax,%eax
ucomisd %xmm1,%xmm0
setae  %al
add    $0x28,%rsp
ret

LLVM IR (-O0):
define i32 @lw6mat_is_similar_d(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %3
store double %1, double* %4
%7 = load double, double* %3
%8 = load double, double* %4
%9 = fsub double %7, %8
%10 = call double @llvm.fabs.f64(double %9)
store double %10, double* %5
%11 = load double, double* %3
%12 = call double @llvm.fabs.f64(double %11)
%13 = load double, double* %4
%14 = call double @llvm.fabs.f64(double %13)
%15 = call double @lw6sys_dmax(double %12, double %14)
store double %15, double* %6
%16 = load double, double* %6
%17 = fcmp ole double %16, 0x3E7AD7F2A0000000
br i1 %17, label %18, label %19
18: ; preds = %2
br label %25
19: ; preds = %2
%20 = load double, double* %5
%21 = load double, double* %6
%22 = fdiv double %20, %21
%23 = fcmp ole double %22, 0x3EE4F8B580000000
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %19, %18
%26 = phi i32 [ 1, %18 ], [ %24, %19 ]
ret i32 %26
}

LLVM IR (-O2):
define i32 @lw6mat_is_similar_d(double %0, double %1) {
%3 = tail call double @llvm.fabs.f64(double %0)
%4 = tail call double @llvm.fabs.f64(double %1)
%5 = tail call double @lw6sys_dmax(double %3, double %4)
%6 = fcmp ugt double %5, 0x3E7AD7F2A0000000
br i1 %6, label %7, label %13
7: ; preds = %2
%8 = fsub double %0, %1
%9 = tail call double @llvm.fabs.f64(double %8)
%10 = fdiv double %9, %5
%11 = fcmp ole double %10, 0x3EE4F8B580000000
%12 = zext i1 %11 to i32
br label %13
13: ; preds = %2, %7
%14 = phi i32 [ %12, %7 ], [ 1, %2 ]
ret i32 %14
}