// File: /workspace/github_c_makefile_star2_O1/salextpuru[P]speccy-toochain/src/megalz/MegaLZ.c
// Function: parse_input
int parse_input(int argc,char * argv[])
// parse input arguments
{
	int fname_pos,ext_pos;

	if( (argc>=2)&&(argc<=4) )
	{
		if( !(strcmp(argv[1],"-h")&&strcmp(argv[1],"-H")) )
		{
			return PARSE_HELP;
		}
		else if( !(strcmp(argv[1],"-g")&&strcmp(argv[1],"-G")) )
		{
			fname_pos=2;
			mode=MODE_PACK_GREEDY;
		}
		else if( !(strcmp(argv[1],"-d")&&strcmp(argv[1],"-d")) )
		{
			fname_pos=2;
			mode=MODE_DEPACK;
		}
		else
		{
			fname_pos=1;
			mode=MODE_PACK_OPTIMAL;
		}

		if( fname_pos>=argc ) return PARSE_ERROR;

		// input filename
		fname_in=(char *)malloc(strlen(argv[fname_pos])+1);
		if( !fname_in )
		{
			printf("parse_input(): fname_in malloc failed!\n");
			return PARSE_FAIL;
		}
		strcpy(fname_in,argv[fname_pos]);

		// output filename
		if( (fname_pos+1)<argc )
		{ // we have second filename
			fname_out=(char *)malloc(strlen(argv[fname_pos+1])+1);
			if( !fname_out)
			{
				printf("parse_input(): fname_out malloc failed!\n");
				return PARSE_FAIL;
			}
			strcpy(fname_out,argv[fname_pos+1]);
		}
		else
		{ // no second filename - create from old adding extensions
			fname_out=(char *)malloc(strlen(argv[fname_pos])+1+4);
			if( !fname_out)
			{
				printf("parse_input(): fname_out malloc failed!\n");
				return PARSE_FAIL;
			}
			strcpy(fname_out,argv[fname_pos]);
			if( mode==MODE_DEPACK )
			{
				ext_pos=strlen(fname_out)-4;
				if( !strcmp(&fname_out[ext_pos],PACK_EXT) )
				{
					strcpy(&fname_out[ext_pos],DEPK_EXT);
				}
				else
				{
					strcat(fname_out,DEPK_EXT);
				}
			}
			else
			{ // MODE_PACK_*
				strcat(fname_out,PACK_EXT);
			}
		}
	}
	else
	{
		return PARSE_ERROR;
	}


	return PARSE_WORK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %r14d
leal -0x2(%r14), %eax
movl $0x1, %ebp
cmpl $0x2, %eax
ja 0x15b1
movq %rsi, %rbx
movq 0x8(%rsi), %r15
leaq 0x1c01(%rip), %rsi      # 0x3004
movq %r15, %rdi
callq 0x1100
movl $0x2, %ebp
testl %eax, %eax
je 0x15b1
leaq 0x1be8(%rip), %rsi      # 0x3007
movq %r15, %rdi
callq 0x1100
testl %eax, %eax
je 0x15b1
leaq 0x1bd4(%rip), %rsi      # 0x300a
movq %r15, %rdi
callq 0x1100
movl $0x2, %ebp
testl %eax, %eax
je 0x1485
leaq 0x1bbf(%rip), %rsi      # 0x300d
movq %r15, %rdi
callq 0x1100
movl $0x2, %r12d
testl %eax, %eax
je 0x148b
leaq 0x1ba9(%rip), %rsi      # 0x3010
movq %r15, %rdi
callq 0x1100
xorl %r12d, %r12d
testl %eax, %eax
sete %r12b
leal 0x1(,%r12,2), %ebp
incl %r12d
jmp 0x148b
movl $0x2, %r12d
movl %ebp, 0x3c57(%rip)      # 0x50e8
movl $0x1, %ebp
cmpl %r14d, %r12d
jge 0x15b1
movl %r12d, %r13d
movq (%rbx,%r13,8), %rdi
callq 0x1050
leaq 0x1(%rax), %rdi
callq 0x10f0
movq %rax, 0x3bfd(%rip)      # 0x50b8
testq %rax, %rax
je 0x150d
movq (%rbx,%r13,8), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x1080
incl %r12d
cmpl %r14d, %r12d
jge 0x1516
movl %r12d, %r14d
movq (%rbx,%r14,8), %rdi
callq 0x1050
leaq 0x1(%rax), %rdi
callq 0x10f0
movq %rax, 0x3bcd(%rip)      # 0x50c0
testq %rax, %rax
je 0x1583
movq (%rbx,%r14,8), %rsi
movq %rax, %rdi
callq 0x1080
jmp 0x15ac
leaq 0x1e59(%rip), %rdi      # 0x336d
jmp 0x158a
movq %r15, %rdi
callq 0x1050
leaq 0x5(%rax), %rdi
callq 0x10f0
movq %rax, 0x3b92(%rip)      # 0x50c0
testq %rax, %rax
je 0x1583
movq %rax, %r14
movq (%rbx,%r13,8), %rsi
movq %rax, %rdi
callq 0x1080
cmpl $0x3, 0x3b9f(%rip)      # 0x50e8
jne 0x1596
movq %r14, %rdi
callq 0x1050
addl $-0x4, %eax
cltq
movq %r14, %rbx
addq %rax, %rbx
leaq 0x1aae(%rip), %rsi      # 0x3013
movq %rbx, %rdi
callq 0x1100
testl %eax, %eax
je 0x15c2
movq %r14, %rdi
callq 0x1050
movl $0x6b70642e, (%r14,%rax) # imm = 0x6B70642E
jmp 0x15a6
leaq 0x1e0a(%rip), %rdi      # 0x3394
callq 0x1120
movl $0x4, %ebp
jmp 0x15b1
movq %r14, %rdi
callq 0x1050
movl $0x7a6c6d2e, (%r14,%rax) # imm = 0x7A6C6D2E
movb $0x0, 0x4(%r14,%rax)
movl $0x3, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x0, 0x4(%rbx)
movl $0x6b70642e, (%rbx)     # imm = 0x6B70642E
jmp 0x15ac