// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/instancelist.c
// Function: find_nearest_neighbors_before_normalize
Instanceptr* find_nearest_neighbors_before_normalize(Instanceptr list, Instanceptr item, int count, Instance mean, Instance variance)
{
 /*!Last Changed 17.05.2004*/
 Instanceptr* neighbors, data;
 double* distances, d;
 int i, j;
 neighbors = (Instanceptr*) safemalloc (count * sizeof(Instanceptr), "find_nearest_neighbors", 4);
 distances = (double *) safemalloc(count * sizeof(double), "find_nearest_neighbors", 5);
 for (i = 0; i < count; i++)
  {
   distances[i] = (double) +LONG_MAX;
   neighbors[i] = NULL;
  }
 data = list;
 while (data)
  {
   d = distance_between_instances_before_normalize(data, item, mean, variance);
   if (d < distances[count - 1])
    {
     i = 0;
     while (distances[i] < d)
       i++;
     for (j = count - 1; j > i; j--)
      {
       neighbors[j] = neighbors[j - 1];
       distances[j] = distances[j - 1];
      }
     neighbors[i] = data;
     distances[i] = d;
    }
   data = data->next;
  }
 safe_free(distances);
 return neighbors;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
leaq 0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq 0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movslq -0x14(%rbp), %rdi
shlq $0x3, %rdi
leaq 0x9ed6d(%rip), %rsi     # 0xe5722
movl $0x4, %edx
callq 0x52d70
movq %rax, -0x20(%rbp)
movslq -0x14(%rbp), %rdi
shlq $0x3, %rdi
leaq 0x9ed50(%rip), %rsi     # 0xe5722
movl $0x5, %edx
callq 0x52d70
movq %rax, -0x30(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x46a1f
movq -0x30(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd 0x9c5b1(%rip), %xmm0    # 0xe2fb0
movsd %xmm0, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x469e7
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x46b52
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %rax
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rsi
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movq %rsp, %rax
movups %xmm2, 0x50(%rax)
movups %xmm1, 0x40(%rax)
movups %xmm0, 0x30(%rax)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups 0x20(%rcx), %xmm2
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x43f70
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm1
movq -0x30(%rbp), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x46b41
movl $0x0, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd -0x38(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x46ac7
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x46aa4
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jle 0x46b1f
movq -0x20(%rbp), %rax
movl -0x40(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
movq -0x20(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rax
movl -0x40(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x40(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x46ad0
movq -0x28(%rbp), %rdx
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movsd -0x38(%rbp), %xmm0
movq -0x30(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x46a27
movq -0x30(%rbp), %rdi
callq 0x52e80
movq -0x20(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax,%rax)