// File: /workspace/github_c_makefile_star2_O3/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
movq %rsi, %rbx
movl %edi, %ebp
xorl %eax, %eax
movq %rax, 0x3e6b(%rip)      # 0x50b8
movq %rax, 0x3e6c(%rip)      # 0x50c0
movq %rax, 0x3e6d(%rip)      # 0x50c8
movq %rax, 0x3e6e(%rip)      # 0x50d0
movl $0x0, 0x3e6c(%rip)      # 0x50d8
movq %rax, 0x3e6d(%rip)      # 0x50e0
leaq 0x1ec1(%rip), %rdi      # 0x313b
callq 0x1120
movl %ebp, %edi
movq %rbx, %rsi
callq 0x13d5
cmpl $0x3, %eax
je 0x1326
cmpl $0x2, %eax
je 0x12b6
movl $0x1, %ebx
cmpl $0x1, %eax
jne 0x1367
leaq 0x2080(%rip), %rdi      # 0x332c
callq 0x1120
jmp 0x1367
leaq 0x1eb5(%rip), %rdi      # 0x3172
callq 0x1120
leaq 0x1ec8(%rip), %rdi      # 0x3191
callq 0x1120
leaq 0x1ef8(%rip), %rdi      # 0x31cd
callq 0x1120
leaq 0x1f22(%rip), %rdi      # 0x3203
callq 0x1120
leaq 0x1f55(%rip), %rdi      # 0x3242
callq 0x1120
leaq 0x1f85(%rip), %rdi      # 0x327e
callq 0x1120
leaq 0x1fbb(%rip), %rdi      # 0x32c0
callq 0x1120
leaq 0x1fc1(%rip), %rdi      # 0x32d2
callq 0x1120
leaq 0x1fea(%rip), %rdi      # 0x3307
callq 0x1120
xorl %ebx, %ebx
jmp 0x1367
movl 0x3dbc(%rip), %eax      # 0x50e8
leal -0x1(%rax), %ecx
cmpl $0x2, %ecx
jae 0x133d
leaq 0x1e2c(%rip), %rdi      # 0x3167
jmp 0x1349
cmpl $0x3, %eax
jne 0x134e
leaq 0x1e11(%rip), %rdi      # 0x315a
callq 0x1120
movq 0x3c83(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
callq 0x10c0
callq 0x15c5
movl %eax, %ebx
xorl $0x1, %ebx
movq 0x3d4a(%rip), %rdi      # 0x50b8
testq %rdi, %rdi
je 0x1378
callq 0x10e0
movq 0x3d41(%rip), %rdi      # 0x50c0
testq %rdi, %rdi
je 0x1389
callq 0x10e0
movq 0x3d38(%rip), %rdi      # 0x50c8
testq %rdi, %rdi
je 0x139a
callq 0x1090
movq 0x3d2f(%rip), %rdi      # 0x50d0
testq %rdi, %rdi
je 0x13ab
callq 0x1090
movq 0x3d2e(%rip), %rdi      # 0x50e0
testq %rdi, %rdi
je 0x13bc
callq 0x10e0
testl %ebx, %ebx
jne 0x13cc
leaq 0x1f91(%rip), %rdi      # 0x3358
callq 0x1120
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq