// File: /workspace/github_c_makefile_star2_O0/salextpuru[P]speccy-toochain/src/megalz/MegaLZ.c
// Function: main
int main(int argc, char* argv[])
{
	int retcode=0;


	// init globals

	fname_in=NULL;
	fname_out=NULL;

	file_in=NULL;
	file_out=NULL;

	inlen=0;
	indata=NULL;




	printf("MegaLZ C packer/depacker v4.89\n");



	switch( parse_input(argc,argv) )
	{
	case PARSE_ERROR:
		printf("\nError in arguments! Try megalz -h for help\n");
		retcode=1;
		break;
	case PARSE_HELP:
		printf("\nUsage:\n megalz -h - this help\n");
		printf(          " megalz [-g] <input filename> [<output filename>] - packing\n");
		printf(          "         -g - greedy coding, default - optimal coding\n");
		printf(          "Greedy coding is significantly faster but yields worse packing\n");
		printf(          " megalz -d <input filename> [<output filename>] - depacking\n");
		printf(          "Default extension for packed file - '.mlz', for depacked - '.dpk'\n");
		printf("\n (c) 2005 MAYhEM\n");
		printf(" Z80 depacker code, packed file format (c) fyrex^mhm\n");
		printf(" This C packer/depacker (c) lvd^mhm\n\n");
		break;
	case PARSE_WORK:
		if( (mode==MODE_PACK_OPTIMAL) || (mode==MODE_PACK_GREEDY) )
		{
			printf("Packing...\n");
		}
		else if( mode==MODE_DEPACK )
		{
			printf("Depacking...\n");
		}
		fflush(stdin);
		retcode=main_job()?0:1;
		break;
	default:
		retcode=1;
	}




	// free globals (if any)

	if(fname_in) free(fname_in);
	if(fname_out) free(fname_out);
	if(file_in) fclose(file_in);
	if(file_out) fclose(file_out);
	if(indata) free(indata);





	if( !retcode ) printf("Done!\n");
	return retcode;
}

// Assembly:
subq $0x18, %rsp
movl $0x0, 0x14(%rsp)
movl %edi, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movl $0x0, 0x4(%rsp)
movq $0x0, 0x4e60(%rip) # 0x60b8
movq $0x0, 0x4e5d(%rip) # 0x60c0
movq $0x0, 0x4e5a(%rip) # 0x60c8
movq $0x0, 0x4e57(%rip) # 0x60d0
movl $0x0, 0x4e55(%rip)      # 0x60d8
movq $0x0, 0x4e52(%rip) # 0x60e0
leaq 0x2d6f(%rip), %rdi      # 0x4004
xorl %eax, %eax
callq 0x1040
movl 0x10(%rsp), %edi
movq 0x8(%rsp), %rsi
callq 0x1470
movl %eax, %ecx
movl %ecx, (%rsp)
subl $0x1, %eax
je 0x12d1
jmp 0x12b6
movl (%rsp), %eax
subl $0x2, %eax
je 0x12ec
jmp 0x12c0
movl (%rsp), %eax
subl $0x3, %eax
je 0x136c
jmp 0x13d0
leaq 0x2d4c(%rip), %rdi      # 0x4024
movb $0x0, %al
callq 0x1040
movl $0x1, 0x4(%rsp)
jmp 0x13d8
leaq 0x2d5e(%rip), %rdi      # 0x4051
movb $0x0, %al
callq 0x1040
leaq 0x2d70(%rip), %rdi      # 0x4071
movb $0x0, %al
callq 0x1040
leaq 0x2d9f(%rip), %rdi      # 0x40ae
movb $0x0, %al
callq 0x1040
leaq 0x2dc8(%rip), %rdi      # 0x40e5
movb $0x0, %al
callq 0x1040
leaq 0x2dfa(%rip), %rdi      # 0x4125
movb $0x0, %al
callq 0x1040
leaq 0x2e29(%rip), %rdi      # 0x4162
movb $0x0, %al
callq 0x1040
leaq 0x2e5e(%rip), %rdi      # 0x41a5
movb $0x0, %al
callq 0x1040
leaq 0x2e63(%rip), %rdi      # 0x41b8
movb $0x0, %al
callq 0x1040
leaq 0x2e8b(%rip), %rdi      # 0x41ee
movb $0x0, %al
callq 0x1040
jmp 0x13d8
cmpl $0x1, 0x4d75(%rip)      # 0x60e8
je 0x137e
cmpl $0x2, 0x4d6c(%rip)      # 0x60e8
jne 0x138e
leaq 0x2e8f(%rip), %rdi      # 0x4214
movb $0x0, %al
callq 0x1040
jmp 0x13a7
cmpl $0x3, 0x4d53(%rip)      # 0x60e8
jne 0x13a5
leaq 0x2e82(%rip), %rdi      # 0x4220
movb $0x0, %al
callq 0x1040
jmp 0x13a7
movq 0x4c32(%rip), %rax      # 0x5fe0
movq (%rax), %rdi
callq 0x10b0
callq 0x1780
movl %eax, %edx
movl $0x1, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, 0x4(%rsp)
jmp 0x13d8
movl $0x1, 0x4(%rsp)
cmpq $0x0, 0x4cd8(%rip)      # 0x60b8
je 0x13ee
movq 0x4ccf(%rip), %rdi      # 0x60b8
callq 0x10d0
cmpq $0x0, 0x4cca(%rip)      # 0x60c0
je 0x1404
movq 0x4cc1(%rip), %rdi      # 0x60c0
callq 0x10d0
cmpq $0x0, 0x4cbc(%rip)      # 0x60c8
je 0x141a
movq 0x4cb3(%rip), %rdi      # 0x60c8
callq 0x1090
cmpq $0x0, 0x4cae(%rip)      # 0x60d0
je 0x1430
movq 0x4ca5(%rip), %rdi      # 0x60d0
callq 0x1090
cmpq $0x0, 0x4ca8(%rip)      # 0x60e0
je 0x1446
movq 0x4c9f(%rip), %rdi      # 0x60e0
callq 0x10d0
cmpl $0x0, 0x4(%rsp)
jne 0x145b
leaq 0x2dda(%rip), %rdi      # 0x422e
movb $0x0, %al
callq 0x1040
movl 0x4(%rsp), %eax
addq $0x18, %rsp
retq
nopw %cs:(%rax,%rax)