// File: /workspace/github_c_makefile_star2_O0/stefpant[P]TCPserver/webcrawler/input_parse.c
// Function: input_parse
int input_parse(int argc,char* argv[],int* s_port,int* c_port,int* n_threads,char** rootdir,
		char** hostid,char** s_url){
	int i;
	int flag1=0,flag2=0,flag3=0,flag4=0,flag5=0;
	for(i=1;i<argc;i++){
		if(strcmp(argv[i],"-d")==0){//then next argument must be the input directory
			if(++i==argc){//error if nothing next
				printf("Missing input file...\n");
				return -2;
			}
			flag1++;
			int len = strlen(argv[i]);
			char c = argv[i][len - 1];
			*rootdir = malloc((len+1)*sizeof(char));
			strcpy((*rootdir),argv[i]);
			if(c == '/'){
				(*rootdir)[len - 1] = '\0';
			}

			int err = isDirEmpty(*rootdir);
			if(err == -1){
				printf("Given directory does not exist!\n");
				return -2;
			}
			else if(err == -2){
				printf("Given directory not empty!\n");
				return -2;
			}
		}
		else if(strcmp(argv[i],"-t")==0){//if found this flag change the t
			if(i+1==argc){//if value for t missing just go on with t=5
				printf("Value for t not found.Continue by default with 5 threads\n");
				break;
			}
			*n_threads = atoi(argv[++i]);
			if(!(*n_threads)){//fails if k=0 or argument not a number
				printf("Try again with t>0\n");
				return -2;
			}
		}
		else if(strcmp(argv[i],"-p")==0){
			if(i+1==argc){
				printf("Missing serving port!\n");
				return -2;
			}
			flag2++;
			*s_port = atoi(argv[++i]);
			if(!(*s_port)){//fails if k=0 or argument not a number
				printf("Try again with serving_port>0\n");
				return -2;
			}
		}
		else if(strcmp(argv[i],"-c")==0){
			if(i+1==argc){
				printf("Missing command port!\n");
				return -2;
			}
			*c_port = atoi(argv[++i]);
			flag3++;
			if(!(*c_port)){//fails if k=0 or argument not a number
				printf("Try again with command_port>0\n");
				return -2;
			}
		}
		else if(strcmp(argv[i],"-h")==0){
			if(i+1==argc){
				printf("Missing host or id!\n");
				return -2;
			}
			flag4++;
			int len = strlen(argv[++i]);
			*hostid = malloc((len+1)*sizeof(char));
			strcpy((*hostid),argv[i]);
		}
		//else if(strcmp(argv[i],"-sorted")==0){
		//	*sorted = 1;//if found this flag sort the trie
		//}
		else{//here must be the starting url and be the last argument to succeed
			if(i+1 != argc){
				printf("%s\n",argv[i]);
				printf("Arguments may be wrong placed!\n");
				return -2;
			}
			flag5++;
			int len = strlen(argv[i]);
			*s_url = malloc((len+1)*sizeof(char));
			strcpy((*s_url),argv[i]);
		}
	}
	if(!flag1 || !flag2 || !flag3 || !flag4 || !flag5){
		printf("Missing some arguments!\n");
		return -2;
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %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)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x1, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x37dd
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1c8e(%rip), %rsi      # 0x505e
callq 0x2180
cmpl $0x0, %eax
jne 0x34e5
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
cmpl -0x8(%rbp), %eax
jne 0x3406
leaq 0x1c6e(%rip), %rdi      # 0x5061
movb $0x0, %al
callq 0x2100
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x3819
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x20e0
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x4c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %al
movb %al, -0x4d(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x0, %rdi
callq 0x2220
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x2070
movsbl -0x4d(%rbp), %eax
cmpl $0x2f, %eax
jne 0x348f
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x4c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
movq -0x30(%rbp), %rax
movq (%rax), %rdi
callq 0x32e0
movl %eax, -0x54(%rbp)
cmpl $-0x1, -0x54(%rbp)
jne 0x34be
leaq 0x1bcd(%rip), %rdi      # 0x5078
movb $0x0, %al
callq 0x2100
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x3819
cmpl $-0x2, -0x54(%rbp)
jne 0x34de
leaq 0x1bce(%rip), %rdi      # 0x5099
movb $0x0, %al
callq 0x2100
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x3819
jmp 0x34e0
jmp 0x37cd
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1bbd(%rip), %rsi      # 0x50b5
callq 0x2180
cmpl $0x0, %eax
jne 0x3569
movl -0x34(%rbp), %eax
addl $0x1, %eax
cmpl -0x8(%rbp), %eax
jne 0x3520
leaq 0x1ba4(%rip), %rdi      # 0x50b8
movb $0x0, %al
callq 0x2100
jmp 0x37dd
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x34(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2300
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x3564
leaq 0x1ba1(%rip), %rdi      # 0x50f2
movb $0x0, %al
callq 0x2100
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x3819
jmp 0x37cb
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1b8a(%rip), %rsi      # 0x5106
callq 0x2180
cmpl $0x0, %eax
jne 0x35fd
movl -0x34(%rbp), %eax
addl $0x1, %eax
cmpl -0x8(%rbp), %eax
jne 0x35ab
leaq 0x1b71(%rip), %rdi      # 0x5109
movb $0x0, %al
callq 0x2100
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x3819
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x34(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2300
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x35f8
leaq 0x1b3b(%rip), %rdi      # 0x5120
movb $0x0, %al
callq 0x2100
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x3819
jmp 0x37c9
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1b2f(%rip), %rsi      # 0x513f
callq 0x2180
cmpl $0x0, %eax
jne 0x3691
movl -0x34(%rbp), %eax
addl $0x1, %eax
cmpl -0x8(%rbp), %eax
jne 0x363f
leaq 0x1b16(%rip), %rdi      # 0x5142
movb $0x0, %al
callq 0x2100
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x3819
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x34(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2300
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x368c
leaq 0x1ae0(%rip), %rdi      # 0x5159
movb $0x0, %al
callq 0x2100
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x3819
jmp 0x37c7
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1ad4(%rip), %rsi      # 0x5178
callq 0x2180
cmpl $0x0, %eax
jne 0x3735
movl -0x34(%rbp), %eax
addl $0x1, %eax
cmpl -0x8(%rbp), %eax
jne 0x36d7
leaq 0x1ab7(%rip), %rdi      # 0x517b
movb $0x0, %al
callq 0x2100
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x3819
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x34(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x20e0
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x0, %rdi
callq 0x2220
movq %rax, %rcx
movq 0x10(%rbp), %rax
movq %rcx, (%rax)
movq 0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x2070
jmp 0x37c5
movl -0x34(%rbp), %eax
addl $0x1, %eax
cmpl -0x8(%rbp), %eax
je 0x3774
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x1add(%rip), %rdi      # 0x5230
movb $0x0, %al
callq 0x2100
leaq 0x1a2f(%rip), %rdi      # 0x5190
movb $0x0, %al
callq 0x2100
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x3819
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x20e0
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x0, %rdi
callq 0x2220
movq %rax, %rcx
movq 0x18(%rbp), %rax
movq %rcx, (%rax)
movq 0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x2070
jmp 0x37c7
jmp 0x37c9
jmp 0x37cb
jmp 0x37cd
jmp 0x37cf
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x33b1
cmpl $0x0, -0x38(%rbp)
je 0x37fb
cmpl $0x0, -0x3c(%rbp)
je 0x37fb
cmpl $0x0, -0x40(%rbp)
je 0x37fb
cmpl $0x0, -0x44(%rbp)
je 0x37fb
cmpl $0x0, -0x48(%rbp)
jne 0x3812
leaq 0x19ae(%rip), %rdi      # 0x51b0
movb $0x0, %al
callq 0x2100
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x3819
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)