#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 interpolate(float const, float const, float);
float interpolate_bilinear(float const values[2][2], float u, float v) {
  float x0 = interpolate(values[0][0], values[0][1], u);
  float x1 = interpolate(values[1][0], values[1][1], u);
  return interpolate(x0, x1, v);
}


x86 assembly (clang, -O0):
<interpolate_bilinear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm1
movss  -0xc(%rbp),%xmm2
call   1030 <interpolate@plt>
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm1
movss  -0xc(%rbp),%xmm2
call   1030 <interpolate@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
call   1030 <interpolate@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interpolate_bilinear>:
push   %rbx
sub    $0x10,%rsp
movss  %xmm1,0xc(%rsp)
movaps %xmm0,%xmm2
movss  %xmm0,0x4(%rsp)
mov    %rdi,%rbx
movss  (%rdi),%xmm0
movss  0x4(%rdi),%xmm1
call   1030 <interpolate@plt>
movss  %xmm0,0x8(%rsp)
movss  0x8(%rbx),%xmm0
movss  0xc(%rbx),%xmm1
movss  0x4(%rsp),%xmm2
call   1030 <interpolate@plt>
movaps %xmm0,%xmm1
movss  0x8(%rsp),%xmm0
movss  0xc(%rsp),%xmm2
add    $0x10,%rsp
pop    %rbx
jmp    1030 <interpolate@plt>

LLVM IR (-O0):
define float @interpolate_bilinear([2 x float]* %0, float %1, float %2) {
%4 = alloca [2 x float]*
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
store [2 x float]* %0, [2 x float]** %4
store float %1, float* %5
store float %2, float* %6
%9 = load [2 x float]*, [2 x float]** %4
%10 = getelementptr inbounds [2 x float], [2 x float]* %9, i64 0
%11 = getelementptr inbounds [2 x float], [2 x float]* %10, i64 0, i64 0
%12 = load float, float* %11
%13 = load [2 x float]*, [2 x float]** %4
%14 = getelementptr inbounds [2 x float], [2 x float]* %13, i64 0
%15 = getelementptr inbounds [2 x float], [2 x float]* %14, i64 0, i64 1
%16 = load float, float* %15
%17 = load float, float* %5
%18 = call float @interpolate(float %12, float %16, float %17)
store float %18, float* %7
%19 = load [2 x float]*, [2 x float]** %4
%20 = getelementptr inbounds [2 x float], [2 x float]* %19, i64 1
%21 = getelementptr inbounds [2 x float], [2 x float]* %20, i64 0, i64 0
%22 = load float, float* %21
%23 = load [2 x float]*, [2 x float]** %4
%24 = getelementptr inbounds [2 x float], [2 x float]* %23, i64 1
%25 = getelementptr inbounds [2 x float], [2 x float]* %24, i64 0, i64 1
%26 = load float, float* %25
%27 = load float, float* %5
%28 = call float @interpolate(float %22, float %26, float %27)
store float %28, float* %8
%29 = load float, float* %7
%30 = load float, float* %8
%31 = load float, float* %6
%32 = call float @interpolate(float %29, float %30, float %31)
ret float %32
}

LLVM IR (-O2):
define float @interpolate_bilinear([2 x float]* nocapture %0, float %1, float %2) {
%4 = getelementptr inbounds [2 x float], [2 x float]* %0, i64 0, i64 0
%5 = load float, float* %4
%6 = getelementptr inbounds [2 x float], [2 x float]* %0, i64 0, i64 1
%7 = load float, float* %6
%8 = tail call float @interpolate(float %5, float %7, float %1)
%9 = getelementptr inbounds [2 x float], [2 x float]* %0, i64 1, i64 0
%10 = load float, float* %9
%11 = getelementptr inbounds [2 x float], [2 x float]* %0, i64 1, i64 1
%12 = load float, float* %11
%13 = tail call float @interpolate(float %10, float %12, float %1)
%14 = tail call float @interpolate(float %8, float %13, float %2)
ret float %14
}