// File: /workspace/github_c_makefile_star2_O3/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 0x38d3(%rip), %rsi      # 0x6010
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 0x3b84(%rip), %r12      # 0x62e8
movsd %xmm0, -0x40(%rbp)
movq %r13, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r15, %rdx
callq 0x1110
testq %rax, %rax
je 0x28df
movq %r13, %rdi
movq %r12, %rsi
callq 0x1220
movq %rax, %r14
movq %rax, %rdi
leaq 0x38b6(%rip), %rsi      # 0x6050
callq 0x1140
testl %eax, %eax
je 0x2769
movq %rbx, -0x58(%rbp)
testq %r14, %r14
je 0x2814
xorl %ebx, %ebx
cmpl $0x2, %ebx
je 0x27f5
cmpl $0x1, %ebx
je 0x27d3
testl %ebx, %ebx
jne 0x2800
movq %r14, %rdi
callq 0x10c0
leaq 0x1(%rax), %rdi
callq 0x11a0
movq %rax, -0x48(%rbp)
jmp 0x27e8
movq %r14, %rdi
callq 0x10c0
leaq 0x1(%rax), %rdi
callq 0x11a0
movq %rax, -0x50(%rbp)
movq %rax, %rdi
movq %r14, %rsi
callq 0x1060
jmp 0x2800
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 0x27ae
movq -0x48(%rbp), %rdi
movq -0x68(%rbp), %rbx
movq %rbx, %rsi
callq 0x1e7e
movq %rax, %r14
movq -0x50(%rbp), %rdi
movq %rbx, %rsi
callq 0x1e7e
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 0x1f1e
movq %rax, %r14
movq %rbx, %rdi
movq -0x58(%rbp), %rbx
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2911
xorpd 0x39d5(%rip), %xmm0     # 0x6240
callq 0x12a0
movsd 0x3998(%rip), %xmm2     # 0x6210
addsd %xmm2, %xmm0
movapd %xmm2, %xmm1
divsd %xmm0, %xmm1
movapd %xmm2, %xmm0
subsd %xmm1, %xmm0
ucomisd 0x3994(%rip), %xmm0     # 0x6228
jbe 0x289e
cmpl $0x0, -0x34(%rbp)
jne 0x28b2
jmp 0x28a4
cmpl $0x0, -0x34(%rbp)
je 0x28b2
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 0x2769
movq %r15, %rdi
callq 0x10a0
movsd -0x30(%rbp), %xmm0
divsd -0x40(%rbp), %xmm0
leaq 0x395b(%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