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


x86 assembly (clang, -O0):
<interpNNpr_b>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movss  %xmm1,-0x18(%rbp)
mov    %rcx,-0x20(%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    0xe93(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
movss  -0x14(%rbp),%xmm0
call   1040 <roundf@plt>
mov    %eax,-0x2c(%rbp)
movss  -0x18(%rbp),%xmm0
call   1040 <roundf@plt>
mov    -0x2c(%rbp),%ecx
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
imul   -0xc(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
xor    %eax,%eax
add    $0x30,%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 <roundf@plt>
mov    %rax,%rbx
movss  0x4(%rsp),%xmm0
call   1040 <roundf@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, i8* %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca float
%11 = alloca float
%12 = alloca i8*
store i8* %0, i8** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store float %3, float* %10
store float %4, float* %11
store i8* %5, i8** %12
%13 = load float, float* %10
%14 = load i32, i32* %8
%15 = sub nsw i32 %14, 1
%16 = sitofp i32 %15 to float
%17 = fdiv float %13, %16
%18 = load float, float* %11
%19 = load i32, i32* %9
%20 = sub nsw i32 %19, 1
%21 = sitofp i32 %20 to float
%22 = fdiv float %18, %21
%23 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), float %17, float %22)
%24 = load i8*, i8** %7
%25 = load float, float* %10
%26 = call i64 @roundf(float %25)
%27 = trunc i64 %26 to i32
%28 = load float, float* %11
%29 = call i64 @roundf(float %28)
%30 = trunc i64 %29 to i32
%31 = load i32, i32* %8
%32 = mul nsw i32 %30, %31
%33 = add nsw i32 %27, %32
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %24, i64 %34
%36 = load i8, i8* %35
%37 = load i8*, i8** %12
store i8 %36, i8* %37
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, i8* nocapture writeonly %5) {
%7 = add nsw i32 %1, -1
%8 = sitofp i32 %7 to float
%9 = fdiv float %3, %8
%10 = add nsw i32 %2, -1
%11 = sitofp i32 %10 to float
%12 = fdiv float %4, %11
%13 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), float %9, float %12)
%14 = tail call i64 @roundf(float %3)
%15 = trunc i64 %14 to i32
%16 = tail call i64 @roundf(float %4)
%17 = trunc i64 %16 to i32
%18 = mul nsw i32 %17, %1
%19 = add nsw i32 %18, %15
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = load i8, i8* %21
store i8 %22, i8* %5
ret i32 0
}