#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 fabs(double);
double linear_interpolation(double xC, double xA, double yA, double xB,
                            double yB) {
  if (fabs(xA - xB) > 1e-9) {
    return yA + (yB - yA) / (xB - xA) * (xC - xA);
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<linear_interpolation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xeb4(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    118f <linear_interpolation+0x7f>
movsd  -0x20(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
divsd  %xmm2,%xmm0
movsd  -0x10(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1197 <linear_interpolation+0x87>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linear_interpolation>:
sub    $0x28,%rsp
movsd  %xmm4,0x18(%rsp)
movsd  %xmm2,0x20(%rsp)
movsd  %xmm0,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
movsd  %xmm3,(%rsp)
subsd  %xmm3,%xmm0
call   1030 <fabs@plt>
test   %eax,%eax
jle    117c <linear_interpolation+0x6c>
movsd  0x20(%rsp),%xmm2
movsd  0x18(%rsp),%xmm1
subsd  %xmm2,%xmm1
movsd  0x8(%rsp),%xmm3
movsd  (%rsp),%xmm0
subsd  %xmm3,%xmm0
divsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
subsd  %xmm3,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
add    $0x28,%rsp
ret
xorpd  %xmm0,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @linear_interpolation(double %0, double %1, double %2, double %3, double %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store double %4, double* %11
%12 = load double, double* %8
%13 = load double, double* %10
%14 = fsub double %12, %13
%15 = call i32 @fabs(double %14)
%16 = sitofp i32 %15 to double
%17 = fcmp ogt double %16, 1.000000e-09
br i1 %17, label %18, label %31
18: ; preds = %5
%19 = load double, double* %9
%20 = load double, double* %11
%21 = load double, double* %9
%22 = fsub double %20, %21
%23 = load double, double* %10
%24 = load double, double* %8
%25 = fsub double %23, %24
%26 = fdiv double %22, %25
%27 = load double, double* %7
%28 = load double, double* %8
%29 = fsub double %27, %28
%30 = call double @llvm.fmuladd.f64(double %26, double %29, double %19)
store double %30, double* %6
br label %32
31: ; preds = %5
store double 0.000000e+00, double* %6
br label %32
32: ; preds = %31, %18
%33 = load double, double* %6
ret double %33
}

LLVM IR (-O2):
define double @linear_interpolation(double %0, double %1, double %2, double %3, double %4) {
%6 = fsub double %1, %3
%7 = tail call i32 @fabs(double %6)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = fsub double %4, %2
%11 = fsub double %3, %1
%12 = fdiv double %10, %11
%13 = fsub double %0, %1
%14 = tail call double @llvm.fmuladd.f64(double %12, double %13, double %2)
br label %15
15: ; preds = %5, %9
%16 = phi double [ %14, %9 ], [ 0.000000e+00, %5 ]
ret double %16
}