#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 */
float fabsf(float);
float lw6sys_fmax(float, float);
int lw6mat_is_similar_f(float f_a, float f_b) {
  float diff = fabsf(f_a - f_b);
  float scale = lw6sys_fmax(fabsf(f_a), fabsf(f_b));
  return (scale <= 0.0001f) ? 1 : ((diff / scale) <= 0.001f);
}


x86 assembly (clang, -O0):
<lw6mat_is_similar_f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movaps 0xedd(%rip),%xmm1
pand   %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
movaps 0xec8(%rip),%xmm1
pand   %xmm1,%xmm0
movss  -0x8(%rbp),%xmm1
movaps 0xeb8(%rip),%xmm2
pand   %xmm2,%xmm1
call   1030 <lw6sys_fmax@plt>
movss  %xmm0,-0x10(%rbp)
movss  0xe92(%rip),%xmm0
ucomiss -0x10(%rbp),%xmm0
jb     1185 <lw6mat_is_similar_f+0x75>
mov    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a5 <lw6mat_is_similar_f+0x95>
movss  -0xc(%rbp),%xmm1
divss  -0x10(%rbp),%xmm1
movss  0xe6d(%rip),%xmm0
ucomiss %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lw6mat_is_similar_f>:
sub    $0x28,%rsp
movaps %xmm1,%xmm2
movaps 0xee2(%rip),%xmm1
movaps %xmm0,0x10(%rsp)
andps  %xmm1,%xmm0
movaps %xmm2,(%rsp)
andps  %xmm2,%xmm1
call   1030 <lw6sys_fmax@plt>
mov    $0x1,%eax
movss  0xed1(%rip),%xmm1
ucomiss %xmm0,%xmm1
jae    1169 <lw6mat_is_similar_f+0x59>
movaps 0x10(%rsp),%xmm1
subss  (%rsp),%xmm1
andps  0xeab(%rip),%xmm1
divss  %xmm0,%xmm1
movss  0xeb3(%rip),%xmm0
xor    %eax,%eax
ucomiss %xmm1,%xmm0
setae  %al
add    $0x28,%rsp
ret

LLVM IR (-O0):
define i32 @lw6mat_is_similar_f(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
store float %0, float* %3
store float %1, float* %4
%7 = load float, float* %3
%8 = load float, float* %4
%9 = fsub float %7, %8
%10 = call float @llvm.fabs.f32(float %9)
store float %10, float* %5
%11 = load float, float* %3
%12 = call float @llvm.fabs.f32(float %11)
%13 = load float, float* %4
%14 = call float @llvm.fabs.f32(float %13)
%15 = call float @lw6sys_fmax(float %12, float %14)
store float %15, float* %6
%16 = load float, float* %6
%17 = fcmp ole float %16, 0x3F1A36E2E0000000
br i1 %17, label %18, label %19
18: ; preds = %2
br label %25
19: ; preds = %2
%20 = load float, float* %5
%21 = load float, float* %6
%22 = fdiv float %20, %21
%23 = fcmp ole float %22, 0x3F50624DE0000000
%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_f(float %0, float %1) {
%3 = tail call float @llvm.fabs.f32(float %0)
%4 = tail call float @llvm.fabs.f32(float %1)
%5 = tail call float @lw6sys_fmax(float %3, float %4)
%6 = fcmp ugt float %5, 0x3F1A36E2E0000000
br i1 %6, label %7, label %13
7: ; preds = %2
%8 = fsub float %0, %1
%9 = tail call float @llvm.fabs.f32(float %8)
%10 = fdiv float %9, %5
%11 = fcmp ole float %10, 0x3F50624DE0000000
%12 = zext i1 %11 to i32
br label %13
13: ; preds = %2, %7
%14 = phi i32 [ %12, %7 ], [ 1, %2 ]
ret i32 %14
}