#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 bicubic_interpolation_at(float const *, float const, float const,
                               int const, int const, int);
void bicubic_interpolation_warp(const float *input, const float *u,
                                const float *v, float *output, const int nx,
                                const int ny, bool border_out) {
  for (int i = 0; i < ny; i++)
    for (int j = 0; j < nx; j++) {
      const int p = i * nx + j;
      const float uu = (float)(j + u[p]);
      const float vv = (float)(i + v[p]);
      output[p] = bicubic_interpolation_at(input, uu, vv, nx, ny, border_out);
    }
}


x86 assembly (clang, -O0):
<bicubic_interpolation_warp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    11de <bicubic_interpolation_warp+0xce>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11cb <bicubic_interpolation_warp+0xbb>
mov    -0x2c(%rbp),%eax
imul   -0x24(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
cvtsi2ssl -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
addss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x38(%rbp)
cvtsi2ssl -0x2c(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
addss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
movss  -0x38(%rbp),%xmm0
movss  -0x3c(%rbp),%xmm1
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    0x10(%rbp),%ecx
call   1030 <bicubic_interpolation_at@plt>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    114d <bicubic_interpolation_warp+0x3d>
jmp    11d0 <bicubic_interpolation_warp+0xc0>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    113a <bicubic_interpolation_warp+0x2a>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bicubic_interpolation_warp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8d,0x4(%rsp)
test   %r9d,%r9d
jle    1204 <bicubic_interpolation_warp+0xf4>
mov    %r9d,%r13d
mov    %rdi,%r12
mov    0x70(%rsp),%r14d
mov    0x4(%rsp),%ebp
mov    %ebp,%eax
movslq %ebp,%rbp
mov    %r9d,%ebx
mov    %rbx,0x18(%rsp)
shl    $0x2,%rbp
mov    %rbp,0x20(%rsp)
xor    %ebp,%ebp
mov    %rbp,0x8(%rsp)
jmp    1186 <bicubic_interpolation_warp+0x76>
nopw   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rbx
add    $0x1,%rbx
mov    0x20(%rsp),%rbp
add    %rbp,%rsi
add    %rbp,%rdx
add    %rbp,%rcx
mov    %rbx,%rbp
mov    %rbx,0x8(%rsp)
cmp    0x18(%rsp),%rbx
je     1204 <bicubic_interpolation_warp+0xf4>
cmpl   $0x0,0x4(%rsp)
jle    1160 <bicubic_interpolation_warp+0x50>
xorps  %xmm0,%xmm0
cvtsi2ssl 0x8(%rsp),%xmm0
movss  %xmm0,0x14(%rsp)
xor    %r15d,%r15d
mov    %rsi,0x30(%rsp)
mov    %rdx,0x28(%rsp)
nopl   0x0(%rax)
xorps  %xmm0,%xmm0
cvtsi2ss %r15d,%xmm0
addss  (%rsi,%r15,4),%xmm0
movss  (%rdx,%r15,4),%xmm1
addss  0x14(%rsp),%xmm1
mov    %r12,%rdi
mov    %eax,%esi
mov    %r13d,%edx
mov    %rcx,%rbx
mov    %r14d,%ecx
mov    %rax,%rbp
call   1030 <bicubic_interpolation_at@plt>
mov    %rbp,%rax
mov    0x30(%rsp),%rsi
mov    0x28(%rsp),%rdx
mov    %rbx,%rcx
movss  %xmm0,(%rbx,%r15,4)
add    $0x1,%r15
cmp    %r15,%rbp
jne    11b0 <bicubic_interpolation_warp+0xa0>
jmp    1160 <bicubic_interpolation_warp+0x50>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @bicubic_interpolation_warp(float* %0, float* %1, float* %2, float* %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca float*
%9 = alloca float*
%10 = alloca float*
%11 = alloca float*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca float
%19 = alloca float
store float* %0, float** %8
store float* %1, float** %9
store float* %2, float** %10
store float* %3, float** %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
store i32 0, i32* %15
br label %20
20: ; preds = %66, %7
%21 = load i32, i32* %15
%22 = load i32, i32* %13
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %69
24: ; preds = %20
store i32 0, i32* %16
br label %25
25: ; preds = %62, %24
%26 = load i32, i32* %16
%27 = load i32, i32* %12
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %65
29: ; preds = %25
%30 = load i32, i32* %15
%31 = load i32, i32* %12
%32 = mul nsw i32 %30, %31
%33 = load i32, i32* %16
%34 = add nsw i32 %32, %33
store i32 %34, i32* %17
%35 = load i32, i32* %16
%36 = sitofp i32 %35 to float
%37 = load float*, float** %9
%38 = load i32, i32* %17
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds float, float* %37, i64 %39
%41 = load float, float* %40
%42 = fadd float %36, %41
store float %42, float* %18
%43 = load i32, i32* %15
%44 = sitofp i32 %43 to float
%45 = load float*, float** %10
%46 = load i32, i32* %17
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds float, float* %45, i64 %47
%49 = load float, float* %48
%50 = fadd float %44, %49
store float %50, float* %19
%51 = load float*, float** %8
%52 = load float, float* %18
%53 = load float, float* %19
%54 = load i32, i32* %12
%55 = load i32, i32* %13
%56 = load i32, i32* %14
%57 = call float @bicubic_interpolation_at(float* %51, float %52, float %53, i32 %54, i32 %55, i32 %56)
%58 = load float*, float** %11
%59 = load i32, i32* %17
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds float, float* %58, i64 %60
store float %57, float* %61
br label %62
62: ; preds = %29
%63 = load i32, i32* %16
%64 = add nsw i32 %63, 1
store i32 %64, i32* %16
br label %25
65: ; preds = %25
br label %66
66: ; preds = %65
%67 = load i32, i32* %15
%68 = add nsw i32 %67, 1
store i32 %68, i32* %15
br label %20
69: ; preds = %20
ret void
}

LLVM IR (-O2):
define void @bicubic_interpolation_warp(float* %0, float* nocapture %1, float* nocapture %2, float* nocapture writeonly %3, i32 %4, i32 %5, i32 %6) {
%8 = icmp sgt i32 %5, 0
br i1 %8, label %9, label %20
9: ; preds = %7
%10 = icmp sgt i32 %4, 0
%11 = sext i32 %4 to i64
%12 = zext i32 %5 to i64
%13 = zext i32 %4 to i64
br label %14
14: ; preds = %9, %21
%15 = phi i64 [ 0, %9 ], [ %22, %21 ]
br i1 %10, label %16, label %21
16: ; preds = %14
%17 = mul nsw i64 %15, %11
%18 = trunc i64 %15 to i32
%19 = sitofp i32 %18 to float
br label %24
20: ; preds = %21, %7
ret void
21: ; preds = %24, %14
%22 = add nuw nsw i64 %15, 1
%23 = icmp eq i64 %22, %12
br i1 %23, label %20, label %14
24: ; preds = %16, %24
%25 = phi i64 [ 0, %16 ], [ %37, %24 ]
%26 = add nsw i64 %25, %17
%27 = trunc i64 %25 to i32
%28 = sitofp i32 %27 to float
%29 = getelementptr inbounds float, float* %1, i64 %26
%30 = load float, float* %29
%31 = fadd float %30, %28
%32 = getelementptr inbounds float, float* %2, i64 %26
%33 = load float, float* %32
%34 = fadd float %33, %19
%35 = tail call float @bicubic_interpolation_at(float* %0, float %31, float %34, i32 %4, i32 %5, i32 %6)
%36 = getelementptr inbounds float, float* %3, i64 %26
store float %35, float* %36
%37 = add nuw nsw i64 %25, 1
%38 = icmp eq i64 %37, %13
br i1 %38, label %21, label %24
}