#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*/ free(float *);
float *fvec_new(int);
int /*<<< orphan*/ knn_full(int, int, int, int, int, float const *,
                            float const *, int /*<<< orphan*/ *, int *, float *,
                            void (*)(void *, double), void *);
void nn(int npt, int nclust, int d, const float *codebook, const float *coords,
        int *vw, void (*peek_fun)(void *arg, double frac), void *peek_arg) {
  float *vwdis = fvec_new(npt);
  knn_full(2, npt, nclust, d, 1, codebook, coords, NULL, vw, vwdis, peek_fun,
           peek_arg);
  free(vwdis);
}


x86 assembly (clang, -O0):
<nn>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x1c(%rbp)
mov    %esi,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    %r9,-0x40(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <fvec_new@plt>
mov    %rax,-0x48(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x30(%rbp),%r9
mov    -0x38(%rbp),%r14
mov    -0x40(%rbp),%rbx
mov    -0x48(%rbp),%r11
mov    0x10(%rbp),%r10
mov    0x18(%rbp),%rax
mov    $0x2,%edi
mov    $0x1,%r8d
xor    %r15d,%r15d
mov    %r14,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
call   1040 <knn_full@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<nn>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9,%rbx
mov    %r8,%r14
mov    %rcx,0x38(%rsp)
mov    %edx,%r12d
mov    %esi,%r13d
mov    %edi,%ebp
movaps 0x90(%rsp),%xmm0
movaps %xmm0,0x40(%rsp)
call   1050 <fvec_new@plt>
mov    %rax,%r15
movaps 0x40(%rsp),%xmm0
movups %xmm0,0x20(%rsp)
mov    %rax,0x18(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r14,(%rsp)
movq   $0x0,0x8(%rsp)
mov    $0x2,%edi
mov    %ebp,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    $0x1,%r8d
mov    0x38(%rsp),%r9
call   1040 <knn_full@plt>
mov    %r15,%rdi
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @nn(i32 %0, i32 %1, i32 %2, float* %3, float* %4, i32* %5, void (i8*, double)* %6, i8* %7) {
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca float*
%13 = alloca float*
%14 = alloca i32*
%15 = alloca void (i8*, double)*
%16 = alloca i8*
%17 = alloca float*
store i32 %0, i32* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store float* %3, float** %12
store float* %4, float** %13
store i32* %5, i32** %14
store void (i8*, double)* %6, void (i8*, double)** %15
store i8* %7, i8** %16
%18 = load i32, i32* %9
%19 = call float* @fvec_new(i32 %18)
store float* %19, float** %17
%20 = load i32, i32* %9
%21 = load i32, i32* %10
%22 = load i32, i32* %11
%23 = load float*, float** %12
%24 = load float*, float** %13
%25 = load i32*, i32** %14
%26 = load float*, float** %17
%27 = load void (i8*, double)*, void (i8*, double)** %15
%28 = load i8*, i8** %16
%29 = call i32 @knn_full(i32 2, i32 %20, i32 %21, i32 %22, i32 1, float* %23, float* %24, i32* null, i32* %25, float* %26, void (i8*, double)* %27, i8* %28)
%30 = load float*, float** %17
%31 = call i32 @free(float* %30)
ret void
}

LLVM IR (-O2):
define void @nn(i32 %0, i32 %1, i32 %2, float* %3, float* %4, i32* %5, void (i8*, double)* %6, i8* %7) {
%9 = tail call float* @fvec_new(i32 %0)
%10 = tail call i32 @knn_full(i32 2, i32 %0, i32 %1, i32 %2, i32 1, float* %3, float* %4, i32* null, i32* %5, float* %9, void (i8*, double)* %6, i8* %7)
%11 = tail call i32 @free(float* %9)
ret void
}