#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 Table_Interp1d(double, double, double, double, double);
double Table_Interp2d(double x, double y, double x1, double y1, double x2,
                      double y2, double z11, double z12, double z21,
                      double z22) {
  double ratio_x, ratio_y;
  if (x2 == x1)
    return Table_Interp1d(y, y1, z11, y2, z12);
  if (y1 == y2)
    return Table_Interp1d(x, x1, z11, x2, z21);
  ratio_y = (y - y1) / (y2 - y1);
  ratio_x = (x - x1) / (x2 - x1);
  return (1 - ratio_x) * (1 - ratio_y) * z11 + ratio_x * (1 - ratio_y) * z21 +
         ratio_x * ratio_y * z22 + (1 - ratio_x) * ratio_y * z12;
}


x86 assembly (clang, -O0):
<Table_Interp2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  0x18(%rbp),%xmm8
movsd  0x10(%rbp),%xmm8
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  %xmm5,-0x38(%rbp)
movsd  %xmm6,-0x40(%rbp)
movsd  %xmm7,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jne    118a <Table_Interp2d+0x7a>
jp     118a <Table_Interp2d+0x7a>
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
movsd  -0x48(%rbp),%xmm4
call   1030 <Table_Interp1d@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1283 <Table_Interp2d+0x173>
movsd  -0x28(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jne    11c8 <Table_Interp2d+0xb8>
jp     11c8 <Table_Interp2d+0xb8>
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
movsd  0x10(%rbp),%xmm4
call   1030 <Table_Interp1d@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1283 <Table_Interp2d+0x173>
movsd  -0x18(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
subsd  -0x28(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xdf6(%rip),%xmm0
subsd  -0x50(%rbp),%xmm0
movsd  0xde9(%rip),%xmm1
subsd  -0x58(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
movsd  0xdce(%rip),%xmm3
subsd  -0x58(%rbp),%xmm3
mulsd  %xmm3,%xmm1
mulsd  0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x50(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
movsd  0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xd99(%rip),%xmm0
subsd  -0x50(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Table_Interp2d>:
ucomisd %xmm2,%xmm4
jne    112c <Table_Interp2d+0x1c>
jp     112c <Table_Interp2d+0x1c>
movaps %xmm1,%xmm0
movaps %xmm3,%xmm1
movaps %xmm6,%xmm2
movaps %xmm5,%xmm3
movaps %xmm7,%xmm4
jmp    1030 <Table_Interp1d@plt>
movapd %xmm4,%xmm8
movsd  0x8(%rsp),%xmm4
ucomisd %xmm5,%xmm3
jne    1150 <Table_Interp2d+0x40>
jp     1150 <Table_Interp2d+0x40>
movapd %xmm2,%xmm1
movaps %xmm6,%xmm2
movapd %xmm8,%xmm3
jmp    1030 <Table_Interp1d@plt>
unpcklpd %xmm1,%xmm0
unpcklpd %xmm3,%xmm2
subpd  %xmm2,%xmm0
unpcklpd %xmm5,%xmm8
subpd  %xmm2,%xmm8
divpd  %xmm8,%xmm0
movapd 0xe8d(%rip),%xmm2
subpd  %xmm0,%xmm2
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
movapd %xmm2,%xmm3
mulsd  %xmm1,%xmm3
mulsd  %xmm0,%xmm1
mulsd  %xmm4,%xmm1
mulsd  %xmm6,%xmm3
addsd  %xmm1,%xmm3
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
mulsd  %xmm1,%xmm0
mulsd  0x10(%rsp),%xmm0
addsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm1
mulsd  %xmm7,%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @Table_Interp2d(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8, double %9) {
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
store double %0, double* %12
store double %1, double* %13
store double %2, double* %14
store double %3, double* %15
store double %4, double* %16
store double %5, double* %17
store double %6, double* %18
store double %7, double* %19
store double %8, double* %20
store double %9, double* %21
%24 = load double, double* %16
%25 = load double, double* %14
%26 = fcmp oeq double %24, %25
br i1 %26, label %27, label %34
27: ; preds = %10
%28 = load double, double* %13
%29 = load double, double* %15
%30 = load double, double* %18
%31 = load double, double* %17
%32 = load double, double* %19
%33 = call double @Table_Interp1d(double %28, double %29, double %30, double %31, double %32)
store double %33, double* %11
br label %84
34: ; preds = %10
%35 = load double, double* %15
%36 = load double, double* %17
%37 = fcmp oeq double %35, %36
br i1 %37, label %38, label %45
38: ; preds = %34
%39 = load double, double* %12
%40 = load double, double* %14
%41 = load double, double* %18
%42 = load double, double* %16
%43 = load double, double* %20
%44 = call double @Table_Interp1d(double %39, double %40, double %41, double %42, double %43)
store double %44, double* %11
br label %84
45: ; preds = %34
%46 = load double, double* %13
%47 = load double, double* %15
%48 = fsub double %46, %47
%49 = load double, double* %17
%50 = load double, double* %15
%51 = fsub double %49, %50
%52 = fdiv double %48, %51
store double %52, double* %23
%53 = load double, double* %12
%54 = load double, double* %14
%55 = fsub double %53, %54
%56 = load double, double* %16
%57 = load double, double* %14
%58 = fsub double %56, %57
%59 = fdiv double %55, %58
store double %59, double* %22
%60 = load double, double* %22
%61 = fsub double 1.000000e+00, %60
%62 = load double, double* %23
%63 = fsub double 1.000000e+00, %62
%64 = fmul double %61, %63
%65 = load double, double* %18
%66 = load double, double* %22
%67 = load double, double* %23
%68 = fsub double 1.000000e+00, %67
%69 = fmul double %66, %68
%70 = load double, double* %20
%71 = fmul double %69, %70
%72 = call double @llvm.fmuladd.f64(double %64, double %65, double %71)
%73 = load double, double* %22
%74 = load double, double* %23
%75 = fmul double %73, %74
%76 = load double, double* %21
%77 = call double @llvm.fmuladd.f64(double %75, double %76, double %72)
%78 = load double, double* %22
%79 = fsub double 1.000000e+00, %78
%80 = load double, double* %23
%81 = fmul double %79, %80
%82 = load double, double* %19
%83 = call double @llvm.fmuladd.f64(double %81, double %82, double %77)
store double %83, double* %11
br label %84
84: ; preds = %45, %38, %27
%85 = load double, double* %11
ret double %85
}

LLVM IR (-O2):
define double @Table_Interp2d(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8, double %9) {
%11 = fcmp oeq double %4, %2
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = tail call double @Table_Interp1d(double %1, double %3, double %6, double %5, double %7)
br label %41
14: ; preds = %10
%15 = fcmp oeq double %3, %5
br i1 %15, label %16, label %18
16: ; preds = %14
%17 = tail call double @Table_Interp1d(double %0, double %2, double %6, double %4, double %8)
br label %41
18: ; preds = %14
%19 = insertelement <2 x double> poison, double %0, i64 0
%20 = insertelement <2 x double> %19, double %1, i64 1
%21 = insertelement <2 x double> poison, double %2, i64 0
%22 = insertelement <2 x double> %21, double %3, i64 1
%23 = fsub <2 x double> %20, %22
%24 = insertelement <2 x double> poison, double %4, i64 0
%25 = insertelement <2 x double> %24, double %5, i64 1
%26 = fsub <2 x double> %25, %22
%27 = fdiv <2 x double> %23, %26
%28 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %27
%29 = extractelement <2 x double> %28, i64 0
%30 = extractelement <2 x double> %28, i64 1
%31 = fmul double %29, %30
%32 = extractelement <2 x double> %27, i64 0
%33 = fmul double %32, %30
%34 = fmul double %33, %8
%35 = tail call double @llvm.fmuladd.f64(double %31, double %6, double %34)
%36 = extractelement <2 x double> %27, i64 1
%37 = fmul double %32, %36
%38 = tail call double @llvm.fmuladd.f64(double %37, double %9, double %35)
%39 = fmul double %29, %36
%40 = tail call double @llvm.fmuladd.f64(double %39, double %7, double %38)
br label %41
41: ; preds = %18, %16, %12
%42 = phi double [ %13, %12 ], [ %17, %16 ], [ %40, %18 ]
ret double %42
}