// File: /workspace/github_c_makefile_star2_O1/DVaronos[P]AnLogProject1/logistic.c
// Function: Testing
void Testing(char* filename,Model* model,Hash* H){
  FILE* fptr = fopen(filename, "r");
  int tcount,match;
  char line[300];
  char* token=NULL;
  char* first;
  char* second;
  double p;
  double correct=0,sum=0;
  HVector* F;
  HVector* S;
  HVector* Con;
  while (fgets(line,sizeof(line),fptr)){//Diavazei to csv file grami grami
    token=strtok(line,",");
    if(!strcmp(token,"left_spec_id"))  continue;
    tcount=0;
    while(token!=NULL){//apothikefsi tou kathe stixoiou ths gramhs se metavlites
     tcount++;
     switch(tcount){
       case 1://ean tcount==1 tote to token isoute me to proto proion
         first=malloc(sizeof(char)*(strlen(token)+1));
         strcpy(first,token);
         break;
       case 2://ean tcount==2 tote to token isoute me to deftero proion
         second=malloc(sizeof(char)*(strlen(token)+1));
         strcpy(second,token);
         break;
       case 3://Ean tcount==3 tote to token einai 0 h 1 analoga to an teriazoun ta proionta
         match=atoi(token);
         break;
     }
     token=strtok(NULL,",");
   }
   F=GetCameraVector(first,H);
   S=GetCameraVector(second,H);
   Con=VectorConcat(F,S,(model->array_size)/2);
   p=Predict(&(model->weight_array),&(model->b),Con);
	 double cor;
   cor=1-p;
   sum++;
   if(cor>0.4){
     if(!match) correct++;
   }else{
     if(match)correct++;
   }
   free(first);
   free(second);
	 free(Con);
 }
 fclose(fptr);
 printf("Success rate is:%f\n",correct/sum);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rdx, -0x68(%rbp)
movq %rsi, %r14
leaq 0x3899(%rip), %rsi      # 0x6016
callq 0x1200
movq %rax, %r15
movq %r14, -0x60(%rbp)
leaq 0x8(%r14), %rbx
xorpd %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
leaq -0x1a0(%rbp), %r13
leaq 0x3b54(%rip), %r12      # 0x62f8
movsd %xmm0, -0x40(%rbp)
movq %r13, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r15, %rdx
callq 0x1120
testq %rax, %rax
je 0x291f
movq %r13, %rdi
movq %r12, %rsi
callq 0x1220
movq %rax, %r14
movq %rax, %rdi
leaq 0x387d(%rip), %rsi      # 0x6057
callq 0x1140
testl %eax, %eax
je 0x27a9
movq %rbx, -0x58(%rbp)
testq %r14, %r14
je 0x2854
xorl %ebx, %ebx
cmpl $0x2, %ebx
je 0x2835
cmpl $0x1, %ebx
je 0x2813
testl %ebx, %ebx
jne 0x2840
movq %r14, %rdi
callq 0x10c0
leaq 0x1(%rax), %rdi
callq 0x11a0
movq %rax, -0x48(%rbp)
jmp 0x2828
movq %r14, %rdi
callq 0x10c0
leaq 0x1(%rax), %rdi
callq 0x11a0
movq %rax, -0x50(%rbp)
movq %rax, %rdi
movq %r14, %rsi
callq 0x1060
jmp 0x2840
movq %r14, %rdi
callq 0x1240
movl %eax, -0x34(%rbp)
xorl %edi, %edi
movq %r12, %rsi
callq 0x1220
movq %rax, %r14
incl %ebx
testq %rax, %rax
jne 0x27ee
movq -0x48(%rbp), %rdi
movq -0x68(%rbp), %rbx
movq %rbx, %rsi
callq 0x1eb9
movq %rax, %r14
movq -0x50(%rbp), %rdi
movq %rbx, %rsi
callq 0x1eb9
movq -0x60(%rbp), %rbx
movl 0x10(%rbx), %ecx
movl %ecx, %edx
shrl $0x1f, %edx
addl %ecx, %edx
sarl %edx
movq %r14, %rdi
movq %rax, %rsi
callq 0x1f59
movq %rax, %r14
movq %rbx, %rdi
movq -0x58(%rbp), %rbx
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2951
xorpd 0x3995(%rip), %xmm0     # 0x6240
callq 0x12a0
movsd 0x3960(%rip), %xmm2     # 0x6218
addsd %xmm2, %xmm0
movapd %xmm2, %xmm1
divsd %xmm0, %xmm1
movapd %xmm2, %xmm0
subsd %xmm1, %xmm0
ucomisd 0x395c(%rip), %xmm0     # 0x6230
jbe 0x28de
cmpl $0x0, -0x34(%rbp)
jne 0x28f2
jmp 0x28e4
cmpl $0x0, -0x34(%rbp)
je 0x28f2
movsd -0x30(%rbp), %xmm0
addsd %xmm2, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x40(%rbp), %xmm0
addsd %xmm2, %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x48(%rbp), %rdi
callq 0x1030
movq -0x50(%rbp), %rdi
callq 0x1030
movq %r14, %rdi
callq 0x1030
jmp 0x27a9
movq %r15, %rdi
callq 0x10a0
movsd -0x30(%rbp), %xmm0
divsd -0x40(%rbp), %xmm0
leaq 0x391b(%rip), %rdi      # 0x6253
movb $0x1, %al
callq 0x10d0
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq