#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 */
scalar_t__ floor(double);
double nlerp2(double *, double *);
double func_lerp(int w, int h, double *f, double x, double y) {
  int x_f = (int)floor(x);
  int y_f = (int)floor(y);
  double fsub[4] = {f[y_f * w + x_f], f[y_f * w + x_f + 1],
                    f[(y_f + 1) * w + x_f], f[(y_f + 1) * w + x_f + 1]};
  double xin[2] = {x - x_f, y - y_f};
  return nlerp2(xin, fsub);
}


x86 assembly (clang, -O0):
<func_lerp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,-0x24(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x24(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x1,%ecx
imul   -0x4(%rbp),%ecx
add    -0x24(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x1,%ecx
imul   -0x4(%rbp),%ecx
add    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x28(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1030 <nlerp2@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<func_lerp>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %rdx,%rbx
mov    %edi,%r14d
call   1040 <floor@plt>
mov    %rax,%rbp
movsd  (%rsp),%xmm0
call   1040 <floor@plt>
lea    0x1(%rax),%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
imul   %r14d,%eax
add    %ebp,%eax
cltq
movsd  (%rbx,%rax,8),%xmm1
movsd  %xmm1,0x20(%rsp)
movsd  0x8(%rbx,%rax,8),%xmm1
movsd  %xmm1,0x28(%rsp)
imul   %r14d,%ecx
add    %ebp,%ecx
movslq %ecx,%rax
movsd  (%rbx,%rax,8),%xmm1
movsd  %xmm1,0x30(%rsp)
movsd  0x8(%rbx,%rax,8),%xmm1
movsd  %xmm1,0x38(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
movsd  0x8(%rsp),%xmm2
subsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%rsp)
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
lea    0x10(%rsp),%rdi
lea    0x20(%rsp),%rsi
call   1030 <nlerp2@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @func_lerp(i32 %0, i32 %1, double* %2, double %3, double %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca double*
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
%13 = alloca [4 x double]
%14 = alloca [2 x double]
store i32 %0, i32* %6
store i32 %1, i32* %7
store double* %2, double** %8
store double %3, double* %9
store double %4, double* %10
%15 = load double, double* %9
%16 = call i64 @floor(double %15)
%17 = trunc i64 %16 to i32
store i32 %17, i32* %11
%18 = load double, double* %10
%19 = call i64 @floor(double %18)
%20 = trunc i64 %19 to i32
store i32 %20, i32* %12
%21 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%22 = load double*, double** %8
%23 = load i32, i32* %12
%24 = load i32, i32* %6
%25 = mul nsw i32 %23, %24
%26 = load i32, i32* %11
%27 = add nsw i32 %25, %26
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %22, i64 %28
%30 = load double, double* %29
store double %30, double* %21
%31 = getelementptr inbounds double, double* %21, i64 1
%32 = load double*, double** %8
%33 = load i32, i32* %12
%34 = load i32, i32* %6
%35 = mul nsw i32 %33, %34
%36 = load i32, i32* %11
%37 = add nsw i32 %35, %36
%38 = add nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %32, i64 %39
%41 = load double, double* %40
store double %41, double* %31
%42 = getelementptr inbounds double, double* %31, i64 1
%43 = load double*, double** %8
%44 = load i32, i32* %12
%45 = add nsw i32 %44, 1
%46 = load i32, i32* %6
%47 = mul nsw i32 %45, %46
%48 = load i32, i32* %11
%49 = add nsw i32 %47, %48
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %43, i64 %50
%52 = load double, double* %51
store double %52, double* %42
%53 = getelementptr inbounds double, double* %42, i64 1
%54 = load double*, double** %8
%55 = load i32, i32* %12
%56 = add nsw i32 %55, 1
%57 = load i32, i32* %6
%58 = mul nsw i32 %56, %57
%59 = load i32, i32* %11
%60 = add nsw i32 %58, %59
%61 = add nsw i32 %60, 1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %54, i64 %62
%64 = load double, double* %63
store double %64, double* %53
%65 = getelementptr inbounds [2 x double], [2 x double]* %14, i64 0, i64 0
%66 = load double, double* %9
%67 = load i32, i32* %11
%68 = sitofp i32 %67 to double
%69 = fsub double %66, %68
store double %69, double* %65
%70 = getelementptr inbounds double, double* %65, i64 1
%71 = load double, double* %10
%72 = load i32, i32* %12
%73 = sitofp i32 %72 to double
%74 = fsub double %71, %73
store double %74, double* %70
%75 = getelementptr inbounds [2 x double], [2 x double]* %14, i64 0, i64 0
%76 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%77 = call double @nlerp2(double* %75, double* %76)
ret double %77
}

LLVM IR (-O2):
define double @func_lerp(i32 %0, i32 %1, double* nocapture %2, double %3, double %4) {
%6 = alloca [4 x double]
%7 = alloca [2 x double]
%8 = tail call i64 @floor(double %3)
%9 = trunc i64 %8 to i32
%10 = tail call i64 @floor(double %4)
%11 = trunc i64 %10 to i32
%12 = bitcast [4 x double]* %6 to i8*
%13 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 0
%14 = mul nsw i32 %11, %0
%15 = add nsw i32 %14, %9
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %2, i64 %16
%18 = load double, double* %17
store double %18, double* %13
%19 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 1
%20 = add nsw i32 %15, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %2, i64 %21
%23 = load double, double* %22
store double %23, double* %19
%24 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 2
%25 = add nsw i32 %11, 1
%26 = mul nsw i32 %25, %0
%27 = add nsw i32 %26, %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %2, i64 %28
%30 = load double, double* %29
store double %30, double* %24
%31 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 3
%32 = add nsw i32 %27, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %2, i64 %33
%35 = load double, double* %34
store double %35, double* %31
%36 = bitcast [2 x double]* %7 to i8*
%37 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 0
%38 = sitofp i32 %9 to double
%39 = fsub double %3, %38
store double %39, double* %37
%40 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 1
%41 = sitofp i32 %11 to double
%42 = fsub double %4, %41
store double %42, double* %40
%43 = call double @nlerp2(double* %37, double* %13)
ret double %43
}