// File: /workspace/github_c_makefile_star2_O0/stefpant[P]TCPserver/PantoulasStefanosProject2/trie/input_parse.c
// Function: input_parse
int input_parse(int argc,char* argv[],char ***docmap,int* w,int* sorted,int *lines,char** fifoname,char** fifoname2){
	char *docfile = NULL;//just to be sure
	int i;
	int flag=0;
	for(i=1;i<argc;i++){
		if(strcmp(argv[i],"-d")==0){//then next argument must be the input file
			if(++i==argc){//error if nothing next
				printf("Missing input file...\n");
				return -2;
			}
			//needs the '-i' argument to success else we haven't got the input file
			//and return failure
			flag = 1;
			docfile = malloc(strlen(argv[i])+1);
			strcpy(docfile,argv[i]);
			//printf("docfile = %s\n",docfile);
		}
		else if(strcmp(argv[i],"-w")==0){//if found this flag change the w
			if(i+1==argc){//if value for w missing just go on with w=3
				printf("Value for k not found.Continue with default value(w=3)\n");
				break;
			}
			*w = atoi(argv[++i]);
			if(!(*w)){//fails if k=0 or argument not a number
				printf("Try again with w!=0\n");
				free(docfile);
				return -2;
			}
		}
		else if(strcmp(argv[i],"-sorted")==0){
			*sorted = 1;//if found this flag sort the trie
		}
		else if(strcmp(argv[i],"-n")==0){
			if(++i==argc){//error if nothing next
				printf("Missing 1st fifo name...\n");
				return -2;
			}
			int len = strlen(argv[i]);
			*fifoname = malloc((len+1)*sizeof(char));
			strcpy((*fifoname),argv[i]);
			if(++i==argc){//error if nothing next
				printf("Missing 2nd fifo name...\n");
				return -2;
			}
			len = strlen(argv[i]);
			*fifoname2 = malloc((len+1)*sizeof(char));
			strcpy((*fifoname2),argv[i]);
		}
		else{//for every other argument/flag or whatever
			printf("Unrecognized arguments!\n");
			free(docfile);
			return -2;//exits 
		}
	}
	if(!flag){
		printf("Input file not found!\n");
		return -2;
	}

	int error = read_doc(docfile,docmap,lines);
	free(docfile);
	if(error<0) return -2;
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x1, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x1872
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6a2f(%rip), %rsi      # 0x803b
callq 0x1160
cmpl $0x0, %eax
jne 0x1680
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
cmpl -0x8(%rbp), %eax
jne 0x163e
leaq 0x6a13(%rip), %rdi      # 0x803e
movb $0x0, %al
callq 0x1120
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x18c2
movl $0x1, -0x40(%rbp)
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1110
movq %rax, %rdi
addq $0x1, %rdi
callq 0x11e0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x1080
jmp 0x1862
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69c2(%rip), %rsi      # 0x8055
callq 0x1160
cmpl $0x0, %eax
jne 0x170d
movl -0x3c(%rbp), %eax
addl $0x1, %eax
cmpl -0x8(%rbp), %eax
jne 0x16bb
leaq 0x69a9(%rip), %rdi      # 0x8058
movb $0x0, %al
callq 0x1120
jmp 0x1872
movq -0x10(%rbp), %rax
movl -0x3c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x3c(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1270
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x1708
leaq 0x69a4(%rip), %rdi      # 0x8090
movb $0x0, %al
callq 0x1120
movq -0x38(%rbp), %rdi
callq 0x1030
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x18c2
jmp 0x1860
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6985(%rip), %rsi      # 0x80a5
callq 0x1160
cmpl $0x0, %eax
jne 0x1739
movq -0x28(%rbp), %rax
movl $0x1, (%rax)
jmp 0x185e
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6961(%rip), %rsi      # 0x80ad
callq 0x1160
cmpl $0x0, %eax
jne 0x183c
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
cmpl -0x8(%rbp), %eax
jne 0x1782
leaq 0x6941(%rip), %rdi      # 0x80b0
movb $0x0, %al
callq 0x1120
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x18c2
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1110
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x0, %rdi
callq 0x11e0
movq %rax, %rcx
movq 0x10(%rbp), %rax
movq %rcx, (%rax)
movq 0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x1080
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
cmpl -0x8(%rbp), %eax
jne 0x17f2
leaq 0x68eb(%rip), %rdi      # 0x80ca
movb $0x0, %al
callq 0x1120
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x18c2
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1110
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x0, %rdi
callq 0x11e0
movq %rax, %rcx
movq 0x18(%rbp), %rax
movq %rcx, (%rax)
movq 0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x1080
jmp 0x185c
leaq 0x68a1(%rip), %rdi      # 0x80e4
movb $0x0, %al
callq 0x1120
movq -0x38(%rbp), %rdi
callq 0x1030
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x18c2
jmp 0x185e
jmp 0x1860
jmp 0x1862
jmp 0x1864
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x15ed
cmpl $0x0, -0x40(%rbp)
jne 0x188f
leaq 0x687e(%rip), %rdi      # 0x80fd
movb $0x0, %al
callq 0x1120
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x18c2
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x1400
movl %eax, -0x48(%rbp)
movq -0x38(%rbp), %rdi
callq 0x1030
cmpl $0x0, -0x48(%rbp)
jge 0x18bb
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x18c2
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)