// File: /workspace/github_c_makefile_star2_O2/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 0x3a40(%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 0x3cf1(%rip), %r12      # 0x62e8
movsd %xmm0, -0x40(%rbp)
movq %r13, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r15, %rdx
callq 0x1110
testq %rax, %rax
je 0x2755
movq %r13, %rdi
movq %r12, %rsi
callq 0x1220
movq %rax, %r14
movq %rax, %rdi
leaq 0x3a23(%rip), %rsi      # 0x6050
callq 0x1140
testl %eax, %eax
je 0x25fc
movq %rbx, -0x58(%rbp)
xorl %ebx, %ebx
testq %r14, %r14
je 0x26a4
cmpl $0x2, %ebx
je 0x2688
cmpl $0x1, %ebx
je 0x2666
testl %ebx, %ebx
jne 0x2693
movq %r14, %rdi
callq 0x10c0
leaq 0x1(%rax), %rdi
callq 0x11a0
movq %rax, -0x48(%rbp)
jmp 0x267b
movq %r14, %rdi
callq 0x10c0
leaq 0x1(%rax), %rdi
callq 0x11a0
movq %rax, -0x50(%rbp)
movq %rax, %rdi
movq %r14, %rsi
callq 0x1060
jmp 0x2693
movq %r14, %rdi
callq 0x1240
movl %eax, -0x34(%rbp)
xorl %edi, %edi
movq %r12, %rsi
callq 0x1220
movq %rax, %r14
incl %ebx
jmp 0x263c
movq -0x48(%rbp), %rdi
movq -0x68(%rbp), %rbx
movq %rbx, %rsi
callq 0x1daa
movq %rax, %r14
movq -0x50(%rbp), %rdi
movq %rbx, %rsi
callq 0x1daa
movq %rax, %rsi
movq -0x60(%rbp), %rbx
movl 0x10(%rbx), %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movq %r14, %rdi
movl %eax, %edx
callq 0x1e43
movq %rax, %r14
movq %rbx, %rdi
movq -0x58(%rbp), %rbx
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2582
movsd 0x3b26(%rip), %xmm2     # 0x6220
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
ucomisd 0x3b1e(%rip), %xmm1     # 0x6228
jbe 0x2714
cmpl $0x0, -0x34(%rbp)
jne 0x2728
jmp 0x271a
cmpl $0x0, -0x34(%rbp)
je 0x2728
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 0x25fc
movq %r15, %rdi
callq 0x10a0
movsd -0x30(%rbp), %xmm0
divsd -0x40(%rbp), %xmm0
leaq 0x3ae5(%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