#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 getpix(float *, int, int, int, int);
float marchi(float, float, float, float, float, float);
float marching_interpolation_at(float *x, int w, int h, float p, float q) {
  int ip = p;
  int iq = q;
  float a = getpix(x, w, h, ip, iq);
  float b = getpix(x, w, h, ip, iq + 1);
  float c = getpix(x, w, h, ip + 1, iq);
  float d = getpix(x, w, h, ip + 1, iq + 1);
  float r = marchi(a, b, c, d, p - ip, q - iq);
  return r;
}


x86 assembly (clang, -O0):
<marching_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),%ecx
mov    -0x20(%rbp),%r8d
call   1030 <getpix@plt>
movss  %xmm0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
add    $0x1,%r8d
call   1030 <getpix@plt>
movss  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%r8d
call   1030 <getpix@plt>
movss  %xmm0,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%r8d
add    $0x1,%r8d
call   1030 <getpix@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   1040 <marchi@plt>
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<marching_interpolation_at>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movaps %xmm1,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbp
cvttss2si %xmm0,%ebx
cvttss2si %xmm1,%r12d
mov    %ebx,%ecx
mov    %r12d,%r8d
call   1030 <getpix@plt>
movss  %xmm0,0xc(%rsp)
lea    0x1(%r12),%r13d
mov    %rbp,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
mov    %r13d,%r8d
call   1030 <getpix@plt>
movss  %xmm0,0x8(%rsp)
add    $0x1,%ebx
mov    %rbp,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
mov    %r12d,%r8d
call   1030 <getpix@plt>
movss  %xmm0,0x4(%rsp)
mov    %rbp,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
mov    %r13d,%r8d
call   1030 <getpix@plt>
movaps %xmm0,%xmm3
movaps 0x10(%rsp),%xmm4
cvttps2dq %xmm4,%xmm0
cvtdq2ps %xmm0,%xmm0
subss  %xmm0,%xmm4
movaps 0x20(%rsp),%xmm5
cvttps2dq %xmm5,%xmm0
cvtdq2ps %xmm0,%xmm0
subss  %xmm0,%xmm5
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
movss  0x4(%rsp),%xmm2
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <marchi@plt>

LLVM IR (-O0):
define float @marching_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 @getpix(float* %22, i32 %23, i32 %24, i32 %25, i32 %26)
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 = load i32, i32* %12
%33 = add nsw i32 %32, 1
%34 = call float @getpix(float* %28, i32 %29, i32 %30, i32 %31, i32 %33)
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 = add nsw i32 %38, 1
%40 = load i32, i32* %12
%41 = call float @getpix(float* %35, i32 %36, i32 %37, i32 %39, i32 %40)
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 @getpix(float* %42, i32 %43, i32 %44, i32 %46, i32 %48)
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 @marchi(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 @marching_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 @getpix(float* %0, i32 %1, i32 %2, i32 %6, i32 %7)
%9 = add nsw i32 %7, 1
%10 = tail call float @getpix(float* %0, i32 %1, i32 %2, i32 %6, i32 %9)
%11 = add nsw i32 %6, 1
%12 = tail call float @getpix(float* %0, i32 %1, i32 %2, i32 %11, i32 %7)
%13 = tail call float @getpix(float* %0, i32 %1, i32 %2, i32 %11, i32 %9)
%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 @marchi(float %8, float %10, float %12, float %13, float %15, float %17)
ret float %18
}