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


x86 assembly (clang, -O0):
<nn_thread>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x70,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %edi,-0x24(%rbp)
mov    %esi,-0x28(%rbp)
mov    %edx,-0x2c(%rbp)
mov    %rcx,-0x38(%rbp)
mov    %r8,-0x40(%rbp)
mov    %r9,-0x48(%rbp)
mov    -0x24(%rbp),%edi
call   1050 <fvec_new@plt>
mov    %rax,-0x50(%rbp)
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x38(%rbp),%r9
mov    -0x40(%rbp),%r15
mov    -0x48(%rbp),%r14
mov    -0x50(%rbp),%rbx
mov    0x10(%rbp),%r11d
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%rax
mov    $0x2,%edi
mov    $0x1,%r8d
xor    %r12d,%r12d
mov    %r15,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %r14,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    %r11d,0x20(%rsp)
mov    %r10,0x28(%rsp)
mov    %rax,0x30(%rsp)
call   1040 <knn_full_thread@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<nn_thread>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9,%rbx
mov    %r8,%r14
mov    %rcx,0x48(%rsp)
mov    %edx,0x44(%rsp)
mov    %esi,%r13d
mov    %edi,%ebp
mov    0xa0(%rsp),%r12d
movups 0xa8(%rsp),%xmm0
movaps %xmm0,0x50(%rsp)
call   1050 <fvec_new@plt>
mov    %rax,%r15
movaps 0x50(%rsp),%xmm0
movups %xmm0,0x28(%rsp)
mov    %r12d,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    0x44(%rsp),%ecx
mov    $0x1,%r8d
mov    0x48(%rsp),%r9
call   1040 <knn_full_thread@plt>
mov    %r15,%rdi
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

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

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