#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, int is_atop) {
  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)
mov    %r8d,-0x2c(%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    0xe8a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
movss  -0x14(%rbp),%xmm0
call   1040 <rintf@plt>
mov    %eax,-0x3c(%rbp)
movss  -0x18(%rbp),%xmm0
call   1040 <rintf@plt>
mov    -0x3c(%rbp),%ecx
mov    %rax,%rdx
mov    -0x38(%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, i32 %7) {
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca i8*
%16 = alloca i32
store i8* %0, i8** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store float %3, float* %12
store float %4, float* %13
store float %5, float* %14
store i8* %6, i8** %15
store i32 %7, i32* %16
%17 = load float, float* %12
%18 = load i32, i32* %10
%19 = sub nsw i32 %18, 1
%20 = sitofp i32 %19 to float
%21 = fdiv float %17, %20
%22 = load float, float* %13
%23 = load i32, i32* %11
%24 = sub nsw i32 %23, 1
%25 = sitofp i32 %24 to float
%26 = fdiv float %22, %25
%27 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), float %21, float %26)
%28 = load i8*, i8** %9
%29 = load float, float* %12
%30 = call i64 @rintf(float %29)
%31 = trunc i64 %30 to i32
%32 = load float, float* %13
%33 = call i64 @rintf(float %32)
%34 = trunc i64 %33 to i32
%35 = load i32, i32* %10
%36 = mul nsw i32 %34, %35
%37 = add nsw i32 %31, %36
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %28, i64 %38
%40 = load i8, i8* %39
%41 = load i8*, i8** %15
store i8 %40, i8* %41
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, i32 %7) {
%9 = add nsw i32 %1, -1
%10 = sitofp i32 %9 to float
%11 = fdiv float %3, %10
%12 = add nsw i32 %2, -1
%13 = sitofp i32 %12 to float
%14 = fdiv float %4, %13
%15 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), float %11, float %14)
%16 = tail call i64 @rintf(float %3)
%17 = trunc i64 %16 to i32
%18 = tail call i64 @rintf(float %4)
%19 = trunc i64 %18 to i32
%20 = mul nsw i32 %19, %1
%21 = add nsw i32 %20, %17
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = load i8, i8* %23
store i8 %24, i8* %6
ret i32 0
}