#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 absVal(float);
float percentDiff(double val1, double val2) {
  if ((absVal(val1) < 0.01) && (absVal(val2) < 0.01)) {
    return 0.0f;
  } else {
    return 100.0f * (absVal(absVal(val1 - val2) / absVal(val1 + 0.00000001f)));
  }
}


x86 assembly (clang, -O0):
<percentDiff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <absVal@plt>
cvtss2sd %xmm0,%xmm1
movsd  0xec4(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1177 <percentDiff+0x67>
movsd  -0x18(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <absVal@plt>
cvtss2sd %xmm0,%xmm1
movsd  0xea0(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1177 <percentDiff+0x67>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11ca <percentDiff+0xba>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <absVal@plt>
movss  %xmm0,-0x1c(%rbp)
movsd  0xe71(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <absVal@plt>
movaps %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
divss  %xmm1,%xmm0
call   1030 <absVal@plt>
movaps %xmm0,%xmm1
movss  0xe4f(%rip),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<percentDiff>:
sub    $0x18,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
cvtsd2ss %xmm0,%xmm0
call   1030 <absVal@plt>
cvtss2sd %xmm0,%xmm0
movsd  0xecb(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1162 <percentDiff+0x52>
movsd  0x8(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <absVal@plt>
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
movsd  0xea4(%rip),%xmm2
ucomisd %xmm1,%xmm2
ja     11ae <percentDiff+0x9e>
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <absVal@plt>
movss  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
addsd  0xe7d(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <absVal@plt>
movss  0x8(%rsp),%xmm1
divss  %xmm0,%xmm1
movaps %xmm1,%xmm0
call   1030 <absVal@plt>
mulss  0xe62(%rip),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @percentDiff(double %0, double %1) {
%3 = alloca float
%4 = alloca double
%5 = alloca double
store double %0, double* %4
store double %1, double* %5
%6 = load double, double* %4
%7 = fptrunc double %6 to float
%8 = call float @absVal(float %7)
%9 = fpext float %8 to double
%10 = fcmp olt double %9, 1.000000e-02
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load double, double* %5
%13 = fptrunc double %12 to float
%14 = call float @absVal(float %13)
%15 = fpext float %14 to double
%16 = fcmp olt double %15, 1.000000e-02
br i1 %16, label %17, label %18
17: ; preds = %11
store float 0.000000e+00, float* %3
br label %31
18: ; preds = %11, %2
%19 = load double, double* %4
%20 = load double, double* %5
%21 = fsub double %19, %20
%22 = fptrunc double %21 to float
%23 = call float @absVal(float %22)
%24 = load double, double* %4
%25 = fadd double %24, 0x3E45798EE0000000
%26 = fptrunc double %25 to float
%27 = call float @absVal(float %26)
%28 = fdiv float %23, %27
%29 = call float @absVal(float %28)
%30 = fmul float 1.000000e+02, %29
store float %30, float* %3
br label %31
31: ; preds = %18, %17
%32 = load float, float* %3
ret float %32
}

LLVM IR (-O2):
define float @percentDiff(double %0, double %1) {
%3 = fptrunc double %0 to float
%4 = tail call float @absVal(float %3)
%5 = fpext float %4 to double
%6 = fcmp olt double %5, 1.000000e-02
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = fptrunc double %1 to float
%9 = tail call float @absVal(float %8)
%10 = fpext float %9 to double
%11 = fcmp olt double %10, 1.000000e-02
br i1 %11, label %22, label %12
12: ; preds = %7, %2
%13 = fsub double %0, %1
%14 = fptrunc double %13 to float
%15 = tail call float @absVal(float %14)
%16 = fadd double %0, 0x3E45798EE0000000
%17 = fptrunc double %16 to float
%18 = tail call float @absVal(float %17)
%19 = fdiv float %15, %18
%20 = tail call float @absVal(float %19)
%21 = fmul float %20, 1.000000e+02
br label %22
22: ; preds = %7, %12
%23 = phi float [ %21, %12 ], [ 0.000000e+00, %7 ]
ret float %23
}