// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %rbx
pushq %rax
andq $0x0, 0x3e81(%rip)      # 0x50b8
andq $0x0, 0x3e81(%rip)      # 0x50c0
andq $0x0, 0x3e81(%rip)      # 0x50c8
andq $0x0, 0x3e81(%rip)      # 0x50d0
movq %rsi, %rbx
andl $0x0, 0x3e7f(%rip)      # 0x50d8
movl %edi, %ebp
andq $0x0, 0x3e7d(%rip)      # 0x50e0
leaq 0x1ed1(%rip), %rdi      # 0x313b
callq 0x1110
movl %ebp, %edi
movq %rbx, %rsi
callq 0x13b4
cmpl $0x3, %eax
je 0x1314
cmpl $0x2, %eax
je 0x12a4
pushq $0x1
popq %rbx
cmpl $0x1, %eax
jne 0x1355
leaq 0x2092(%rip), %rdi      # 0x332c
callq 0x1110
jmp 0x1355
leaq 0x1ec7(%rip), %rdi      # 0x3172
callq 0x1110
leaq 0x1eda(%rip), %rdi      # 0x3191
callq 0x1110
leaq 0x1f0a(%rip), %rdi      # 0x31cd
callq 0x1110
leaq 0x1f34(%rip), %rdi      # 0x3203
callq 0x1110
leaq 0x1f67(%rip), %rdi      # 0x3242
callq 0x1110
leaq 0x1f97(%rip), %rdi      # 0x327e
callq 0x1110
leaq 0x1fcd(%rip), %rdi      # 0x32c0
callq 0x1110
leaq 0x1fd3(%rip), %rdi      # 0x32d2
callq 0x1110
leaq 0x1ffc(%rip), %rdi      # 0x3307
callq 0x1110
xorl %ebx, %ebx
jmp 0x1355
movl 0x3dce(%rip), %eax      # 0x50e8
leal -0x1(%rax), %ecx
cmpl $0x2, %ecx
jae 0x132b
leaq 0x1e3e(%rip), %rdi      # 0x3167
jmp 0x1337
cmpl $0x3, %eax
jne 0x133c
leaq 0x1e23(%rip), %rdi      # 0x315a
callq 0x1110
movq 0x3c95(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
callq 0x10b0
callq 0x1593
movl %eax, %ebx
xorl $0x1, %ebx
movq 0x3d5c(%rip), %rdi      # 0x50b8
callq 0x10d0
movq 0x3d58(%rip), %rdi      # 0x50c0
callq 0x10d0
movq 0x3d54(%rip), %rdi      # 0x50c8
testq %rdi, %rdi
je 0x137e
callq 0x1080
movq 0x3d4b(%rip), %rdi      # 0x50d0
testq %rdi, %rdi
je 0x138f
callq 0x1080
movq 0x3d4a(%rip), %rdi      # 0x50e0
callq 0x10d0
testl %ebx, %ebx
jne 0x13ab
leaq 0x1fb2(%rip), %rdi      # 0x3358
callq 0x1110
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq