// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/dataset.c
// Function: nn_ratio
double nn_ratio(Datasetptr d, double *estimate)
{
 /* multiclass is handled by one vs one */
 Instance mean, variance;
 Instanceptr temp, traindata, *nearestneighbors;
 int count, cno1, cno2;
 double result = 0;
 double intraclass = 0, interclass = 0, dist;
 int intranum = 0, internum = 0;
 read_from_train_file(d, &traindata);
 mean = find_mean(traindata);
 variance = find_variance(traindata);
 normalize(traindata, mean, variance);
 type_change(d);
 temp = traindata;
 count = 2;
 while(temp)
  {
   nearestneighbors = find_nearest_neighbors(traindata, temp, count);
   dist = distance_between_instances(nearestneighbors[1], temp);
   cno1 = give_classno(nearestneighbors[1]);
   cno2 = give_classno(temp);
   if (cno1 == cno2)
    {
     intraclass += dist;
     intranum++;
    }
   else
    {
     interclass += dist;
     internum++;
    }
   temp = temp->next;
   safe_free(nearestneighbors);
  }
 result = intraclass / interclass;
 *estimate = (double) internum / (internum + intranum); 
 safe_free(mean.values);
 safe_free(variance.values);
 type_restore(d);
 deallocate(traindata);
 traindata = NULL;
 return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rsi, 0x80(%rsp)
movq %rdi, %rbx
leaq 0x70(%rsp), %r15
movq %r15, %rsi
callq 0x5dcbd
movq (%r15), %rsi
leaq 0xb8(%rsp), %r12
movq %r12, %rdi
callq 0x1247b
movq (%r15), %rsi
leaq 0x88(%rsp), %r13
movq %r13, %rdi
callq 0x127bd
movq (%r15), %rdi
movups (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups 0x20(%r13), %xmm2
movups %xmm2, 0x50(%rsp)
movups %xmm1, 0x40(%rsp)
movups %xmm0, 0x30(%rsp)
movupd (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups 0x20(%r12), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
callq 0x107b2
movslq 0x1bc(%rbx), %rax
testq %rax, %rax
jle 0x1a381
imulq $0x340, %rax, %rax      # imm = 0x340
xorl %ecx, %ecx
movl 0x30f08(%rbx,%rcx), %edx
movl %edx, 0x30f0c(%rbx,%rcx)
testl %edx, %edx
jne 0x1a375
movl $0x2, 0x30f08(%rbx,%rcx)
addq $0x340, %rcx            # imm = 0x340
cmpq %rcx, %rax
jne 0x1a358
movq 0x70(%rsp), %r15
testq %r15, %r15
je 0x1a423
xorpd %xmm0, %xmm0
movsd %xmm0, 0x68(%rsp)
xorl %r14d, %r14d
xorl %r13d, %r13d
movsd %xmm0, 0x60(%rsp)
movq 0x70(%rsp), %rdi
movq %r15, %rsi
movl $0x2, %edx
callq 0x3151c
movq %rax, %r12
movq 0x8(%rax), %rdi
movq %r15, %rsi
callq 0x2fe29
movsd %xmm0, 0x78(%rsp)
movq 0x8(%r12), %rdi
callq 0x2f33a
movl %eax, %ebp
movq %r15, %rdi
callq 0x2f33a
cmpl %eax, %ebp
jne 0x1a3fb
movsd 0x60(%rsp), %xmm0
addsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x60(%rsp)
incl %r13d
jmp 0x1a410
movsd 0x68(%rsp), %xmm0
addsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x68(%rsp)
incl %r14d
movq 0x10(%r15), %r15
movq %r12, %rdi
callq 0x3a180
testq %r15, %r15
jne 0x1a3a5
jmp 0x1a439
xorl %r13d, %r13d
xorpd %xmm0, %xmm0
movsd %xmm0, 0x60(%rsp)
movsd %xmm0, 0x68(%rsp)
xorl %r14d, %r14d
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
addl %r14d, %r13d
xorps %xmm1, %xmm1
cvtsi2sd %r13d, %xmm1
divsd %xmm1, %xmm0
movq 0x80(%rsp), %rax
movsd %xmm0, (%rax)
movq 0xb8(%rsp), %rdi
callq 0x3a180
movq 0x88(%rsp), %rdi
callq 0x3a180
movslq 0x1bc(%rbx), %rax
testq %rax, %rax
jle 0x1a4a5
imulq $0x340, %rax, %rax      # imm = 0x340
xorl %ecx, %ecx
movl 0x30f0c(%rbx,%rcx), %edx
movl %edx, 0x30f08(%rbx,%rcx)
addq $0x340, %rcx            # imm = 0x340
cmpq %rcx, %rax
jne 0x1a48b
movsd 0x60(%rsp), %xmm0
divsd 0x68(%rsp), %xmm0
movsd %xmm0, 0x60(%rsp)
movq 0x70(%rsp), %rdi
callq 0x2ff55
movsd 0x60(%rsp), %xmm0
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq