#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 */
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 *);
float *knn_thread(int npt, int nclust, int d, int k, 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(k * npt);
  knn_full_thread(2, npt, nclust, d, k, codebook, coords, NULL, vw, vwdis2,
                  n_thread, peek_fun, peek_arg);
  return vwdis2;
}


x86 assembly (clang, -O0):
<knn_thread>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x60,%rsp
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %edi,-0x24(%rbp)
mov    %esi,-0x28(%rbp)
mov    %edx,-0x2c(%rbp)
mov    %ecx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    %r9,-0x40(%rbp)
mov    -0x30(%rbp),%edi
imul   -0x24(%rbp),%edi
call   1040 <fvec_new@plt>
mov    %rax,-0x48(%rbp)
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x30(%rbp),%r8d
mov    -0x38(%rbp),%r9
mov    -0x40(%rbp),%r15
mov    0x10(%rbp),%r14
mov    -0x48(%rbp),%rbx
mov    0x18(%rbp),%r11d
mov    0x20(%rbp),%r10
mov    0x28(%rbp),%rax
mov    $0x2,%edi
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   1030 <knn_full_thread@plt>
mov    -0x48(%rbp),%rax
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<knn_thread>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9,%r13
mov    %r8,0x40(%rsp)
mov    %ecx,%ebp
mov    %edx,%r15d
mov    %esi,%r12d
mov    %edi,%ebx
mov    %ecx,%edi
imul   %ebx,%edi
call   1040 <fvec_new@plt>
mov    %rax,%r14
movaps 0x90(%rsp),%xmm0
movups %xmm0,0x28(%rsp)
mov    0x88(%rsp),%eax
mov    %eax,0x20(%rsp)
mov    %r14,0x18(%rsp)
mov    0x80(%rsp),%rax
mov    %rax,0x10(%rsp)
mov    %r13,(%rsp)
movq   $0x0,0x8(%rsp)
mov    $0x2,%edi
mov    %ebx,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
mov    %ebp,%r8d
mov    0x40(%rsp),%r9
call   1030 <knn_full_thread@plt>
mov    %r14,%rax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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