// File: /workspace/github_c_makefile_star2_O2/DVaronos[P]AnLogProject1/logistic.c
// Function: InputMake
Input* InputMake(char* filename1,char* filename2,Hash* H){

	FILE* fptr;
  int   a,z,ismatch,size = H->Head->Next->vec_size,count=0;
  char line[300];
  char* first;
  char* second;
  char* token=NULL;
	HVector* F;
  HVector* S;
  HVector* Con;
	Input* input=InputInit();

	fptr = fopen(filename1, "r");	//Anigma tou protou arxiou(me tis thetikes sisxetiseis)
	ismatch=1;	//oi sisxetiseis einai oles thetikes
	a=0;
	z=0;
	for(int i=0 ; i<2; i++){ //Gia kathe ena ap ta dio arxia

		while (fgets(line,sizeof(line),fptr)){//Diavazei to csv file grami grami
			if(!i){	//Ean eimaste sto proto arxio
					a++;	//Metrame tis thetikes sisxetisis
			}else{	//Ean eimaste sto deftero arxio
					if(z==2*a){	//Ean oi arnitikes sisxetisis einai oi diplasies stamatame to trainig gia afthn thn epanalipsh
							break;
					}else{	//Alios afksanoume tis arnitikes sisxetisis
							z++;
					}
			}
			token=strtok(line,",");
			if(!strcmp(token,"left_spec_id"))  continue;	//Ean einai h proth gramh twn csv kanoume skip thn epanalipsh
			first=strdup(token);
			token = strtok(NULL, " \n");
			second=strdup(token);
			F=GetCameraVector(first,H);	//Pernoume to vector ths proths kameras
			S=GetCameraVector(second,H);	//Pernoume to vector ths defterhs kameras
			Con=VectorConcat(F,S,size);	//Ipologizoume to concatenation

			input->Cons=realloc(input->Cons, (count+1)*sizeof(HVector*));
			input->Cons[count] = Con;

			input->matches= realloc(input->matches, (count+1)*sizeof(int));
			input->matches[count] = ismatch;
			count++;


			free(first);
			free(second);
		}
		fclose(fptr);//klinoume to arxio
		if(!i){	//Ean imastan sto proto arxio anoigoume to deftero(me tis arnitikes sisxerisis)
			fptr = fopen(filename2, "r");
			ismatch = 0;
		}
	}
	input->size=count;
	return input;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rsi, -0x68(%rbp)
movq %rdi, %rbx
movq %rdx, -0x70(%rbp)
movq 0x8(%rdx), %rax
movq 0x20(%rax), %rax
movl 0x28(%rax), %eax
movl %eax, -0x54(%rbp)
callq 0x1f9a
movq %rax, -0x38(%rbp)
leaq 0x3fe0(%rip), %rsi      # 0x6010
movq %rbx, %rdi
callq 0x1200
movq %rax, -0x50(%rbp)
pushq $0x1
popq %rax
movl %eax, -0x2c(%rbp)
xorl %ecx, %ecx
leaq -0x1b0(%rbp), %r15
xorl %r14d, %r14d
xorl %ebx, %ebx
xorl %r13d, %r13d
cmpl $0x2, %r13d
je 0x21ba
movslq %ecx, %rcx
movq %rcx, -0x48(%rbp)
movq %r15, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq -0x50(%rbp), %rdx
callq 0x1110
testq %rax, %rax
je 0x2185
testl %r13d, %r13d
je 0x2094
leal (%rbx,%rbx), %eax
cmpl %eax, %r14d
je 0x2185
incl %r14d
jmp 0x2096
incl %ebx
movq %r15, %rdi
leaq 0x4248(%rip), %rsi      # 0x62e8
callq 0x1220
movq %rax, %r12
movq %rax, %rdi
leaq 0x3f9e(%rip), %rsi      # 0x6050
callq 0x1140
testl %eax, %eax
je 0x2064
movq %r12, %rdi
callq 0x1270
movq %rax, %r12
movq %rax, -0x80(%rbp)
xorl %edi, %edi
leaq 0x417d(%rip), %rsi      # 0x6250
callq 0x1220
movq %rax, %rdi
callq 0x1270
movq %rax, -0x60(%rbp)
movq %r12, %rdi
movq -0x70(%rbp), %r12
movq %r12, %rsi
callq 0x1daa
movq %rax, -0x40(%rbp)
movq -0x60(%rbp), %rdi
movq %r12, %rsi
callq 0x1daa
movq -0x40(%rbp), %rdi
movq %rax, %rsi
movl -0x54(%rbp), %edx
callq 0x1e43
movq %rax, -0x78(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rdi
movq -0x48(%rbp), %r12
leaq 0x1(%r12), %rax
movq %rax, -0x40(%rbp)
leaq 0x8(,%r12,8), %rsi
callq 0x11c0
movq -0x38(%rbp), %rcx
movq %rax, (%rcx)
movq -0x78(%rbp), %rdx
movq %rdx, (%rax,%r12,8)
movq 0x8(%rcx), %rdi
leaq 0x4(,%r12,4), %rsi
callq 0x11c0
movq -0x38(%rbp), %rcx
movq %rax, 0x8(%rcx)
movl -0x2c(%rbp), %ecx
movl %ecx, (%rax,%r12,4)
movq -0x80(%rbp), %rdi
callq 0x1030
movq -0x60(%rbp), %rdi
callq 0x1030
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x2064
movq -0x50(%rbp), %rdi
callq 0x10a0
testl %r13d, %r13d
jne 0x21ae
movq -0x68(%rbp), %rdi
leaq 0x3e72(%rip), %rsi      # 0x6010
callq 0x1200
movq %rax, -0x50(%rbp)
movl $0x0, -0x2c(%rbp)
incl %r13d
movq -0x48(%rbp), %rcx
jmp 0x2053
movq -0x38(%rbp), %rax
movl %ecx, 0x10(%rax)
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq