// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/dataset.c
// Function: nn_nonlinearity
double nn_nonlinearity(Datasetptr d, Instanceptr testdata)
{
 /*!Last Changed 07.05.2006 Oya*/
 Instance mean, variance;
 Instanceptr temp, traindata, *nearestneighbors;
 int count, cno1, cno2;
 double result = 0;
 int intranum = 0, internum = 0;
 read_from_train_file(d, &traindata);
 mean = find_mean(traindata);
 variance = find_variance(traindata);
 normalize(traindata, mean, variance);
 normalize(testdata, mean, variance);
 type_change(d);
 temp = testdata;
 count = 1;
 while (temp)
  {
   nearestneighbors = find_nearest_neighbors(traindata, temp, count);
   cno1 = give_classno(nearestneighbors[0]);
   cno2 = give_classno(temp);
   if (cno1 == cno2)
     intranum++;
   else
     internum++;
   temp = temp->next;
   safe_free(nearestneighbors);
  }
 result = (double) internum / (internum + intranum);
 safe_free(mean.values);
 safe_free(variance.values);
 deallocate(traindata);
 type_restore(d);
 return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x60(%rsp), %r12
movq %r12, %rsi
callq 0x5c7af
movq (%r12), %rsi
leaq 0x98(%rsp), %r15
movq %r15, %rdi
callq 0x12519
movq (%r12), %rsi
leaq 0x68(%rsp), %r13
movq %r13, %rdi
callq 0x1286d
movq (%r12), %rdi
movups (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups 0x20(%r13), %xmm2
movups %xmm2, 0x50(%rsp)
movups %xmm1, 0x40(%rsp)
movups %xmm0, 0x30(%rsp)
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x107bc
movups (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups 0x20(%r13), %xmm2
movups %xmm2, 0x50(%rsp)
movups %xmm1, 0x40(%rsp)
movups %xmm0, 0x30(%rsp)
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r14, %rdi
callq 0x107bc
movslq 0x1bc(%rbx), %rax
testq %rax, %rax
jle 0x1a4e2
imulq $0x340, %rax, %rax      # imm = 0x340
xorl %ecx, %ecx
movl 0x30f08(%rbx,%rcx), %edx
movl %edx, 0x30f0c(%rbx,%rcx)
testl %edx, %edx
jne 0x1a4d6
movl $0x2, 0x30f08(%rbx,%rcx)
addq $0x340, %rcx            # imm = 0x340
cmpq %rcx, %rax
jne 0x1a4b9
testq %r14, %r14
je 0x1a539
xorl %r13d, %r13d
xorl %r12d, %r12d
movq 0x60(%rsp), %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x30ca9
movq %rax, %r15
movq (%rax), %rdi
callq 0x2eaca
movl %eax, %ebp
movq %r14, %rdi
callq 0x2eaca
xorl %ecx, %ecx
xorl %edx, %edx
cmpl %eax, %ebp
setne %cl
sete %dl
addl %edx, %r12d
addl %ecx, %r13d
movq 0x10(%r14), %r14
movq %r15, %rdi
callq 0x39194
testq %r14, %r14
jne 0x1a4ed
jmp 0x1a53f
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x98(%rsp), %rdi
callq 0x39194
movq 0x68(%rsp), %rdi
callq 0x39194
movq 0x60(%rsp), %rdi
callq 0x2f616
movslq 0x1bc(%rbx), %rax
testq %rax, %rax
jle 0x1a58f
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 0x1a575
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
addl %r13d, %r12d
xorps %xmm1, %xmm1
cvtsi2sd %r12d, %xmm1
divsd %xmm1, %xmm0
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq