#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 evaluate_bilinear_cell(float, float, float, float, float, float);
float getsamplec(float *, int, int, int, int, int, int /*<<< orphan*/);
float bilinear_interpolation_at(float *x, int w, int h, float p, float q) {
  int ip = p;
  int iq = q;
  float a = getsamplec(x, w, h, 1, ip, iq, 0);
  float b = getsamplec(x, w, h, 1, ip + 1, iq, 0);
  float c = getsamplec(x, w, h, 1, ip, iq + 1, 0);
  float d = getsamplec(x, w, h, 1, ip + 1, iq + 1, 0);
  float r = evaluate_bilinear_cell(a, b, c, d, p - ip, q - iq);
  return r;
}


x86 assembly (clang, -O0):
<bilinear_interpolation_at>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movss  %xmm1,-0x18(%rbp)
cvttss2si -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cvttss2si -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
mov    $0x1,%ecx
xor    %eax,%eax
movl   $0x0,(%rsp)
call   1040 <getsamplec@plt>
movss  %xmm0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%r8d
add    $0x1,%r8d
mov    -0x20(%rbp),%r9d
mov    $0x1,%ecx
xor    %eax,%eax
movl   $0x0,(%rsp)
call   1040 <getsamplec@plt>
movss  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
add    $0x1,%r9d
mov    $0x1,%ecx
xor    %eax,%eax
movl   $0x0,(%rsp)
call   1040 <getsamplec@plt>
movss  %xmm0,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%r8d
add    $0x1,%r8d
mov    -0x20(%rbp),%r9d
add    $0x1,%r9d
mov    $0x1,%ecx
xor    %eax,%eax
movl   $0x0,(%rsp)
call   1040 <getsamplec@plt>
movss  %xmm0,-0x30(%rbp)
movss  -0x24(%rbp),%xmm0
movss  -0x28(%rbp),%xmm1
movss  -0x2c(%rbp),%xmm2
movss  -0x30(%rbp),%xmm3
movss  -0x14(%rbp),%xmm4
cvtsi2ssl -0x1c(%rbp),%xmm5
subss  %xmm5,%xmm4
movss  -0x18(%rbp),%xmm5
cvtsi2ssl -0x20(%rbp),%xmm6
subss  %xmm6,%xmm5
call   1030 <evaluate_bilinear_cell@plt>
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bilinear_interpolation_at>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
movaps %xmm1,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbx
cvttss2si %xmm0,%r12d
cvttss2si %xmm1,%ebp
movl   $0x0,(%rsp)
mov    $0x1,%ecx
mov    %r12d,%r8d
mov    %ebp,%r9d
call   1040 <getsamplec@plt>
movss  %xmm0,0x1c(%rsp)
lea    0x1(%r12),%r13d
movl   $0x0,(%rsp)
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    $0x1,%ecx
mov    %r13d,%r8d
mov    %ebp,%r9d
call   1040 <getsamplec@plt>
movss  %xmm0,0x18(%rsp)
add    $0x1,%ebp
movl   $0x0,(%rsp)
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    $0x1,%ecx
mov    %r12d,%r8d
mov    %ebp,%r9d
call   1040 <getsamplec@plt>
movss  %xmm0,0x14(%rsp)
movl   $0x0,(%rsp)
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    $0x1,%ecx
mov    %r13d,%r8d
mov    %ebp,%r9d
call   1040 <getsamplec@plt>
movaps %xmm0,%xmm3
movaps 0x20(%rsp),%xmm4
cvttps2dq %xmm4,%xmm0
cvtdq2ps %xmm0,%xmm0
subss  %xmm0,%xmm4
movaps 0x30(%rsp),%xmm5
cvttps2dq %xmm5,%xmm0
cvtdq2ps %xmm0,%xmm0
subss  %xmm0,%xmm5
movss  0x1c(%rsp),%xmm0
movss  0x18(%rsp),%xmm1
movss  0x14(%rsp),%xmm2
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <evaluate_bilinear_cell@plt>

LLVM IR (-O0):
define float @bilinear_interpolation_at(float* %0, i32 %1, i32 %2, float %3, float %4) {
%6 = alloca float*
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
%10 = alloca float
%11 = alloca i32
%12 = alloca i32
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
store float* %0, float** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store float %3, float* %9
store float %4, float* %10
%18 = load float, float* %9
%19 = fptosi float %18 to i32
store i32 %19, i32* %11
%20 = load float, float* %10
%21 = fptosi float %20 to i32
store i32 %21, i32* %12
%22 = load float*, float** %6
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = load i32, i32* %11
%26 = load i32, i32* %12
%27 = call float @getsamplec(float* %22, i32 %23, i32 %24, i32 1, i32 %25, i32 %26, i32 0)
store float %27, float* %13
%28 = load float*, float** %6
%29 = load i32, i32* %7
%30 = load i32, i32* %8
%31 = load i32, i32* %11
%32 = add nsw i32 %31, 1
%33 = load i32, i32* %12
%34 = call float @getsamplec(float* %28, i32 %29, i32 %30, i32 1, i32 %32, i32 %33, i32 0)
store float %34, float* %14
%35 = load float*, float** %6
%36 = load i32, i32* %7
%37 = load i32, i32* %8
%38 = load i32, i32* %11
%39 = load i32, i32* %12
%40 = add nsw i32 %39, 1
%41 = call float @getsamplec(float* %35, i32 %36, i32 %37, i32 1, i32 %38, i32 %40, i32 0)
store float %41, float* %15
%42 = load float*, float** %6
%43 = load i32, i32* %7
%44 = load i32, i32* %8
%45 = load i32, i32* %11
%46 = add nsw i32 %45, 1
%47 = load i32, i32* %12
%48 = add nsw i32 %47, 1
%49 = call float @getsamplec(float* %42, i32 %43, i32 %44, i32 1, i32 %46, i32 %48, i32 0)
store float %49, float* %16
%50 = load float, float* %13
%51 = load float, float* %14
%52 = load float, float* %15
%53 = load float, float* %16
%54 = load float, float* %9
%55 = load i32, i32* %11
%56 = sitofp i32 %55 to float
%57 = fsub float %54, %56
%58 = load float, float* %10
%59 = load i32, i32* %12
%60 = sitofp i32 %59 to float
%61 = fsub float %58, %60
%62 = call float @evaluate_bilinear_cell(float %50, float %51, float %52, float %53, float %57, float %61)
store float %62, float* %17
%63 = load float, float* %17
ret float %63
}

LLVM IR (-O2):
define float @bilinear_interpolation_at(float* %0, i32 %1, i32 %2, float %3, float %4) {
%6 = fptosi float %3 to i32
%7 = fptosi float %4 to i32
%8 = tail call float @getsamplec(float* %0, i32 %1, i32 %2, i32 1, i32 %6, i32 %7, i32 0)
%9 = add nsw i32 %6, 1
%10 = tail call float @getsamplec(float* %0, i32 %1, i32 %2, i32 1, i32 %9, i32 %7, i32 0)
%11 = add nsw i32 %7, 1
%12 = tail call float @getsamplec(float* %0, i32 %1, i32 %2, i32 1, i32 %6, i32 %11, i32 0)
%13 = tail call float @getsamplec(float* %0, i32 %1, i32 %2, i32 1, i32 %9, i32 %11, i32 0)
%14 = sitofp i32 %6 to float
%15 = fsub float %3, %14
%16 = sitofp i32 %7 to float
%17 = fsub float %4, %16
%18 = tail call float @evaluate_bilinear_cell(float %8, float %10, float %12, float %13, float %15, float %17)
ret float %18
}