#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 catmullrom_interp(float const *, size_t, size_t, float, float, size_t);
void neuralops_interpolate2d_catmullrom(size_t in_width, size_t in_height,
                                        size_t chan, size_t out_width,
                                        size_t out_height,
                                        const float *in_pixels,
                                        float *out_pixels) {
  float scale_x = ((float)in_width) / ((float)(out_width));
  float scale_y = ((float)in_height) / ((float)(out_height));
  size_t p = 0;
  for (size_t a = 0; a < chan; a++) {
    for (size_t y = 0; y < out_height; y++) {
      for (size_t x = 0; x < out_width; x++) {
        float u = (float)x * scale_x;
        float v = (float)y * scale_y;
        out_pixels[p] =
            catmullrom_interp(in_pixels, in_width, in_height, u, v, a);
        p += 1;
      }
    }
  }
}


x86 assembly (clang, -O0):
<neuralops_interpolate2d_catmullrom>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x68(%rbp)
test   %rax,%rax
movss  %xmm0,-0x64(%rbp)
js     1174 <neuralops_interpolate2d_catmullrom+0x64>
movss  -0x68(%rbp),%xmm0
movss  %xmm0,-0x64(%rbp)
movss  -0x64(%rbp),%xmm0
movss  %xmm0,-0x74(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x70(%rbp)
test   %rax,%rax
movss  %xmm0,-0x6c(%rbp)
js     11bb <neuralops_interpolate2d_catmullrom+0xab>
movss  -0x70(%rbp),%xmm0
movss  %xmm0,-0x6c(%rbp)
movss  -0x74(%rbp),%xmm0
movss  -0x6c(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x7c(%rbp)
test   %rax,%rax
movss  %xmm0,-0x78(%rbp)
js     120b <neuralops_interpolate2d_catmullrom+0xfb>
movss  -0x7c(%rbp),%xmm0
movss  %xmm0,-0x78(%rbp)
movss  -0x78(%rbp),%xmm0
movss  %xmm0,-0x88(%rbp)
ff
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x84(%rbp)
ff
test   %rax,%rax
movss  %xmm0,-0x80(%rbp)
js     125b <neuralops_interpolate2d_catmullrom+0x14b>
movss  -0x84(%rbp),%xmm0
ff
movss  %xmm0,-0x80(%rbp)
movss  -0x88(%rbp),%xmm0
ff
movss  -0x80(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    13ea <neuralops_interpolate2d_catmullrom+0x2da>
movq   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    13d4 <neuralops_interpolate2d_catmullrom+0x2c4>
movq   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    13be <neuralops_interpolate2d_catmullrom+0x2ae>
mov    -0x58(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x90(%rbp)
ff
test   %rax,%rax
movss  %xmm0,-0x8c(%rbp)
ff
js     1304 <neuralops_interpolate2d_catmullrom+0x1f4>
movss  -0x90(%rbp),%xmm0
ff
movss  %xmm0,-0x8c(%rbp)
ff
movss  -0x8c(%rbp),%xmm0
ff
movss  -0x34(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x5c(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x98(%rbp)
ff
test   %rax,%rax
movss  %xmm0,-0x94(%rbp)
ff
js     1363 <neuralops_interpolate2d_catmullrom+0x253>
movss  -0x98(%rbp),%xmm0
ff
movss  %xmm0,-0x94(%rbp)
ff
movss  -0x94(%rbp),%xmm0
ff
mulss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x60(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
movss  -0x5c(%rbp),%xmm0
movss  -0x60(%rbp),%xmm1
mov    -0x48(%rbp),%rcx
call   1030 <catmullrom_interp@plt>
mov    0x10(%rbp),%rax
mov    -0x40(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    12ad <neuralops_interpolate2d_catmullrom+0x19d>
jmp    13c3 <neuralops_interpolate2d_catmullrom+0x2b3>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    1297 <neuralops_interpolate2d_catmullrom+0x187>
jmp    13d9 <neuralops_interpolate2d_catmullrom+0x2c9>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    1281 <neuralops_interpolate2d_catmullrom+0x171>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<neuralops_interpolate2d_catmullrom>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,0x30(%rsp)
mov    %rcx,%rbx
mov    %rdx,0x10(%rsp)
mov    %rsi,%r13
mov    %rdi,%rbp
test   %rdi,%rdi
js     113d <neuralops_interpolate2d_catmullrom+0x2d>
cvtsi2ss %rbp,%xmm0
jmp    1154 <neuralops_interpolate2d_catmullrom+0x44>
mov    %rbp,%rax
shr    %rax
mov    %ebp,%ecx
and    $0x1,%ecx
or     %rax,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
test   %rbx,%rbx
js     1186 <neuralops_interpolate2d_catmullrom+0x76>
xorps  %xmm0,%xmm0
cvtsi2ss %rbx,%xmm0
test   %r13,%r13
jns    11a5 <neuralops_interpolate2d_catmullrom+0x95>
mov    %r13,%rax
shr    %rax
mov    %r13d,%ecx
and    $0x1,%ecx
or     %rax,%rcx
cvtsi2ss %rcx,%xmm1
addss  %xmm1,%xmm1
jmp    11aa <neuralops_interpolate2d_catmullrom+0x9a>
mov    %rbx,%rax
shr    %rax
mov    %ebx,%ecx
and    $0x1,%ecx
or     %rax,%rcx
xorps  %xmm0,%xmm0
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
test   %r13,%r13
js     116c <neuralops_interpolate2d_catmullrom+0x5c>
cvtsi2ss %r13,%xmm1
movss  %xmm1,0x4(%rsp)
test   %r8,%r8
js     11ca <neuralops_interpolate2d_catmullrom+0xba>
xorps  %xmm1,%xmm1
cvtsi2ss %r8,%xmm1
cmpq   $0x0,0x10(%rsp)
jne    11f1 <neuralops_interpolate2d_catmullrom+0xe1>
jmp    131c <neuralops_interpolate2d_catmullrom+0x20c>
mov    %r8,%rax
shr    %rax
mov    %r8d,%ecx
and    $0x1,%ecx
or     %rax,%rcx
xorps  %xmm1,%xmm1
cvtsi2ss %rcx,%xmm1
addss  %xmm1,%xmm1
cmpq   $0x0,0x10(%rsp)
je     131c <neuralops_interpolate2d_catmullrom+0x20c>
movss  0x8(%rsp),%xmm2
divss  %xmm0,%xmm2
movss  %xmm2,0x8(%rsp)
movss  0x4(%rsp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,0x4(%rsp)
xor    %edx,%edx
xor    %r12d,%r12d
mov    %r8,0x18(%rsp)
jmp    122f <neuralops_interpolate2d_catmullrom+0x11f>
nopl   (%rax)
add    $0x1,%r12
cmp    0x10(%rsp),%r12
je     131c <neuralops_interpolate2d_catmullrom+0x20c>
test   %r8,%r8
je     1220 <neuralops_interpolate2d_catmullrom+0x110>
xor    %ecx,%ecx
jmp    125b <neuralops_interpolate2d_catmullrom+0x14b>
nopl   0x0(%rax,%rax,1)
mov    0x28(%rsp),%rdx
add    %r14,%rdx
mov    0x18(%rsp),%r8
mov    0x20(%rsp),%rcx
add    $0x1,%rcx
cmp    %r8,%rcx
je     1220 <neuralops_interpolate2d_catmullrom+0x110>
test   %rbx,%rbx
je     1252 <neuralops_interpolate2d_catmullrom+0x142>
test   %rcx,%rcx
mov    %rcx,0x20(%rsp)
js     1280 <neuralops_interpolate2d_catmullrom+0x170>
xorps  %xmm0,%xmm0
cvtsi2ss %rcx,%xmm0
jmp    1298 <neuralops_interpolate2d_catmullrom+0x188>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rcx,%rax
shr    %rax
and    $0x1,%ecx
or     %rax,%rcx
xorps  %xmm0,%xmm0
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
mulss  0x4(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
mov    0x70(%rsp),%rax
mov    %rdx,0x28(%rsp)
lea    (%rax,%rdx,4),%r15
xor    %r14d,%r14d
jmp    12fa <neuralops_interpolate2d_catmullrom+0x1ea>
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2ss %r14,%xmm0
movss  0xc(%rsp),%xmm1
mulss  0x8(%rsp),%xmm0
mov    0x30(%rsp),%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
mov    %r12,%rcx
call   1030 <catmullrom_interp@plt>
movss  %xmm0,(%r15,%r14,4)
add    $0x1,%r14
cmp    %r14,%rbx
je     1240 <neuralops_interpolate2d_catmullrom+0x130>
test   %r14,%r14
jns    12c0 <neuralops_interpolate2d_catmullrom+0x1b0>
mov    %r14,%rax
shr    %rax
mov    %r14d,%ecx
and    $0x1,%ecx
or     %rax,%rcx
xorps  %xmm0,%xmm0
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
jmp    12c8 <neuralops_interpolate2d_catmullrom+0x1b8>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @neuralops_interpolate2d_catmullrom(i64 %0, i64 %1, i64 %2, i64 %3, i64 %4, float* %5, float* nocapture writeonly %6) {
%8 = uitofp i64 %0 to float
%9 = uitofp i64 %3 to float
%10 = fdiv float %8, %9
%11 = uitofp i64 %1 to float
%12 = uitofp i64 %4 to float
%13 = fdiv float %11, %12
%14 = icmp eq i64 %2, 0
br i1 %14, label %21, label %15
15: ; preds = %7
%16 = icmp eq i64 %4, 0
%17 = icmp eq i64 %3, 0
br label %18
18: ; preds = %15, %28
%19 = phi i64 [ 0, %15 ], [ %29, %28 ]
%20 = phi i64 [ 0, %15 ], [ %30, %28 ]
br i1 %16, label %28, label %22
21: ; preds = %28, %7
ret void
22: ; preds = %18, %32
%23 = phi i64 [ %33, %32 ], [ %19, %18 ]
%24 = phi i64 [ %34, %32 ], [ 0, %18 ]
br i1 %17, label %32, label %25
25: ; preds = %22
%26 = uitofp i64 %24 to float
%27 = fmul float %13, %26
br label %36
28: ; preds = %32, %18
%29 = phi i64 [ %19, %18 ], [ %33, %32 ]
%30 = add nuw i64 %20, 1
%31 = icmp eq i64 %30, %2
br i1 %31, label %21, label %18
32: ; preds = %36, %22
%33 = phi i64 [ %23, %22 ], [ %43, %36 ]
%34 = add nuw i64 %24, 1
%35 = icmp eq i64 %34, %4
br i1 %35, label %28, label %22
36: ; preds = %25, %36
%37 = phi i64 [ %23, %25 ], [ %43, %36 ]
%38 = phi i64 [ 0, %25 ], [ %44, %36 ]
%39 = uitofp i64 %38 to float
%40 = fmul float %10, %39
%41 = tail call float @catmullrom_interp(float* %5, i64 %0, i64 %1, float %40, float %27, i64 %20)
%42 = getelementptr inbounds float, float* %6, i64 %37
store float %41, float* %42
%43 = add i64 %37, 1
%44 = add nuw i64 %38, 1
%45 = icmp eq i64 %44, %3
br i1 %45, label %32, label %36
}