#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 */
int /*<<< orphan*/ printf(char *, float, float);
scalar_t__ rintf(float);
int interpNNpr_b(unsigned char *sl, int w, int h, float x, float y, float o,
                 unsigned char *v) {
  printf("u=%5.3f v=%5.3f     ", x / (w - 1), y / (h - 1));
  *v = sl[(int)rintf(x) + (int)rintf(y) * w];
  return 0;
}


x86 assembly (clang, -O0):
<interpNNpr_b>:
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)
movss  %xmm2,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
movss  -0x14(%rbp),%xmm0
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
movss  -0x18(%rbp),%xmm1
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm2
divss  %xmm2,%xmm1
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
movss  -0x14(%rbp),%xmm0
call   1040 <rintf@plt>
mov    %eax,-0x34(%rbp)
movss  -0x18(%rbp),%xmm0
call   1040 <rintf@plt>
mov    -0x34(%rbp),%ecx
mov    %rax,%rdx
mov    -0x30(%rbp),%rax
imul   -0xc(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interpNNpr_b>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %esi,%r12d
lea    -0x1(%r12),%eax
cvtsi2ss %eax,%xmm2
mov    %rcx,%r14
movss  %xmm1,0x4(%rsp)
movss  %xmm0,(%rsp)
mov    %rdi,%r15
divss  %xmm2,%xmm0
add    $0xffffffff,%edx
xorps  %xmm2,%xmm2
cvtsi2ss %edx,%xmm2
divss  %xmm2,%xmm1
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
movss  (%rsp),%xmm0
call   1040 <rintf@plt>
mov    %rax,%rbx
movss  0x4(%rsp),%xmm0
call   1040 <rintf@plt>
imul   %r12d,%eax
add    %ebx,%eax
cltq
mov    (%r15,%rax,1),%al
mov    %al,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"u=%5.3f v=%5.3f \00"
define i32 @interpNNpr_b(i8* %0, i32 %1, i32 %2, float %3, float %4, float %5, i8* %6) {
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca i8*
store i8* %0, i8** %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store float %3, float* %11
store float %4, float* %12
store float %5, float* %13
store i8* %6, i8** %14
%15 = load float, float* %11
%16 = load i32, i32* %9
%17 = sub nsw i32 %16, 1
%18 = sitofp i32 %17 to float
%19 = fdiv float %15, %18
%20 = load float, float* %12
%21 = load i32, i32* %10
%22 = sub nsw i32 %21, 1
%23 = sitofp i32 %22 to float
%24 = fdiv float %20, %23
%25 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), float %19, float %24)
%26 = load i8*, i8** %8
%27 = load float, float* %11
%28 = call i64 @rintf(float %27)
%29 = trunc i64 %28 to i32
%30 = load float, float* %12
%31 = call i64 @rintf(float %30)
%32 = trunc i64 %31 to i32
%33 = load i32, i32* %9
%34 = mul nsw i32 %32, %33
%35 = add nsw i32 %29, %34
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %26, i64 %36
%38 = load i8, i8* %37
%39 = load i8*, i8** %14
store i8 %38, i8* %39
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"u=%5.3f v=%5.3f \00"
define i32 @interpNNpr_b(i8* nocapture %0, i32 %1, i32 %2, float %3, float %4, float %5, i8* nocapture writeonly %6) {
%8 = add nsw i32 %1, -1
%9 = sitofp i32 %8 to float
%10 = fdiv float %3, %9
%11 = add nsw i32 %2, -1
%12 = sitofp i32 %11 to float
%13 = fdiv float %4, %12
%14 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), float %10, float %13)
%15 = tail call i64 @rintf(float %3)
%16 = trunc i64 %15 to i32
%17 = tail call i64 @rintf(float %4)
%18 = trunc i64 %17 to i32
%19 = mul nsw i32 %18, %1
%20 = add nsw i32 %19, %16
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %0, i64 %21
%23 = load i8, i8* %22
store i8 %23, i8* %6
ret i32 0
}