#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();
void check(float a, float b) {
  float err = (b == 0.0) ? a : (a - b) / b;
  if (((err > 0) ? err : -err) > 0.0001)
    abort();
}


x86 assembly (clang, -O0):
<check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    114d <check+0x3d>
jp     114d <check+0x3d>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1161 <check+0x51>
movss  -0x4(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    118b <check+0x7b>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    11a2 <check+0x92>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe4d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11c4 <check+0xb4>
mov    $0x0,%al
call   1030 <abort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check>:
push   %rax
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm1
jne    111b <check+0xb>
jnp    1123 <check+0x13>
subss  %xmm1,%xmm0
divss  %xmm1,%xmm0
movaps 0xed6(%rip),%xmm1
xorps  %xmm0,%xmm1
cmpltss %xmm0,%xmm2
andps  %xmm2,%xmm0
andnps %xmm1,%xmm2
orps   %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
ucomisd 0xec6(%rip),%xmm0
ja     114e <check+0x3e>
pop    %rax
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define void @check(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
store float %0, float* %3
store float %1, float* %4
%6 = load float, float* %4
%7 = fpext float %6 to double
%8 = fcmp oeq double %7, 0.000000e+00
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = load float, float* %3
br label %17
11: ; preds = %2
%12 = load float, float* %3
%13 = load float, float* %4
%14 = fsub float %12, %13
%15 = load float, float* %4
%16 = fdiv float %14, %15
br label %17
17: ; preds = %11, %9
%18 = phi float [ %10, %9 ], [ %16, %11 ]
store float %18, float* %5
%19 = load float, float* %5
%20 = fcmp ogt float %19, 0.000000e+00
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load float, float* %5
br label %26
23: ; preds = %17
%24 = load float, float* %5
%25 = fneg float %24
br label %26
26: ; preds = %23, %21
%27 = phi float [ %22, %21 ], [ %25, %23 ]
%28 = fpext float %27 to double
%29 = fcmp ogt double %28, 1.000000e-04
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 (...) @abort()
unreachable
32: ; preds = %26
ret void
}

LLVM IR (-O2):
define void @check(float %0, float %1) {
%3 = fcmp oeq float %1, 0.000000e+00
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = fsub float %0, %1
%6 = fdiv float %5, %1
br label %7
7: ; preds = %2, %4
%8 = phi float [ %6, %4 ], [ %0, %2 ]
%9 = fcmp ogt float %8, 0.000000e+00
%10 = fneg float %8
%11 = select i1 %9, float %8, float %10
%12 = fpext float %11 to double
%13 = fcmp ogt double %12, 1.000000e-04
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = tail call i32 (...) @abort()
unreachable
16: ; preds = %7
ret void
}