// File: /workspace/github_c_makefile_star2_O0/salextpuru[P]speccy-toochain/src/megalz/MegaLZ.c
// Function: main_job
int main_job(void)
{


	// open input file
	file_in=fopen(fname_in,"rb");

	if(!file_in)
	{
		printf("Cannot open input file \"%s\"!\n",fname_in);
		return 0;
	}


	// open output file
	file_out=fopen(fname_out,"wb");
	if(!file_out)
	{
		printf("Cannot create output file \"%s\"!\n",fname_out);
		return 0;
	}




	//get length of file
	if( fseek(file_in,0,SEEK_END) )
	{
		printf("Cannot fseek input file \"%s\"!\n",fname_in);
		return 0;
	}

	inlen=ftell(file_in);
	if( inlen==(-1L)  )
	{
		printf("Cannot ftell() length of input file \"%s\"!\n",fname_in);
		inlen=0;
		return 0;
	}
	else if( inlen<4 )
	{
		printf("Input file \"%s\" is smaller than 4 bytes - I won't process it!\n",fname_in);
		return 0;
	}

	//return ptr to beginning
	if( fseek(file_in,0,SEEK_SET) )
	{
		printf("Cannot fseek() input file \"%s\"!\n",fname_in);
		return 0;
	}




	//alloc mem for file and load it into mem

	indata=(UBYTE*)malloc(inlen);
	if( !indata )
	{
		printf("Cannot allocate memory for loading input file \"%s\"!\n",fname_in);
		return 0;
	}

	if( inlen!=fread(indata,1,inlen,file_in) )
	{
		printf("Cannot successfully load input file \"%s\" into mem!\n",fname_in);
		return 0;
	}




	// now file loaded, pack it

	if( (mode==MODE_PACK_OPTIMAL)||(mode==MODE_PACK_GREEDY) )
	{
		if( !pack() )
		{
			printf("main_job(): pack() failed!\n");
			return 0;
		}
	}
	else if( mode==MODE_DEPACK )
	{
		if( !depack() )
		{
			printf("main_job(): depack() failed!\n");
			return 0;
		}
	}


	return 1;
}

// Assembly:
subq $0x18, %rsp
movq 0x492d(%rip), %rdi      # 0x60b8
leaq 0x2b0d(%rip), %rsi      # 0x429f
callq 0x10c0
movq %rax, 0x492a(%rip)      # 0x60c8
cmpq $0x0, 0x4922(%rip)      # 0x60c8
jne 0x17ca
movq 0x4909(%rip), %rsi      # 0x60b8
leaq 0x2aec(%rip), %rdi      # 0x42a2
movb $0x0, %al
callq 0x1040
movl $0x0, 0x14(%rsp)
jmp 0x1a00
movq 0x48ef(%rip), %rdi      # 0x60c0
leaq 0x2ae8(%rip), %rsi      # 0x42c0
callq 0x10c0
movq %rax, 0x48ec(%rip)      # 0x60d0
cmpq $0x0, 0x48e4(%rip)      # 0x60d0
jne 0x1810
movq 0x48cb(%rip), %rsi      # 0x60c0
leaq 0x2ac7(%rip), %rdi      # 0x42c3
movb $0x0, %al
callq 0x1040
movl $0x0, 0x14(%rsp)
jmp 0x1a00
movq 0x48b1(%rip), %rdi      # 0x60c8
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
callq 0x10a0
cmpl $0x0, %eax
je 0x184c
movq 0x4887(%rip), %rsi      # 0x60b8
leaq 0x2aac(%rip), %rdi      # 0x42e4
movb $0x0, %al
callq 0x1040
movl $0x0, 0x14(%rsp)
jmp 0x1a00
movq 0x4875(%rip), %rdi      # 0x60c8
callq 0x1030
movl %eax, 0x487a(%rip)      # 0x60d8
movl 0x4874(%rip), %eax      # 0x60d8
cmpq $-0x1, %rax
jne 0x1896
movq 0x4847(%rip), %rsi      # 0x60b8
leaq 0x2a8b(%rip), %rdi      # 0x4303
movb $0x0, %al
callq 0x1040
movl $0x0, 0x484f(%rip)      # 0x60d8
movl $0x0, 0x14(%rsp)
jmp 0x1a00
cmpl $0x4, 0x483b(%rip)      # 0x60d8
jae 0x18c1
movq 0x4812(%rip), %rsi      # 0x60b8
leaq 0x2a81(%rip), %rdi      # 0x432e
movb $0x0, %al
callq 0x1040
movl $0x0, 0x14(%rsp)
jmp 0x1a00
jmp 0x18c3
movq 0x47fe(%rip), %rdi      # 0x60c8
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x10a0
cmpl $0x0, %eax
je 0x18fc
movq 0x47d7(%rip), %rsi      # 0x60b8
leaq 0x2a85(%rip), %rdi      # 0x436d
movb $0x0, %al
callq 0x1040
movl $0x0, 0x14(%rsp)
jmp 0x1a00
movl 0x47d6(%rip), %eax      # 0x60d8
movl %eax, %edi
callq 0x10e0
movq %rax, 0x47d0(%rip)      # 0x60e0
cmpq $0x0, 0x47c8(%rip)      # 0x60e0
jne 0x193c
movq 0x4797(%rip), %rsi      # 0x60b8
leaq 0x2a66(%rip), %rdi      # 0x438e
movb $0x0, %al
callq 0x1040
movl $0x0, 0x14(%rsp)
jmp 0x1a00
movl 0x4796(%rip), %eax      # 0x60d8
movq %rax, 0x8(%rsp)
movq 0x4792(%rip), %rdi      # 0x60e0
movl 0x4784(%rip), %eax      # 0x60d8
movl %eax, %edx
movq 0x476b(%rip), %rcx      # 0x60c8
movl $0x1, %esi
callq 0x1100
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
je 0x1993
movq 0x473d(%rip), %rsi      # 0x60b8
leaq 0x2a41(%rip), %rdi      # 0x43c3
movb $0x0, %al
callq 0x1040
movl $0x0, 0x14(%rsp)
jmp 0x1a00
cmpl $0x1, 0x474e(%rip)      # 0x60e8
je 0x19a5
cmpl $0x2, 0x4745(%rip)      # 0x60e8
jne 0x19c9
callq 0x2b10
cmpl $0x0, %eax
jne 0x19c7
leaq 0x2a41(%rip), %rdi      # 0x43f7
movb $0x0, %al
callq 0x1040
movl $0x0, 0x14(%rsp)
jmp 0x1a00
jmp 0x19f8
cmpl $0x3, 0x4718(%rip)      # 0x60e8
jne 0x19f6
callq 0x1a10
cmpl $0x0, %eax
jne 0x19f4
leaq 0x2a30(%rip), %rdi      # 0x4413
movb $0x0, %al
callq 0x1040
movl $0x0, 0x14(%rsp)
jmp 0x1a00
jmp 0x19f6
jmp 0x19f8
movl $0x1, 0x14(%rsp)
movl 0x14(%rsp), %eax
addq $0x18, %rsp
retq
nopl (%rax)