// File: /workspace/github_c_makefile_star2_O1/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)
movl $0x18, %edi
callq 0x11a0
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %rax, -0x38(%rbp)
movl $0x0, 0x10(%rax)
leaq 0x3e93(%rip), %rsi      # 0x6016
movq %rbx, %rdi
callq 0x1200
movq %rax, -0x50(%rbp)
movl $0x1, -0x2c(%rbp)
xorl %r15d, %r15d
leaq -0x1b0(%rbp), %r14
xorl %ebx, %ebx
xorl %r13d, %r13d
xorl %ecx, %ecx
movslq %ecx, %rcx
movq %rcx, -0x48(%rbp)
movq %r14, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq -0x50(%rbp), %rdx
callq 0x1120
testq %rax, %rax
je 0x22cf
testl %r15d, %r15d
je 0x21de
leal (%rbx,%rbx), %eax
cmpl %eax, %r13d
je 0x22cf
incl %r13d
jmp 0x21e0
incl %ebx
movq %r14, %rdi
leaq 0x410e(%rip), %rsi      # 0x62f8
callq 0x1220
movq %rax, %r12
movq %rax, %rdi
leaq 0x3e5b(%rip), %rsi      # 0x6057
callq 0x1140
testl %eax, %eax
je 0x21ae
movq %r12, %rdi
callq 0x1270
movq %rax, %r12
movq %rax, -0x80(%rbp)
xorl %edi, %edi
leaq 0x4033(%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 0x1eb9
movq %rax, -0x40(%rbp)
movq -0x60(%rbp), %rdi
movq %r12, %rsi
callq 0x1eb9
movq -0x40(%rbp), %rdi
movq %rax, %rsi
movl -0x54(%rbp), %edx
callq 0x1f59
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 0x21ae
movq -0x50(%rbp), %rdi
callq 0x10a0
testl %r15d, %r15d
jne 0x22f8
movq -0x68(%rbp), %rdi
leaq 0x3d2e(%rip), %rsi      # 0x6016
callq 0x1200
movq %rax, -0x50(%rbp)
movl $0x0, -0x2c(%rbp)
leal 0x1(%r15), %eax
testl %r15d, %r15d
movl %eax, %r15d
movq -0x48(%rbp), %rcx
je 0x21a7
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