// File: /workspace/github_c_makefile_star2_O1/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 0x1ed0(%rip), %rdi      # 0x314a
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 0x208f(%rip), %rdi      # 0x333b
callq 0x1120
jmp 0x1367
leaq 0x1ec4(%rip), %rdi      # 0x3181
callq 0x1120
leaq 0x1ed7(%rip), %rdi      # 0x31a0
callq 0x1120
leaq 0x1f07(%rip), %rdi      # 0x31dc
callq 0x1120
leaq 0x1f31(%rip), %rdi      # 0x3212
callq 0x1120
leaq 0x1f64(%rip), %rdi      # 0x3251
callq 0x1120
leaq 0x1f94(%rip), %rdi      # 0x328d
callq 0x1120
leaq 0x1fca(%rip), %rdi      # 0x32cf
callq 0x1120
leaq 0x1fd0(%rip), %rdi      # 0x32e1
callq 0x1120
leaq 0x1ff9(%rip), %rdi      # 0x3316
callq 0x1120
xorl %ebx, %ebx
jmp 0x1367
movl 0x3dbc(%rip), %eax      # 0x50e8
leal -0x1(%rax), %ecx
cmpl $0x2, %ecx
jae 0x133d
leaq 0x1e3b(%rip), %rdi      # 0x3176
jmp 0x1349
cmpl $0x3, %eax
jne 0x134e
leaq 0x1e20(%rip), %rdi      # 0x3169
callq 0x1120
movq 0x3c83(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
callq 0x10c0
callq 0x15ce
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 0x1fa0(%rip), %rdi      # 0x3367
callq 0x1120
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq