#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 table_interpolate(double x, double x1, double y1, double x2, double y2) {
  double dx = x2 - x1;
  if (fabs(dx) < 1.0e-20)
    return (y1 + y2) / 2.;
  return y1 + (x - x1) * (y2 - y1) / dx;
}


x86 assembly (clang, -O0):
<table_interpolate>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm1
movaps 0xed8(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xebc(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    116e <table_interpolate+0x6e>
movsd  -0x20(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  0xea8(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1199 <table_interpolate+0x99>
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
subsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm1
divsd  -0x38(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<table_interpolate>:
subsd  %xmm1,%xmm3
movapd 0xef4(%rip),%xmm5
andpd  %xmm3,%xmm5
movsd  0xef8(%rip),%xmm6
ucomisd %xmm5,%xmm6
jbe    112f <table_interpolate+0x2f>
addsd  %xmm4,%xmm2
mulsd  0xeee(%rip),%xmm2
movapd %xmm2,%xmm0
ret
subsd  %xmm1,%xmm0
subsd  %xmm2,%xmm4
mulsd  %xmm0,%xmm4
divsd  %xmm3,%xmm4
addsd  %xmm4,%xmm2
movapd %xmm2,%xmm0
ret

LLVM IR (-O0):
define double @table_interpolate(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
%12 = 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
%13 = load double, double* %10
%14 = load double, double* %8
%15 = fsub double %13, %14
store double %15, double* %12
%16 = load double, double* %12
%17 = call double @llvm.fabs.f64(double %16)
%18 = fcmp olt double %17, 0x3BC79CA10C924223
br i1 %18, label %19, label %24
19: ; preds = %5
%20 = load double, double* %9
%21 = load double, double* %11
%22 = fadd double %20, %21
%23 = fdiv double %22, 2.000000e+00
store double %23, double* %6
br label %36
24: ; preds = %5
%25 = load double, double* %9
%26 = load double, double* %7
%27 = load double, double* %8
%28 = fsub double %26, %27
%29 = load double, double* %11
%30 = load double, double* %9
%31 = fsub double %29, %30
%32 = fmul double %28, %31
%33 = load double, double* %12
%34 = fdiv double %32, %33
%35 = fadd double %25, %34
store double %35, double* %6
br label %36
36: ; preds = %24, %19
%37 = load double, double* %6
ret double %37
}

LLVM IR (-O2):
define double @table_interpolate(double %0, double %1, double %2, double %3, double %4) {
%6 = fsub double %3, %1
%7 = tail call double @llvm.fabs.f64(double %6)
%8 = fcmp olt double %7, 0x3BC79CA10C924223
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = fadd double %2, %4
%11 = fmul double %10, 5.000000e-01
br label %18
12: ; preds = %5
%13 = fsub double %0, %1
%14 = fsub double %4, %2
%15 = fmul double %13, %14
%16 = fdiv double %15, %6
%17 = fadd double %16, %2
br label %18
18: ; preds = %12, %9
%19 = phi double [ %11, %9 ], [ %17, %12 ]
ret double %19
}