// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/data.c
// Function: distance_matrix_with_k
matrix distance_matrix_with_k(Instanceptr myptr, int k)
{
 /*!Last Changed 31.03.2008*/
 int i, j, size;
 Instanceptr temp1, temp2;
 matrix result;
 double distance, threshold;
 size = data_size(myptr);
 result = matrix_alloc(size, size);
 for (i = 0, temp1 = myptr; i < size; i++, temp1 = temp1->next)
  {
   threshold = find_k_nearest_neighbor_distance(myptr, temp1, k);
   for (j = 0, temp2 = myptr; j < size; j++, temp2 = temp2->next)    
    {
     distance = distance_between_instances(temp1, temp2);
     if (distance < threshold + DBL_DELTA)
       result.values[i][j] = distance;
     else
       result.values[i][j] = +LONG_MAX;
    }
  }
 /*Make distance matrix symmetric*/
 for (i = 0; i < size; i++)
   for (j = i + 1; j < size; j++)
     if (result.values[i][j] < result.values[j][i])
       result.values[j][i] = result.values[i][j];
     else
       result.values[i][j] = result.values[j][i];     
 return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x18(%rbp)
movl %esi, -0x1c(%rbp)
movq -0x18(%rbp), %rdi
callq 0x449f0
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %edi
movl -0x28(%rbp), %esi
callq 0x57fc0
movq %rax, -0x58(%rbp)
movq %rdx, -0x50(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x0, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x175a0
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0x46cf0
movsd %xmm0, -0x48(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x17584
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x442e0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm1
movsd 0xcb54c(%rip), %xmm0    # 0xe2a70
addsd -0x48(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1754b
movsd -0x40(%rbp), %xmm0
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x17568
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
movsd 0xcba4d(%rip), %xmm0    # 0xe2fb0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x1756a
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x174fd
jmp 0x17586
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x174cd
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x1766e
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x1765e
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x20(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x17624
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x20(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x1764e
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x20(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x17650
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x175bc
jmp 0x17660
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x175a7
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rdx
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)