// File: /workspace/github_c_makefile_star2_O2/lmcilroy[P]lzm/lzm.c
// Function: process_file
static unsigned int
process_file(struct compress_args * const args)
{
	struct stat st;
	int fd_in = -1;
	int fd_out = -1;
	unsigned int remove = false;
	int err;
	int ret;

	if (args->st->st_size == 0) {
		ret = EINVAL;
		fprintf(stderr, "File %s: zero size, skipping\n",
		    args->filename);
		goto out;
	}

	fd_in = open(args->filename, O_RDONLY);
	if (fd_in < 0) {
		ret = errno;
		fprintf(stderr, "File %s: failed to open file: %s\n",
		    args->filename, strerror(ret));
		goto out;
	}

	posix_fadvise(fd_in, 0, 0, POSIX_FADV_SEQUENTIAL);

	if (args->benchmark == true) {
		ret = benchmark(fd_in, args);
		goto out;
	}

	if (args->test == false) {
		if (args->console == true) {
			fd_out = STDOUT_FILENO;
			if (isatty(fd_out)) {
				ret = EIO;
				fprintf(stderr, "Will not write to terminal\n");
				goto out;
			}

			strcpy(args->filename_out, "(stdout)");
		} else {
			ret = output_filename(args);
			if (ret != 0)
				goto out;

			ret = stat(args->filename_out, &st);
			if (ret == 0) {
				if (args->clobber == true) {
					ret = unlink(args->filename_out);
					if (ret < 0) {
						ret = errno;
						fprintf(stderr, "File %s: cannot remove: %s\n",
						    args->filename_out, strerror(ret));
						goto out;
					}
				} else {
					ret = EEXIST;
					fprintf(stderr, "File %s: not overwriting existing file\n",
					    args->filename_out);
					goto out;
				}
			}

			fd_out = open(args->filename_out,
			    O_WRONLY|O_CREAT|O_EXCL, 0600);
			if (fd_out < 0) {
				ret = errno;
				fprintf(stderr, "File %s: failed to open file: %s\n",
				    args->filename_out, strerror(ret));
				goto out;
			}

			remove = true;
		}
	}

	ret = process_data(fd_in, fd_out, args);
	if (ret != 0) {
		if (remove == true) {
			err = unlink(args->filename_out);
			if (err < 0) {
				err = errno;
				fprintf(stderr, "File %s: cannot remove: %s\n",
				    args->filename, strerror(err));
				goto out;
			}
		}
		goto out;
	}

	if (args->remove == true && args->test == false) {
		ret = stat(args->filename, &st);
		if (ret < 0) {
			ret = errno;
			fprintf(stderr, "File %s: cannot stat: %s\n",
			    args->filename, strerror(ret));
			goto out;
		}

		/* Check source file hasn't changed */
		if (st.st_dev == args->st->st_dev &&
		    st.st_ino == args->st->st_ino) {
			ret = unlink(args->filename);
			if (ret < 0) {
				ret = errno;
				fprintf(stderr, "File %s: cannot remove: %s\n",
				    args->filename, strerror(ret));
				goto out;
			}
		}
	}

 out:

	if (fd_in != -1 && fd_in != STDIN_FILENO)
		close(fd_in);
	if (fd_out != -1 && fd_out != STDOUT_FILENO)
		close(fd_out);

	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdi, %r13
movq (%rdi), %rax
cmpq $0x0, 0x30(%rax)
je 0x1d38
movq 0x8(%r13), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x11d0
movl %eax, %r12d
testl %eax, %eax
js 0x1d5c
pushq $0x2
popq %rcx
movl %r12d, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1140
cmpl $0x1, 0x1030(%r13)
jne 0x1b51
movq (%r13), %rcx
movl 0x101c(%r13), %esi
leal -0x1(%rsi), %eax
addq 0x30(%rcx), %rax
cqto
idivq %rsi
movq %rax, %r14
movl %r14d, %ebx
pushq $0x28
popq %rsi
movq %rbx, %rdi
callq 0x1160
testq %rax, %rax
je 0x1e4b
movq %rax, %r15
callq 0x1210
cmpl $-0x1, %eax
movq %rbx, 0x28(%rsp)
je 0x1e8d
xorps %xmm0, %xmm0
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
cmpl $0x3ff, %eax            # imm = 0x3FF
ja 0x1a51
pushq $0x1
popq %rdx
movl %eax, %ecx
shlq %cl, %rdx
shrl $0x6, %eax
orq %rdx, 0x30(%rsp,%rax,8)
leaq 0x30(%rsp), %rdx
movl $0x80, %esi
xorl %edi, %edi
callq 0x1130
testl %eax, %eax
jne 0x1eae
movq %r14, 0x20(%rsp)
movl %r12d, 0xc(%rsp)
pushq $-0x14
popq %rdx
xorl %edi, %edi
xorl %esi, %esi
callq 0x1110
movq (%r13), %rax
movq 0x30(%rax), %r14
movq %r15, 0x10(%rsp)
addq $0x10, %r15
movq %rbx, %r12
movq %r13, 0x18(%rsp)
subq $0x1, %r12
jb 0x1b62
movl 0x101c(%r13), %eax
cmpq %rax, %r14
movl %r14d, %ebx
cmovgel %eax, %ebx
leaq -0x10(%r15), %rbp
movl %ebx, 0x8(%r15)
movq 0x6786(%rip), %rsi      # 0x8248
movq %rbp, %rdi
movq %rbx, %rdx
callq 0x1240
movl 0x8(%r15), %r13d
testl %eax, %eax
jne 0x1edf
movq 0x6768(%rip), %rsi      # 0x8248
movq %r15, %rdi
movq %r13, %rdx
callq 0x1240
testl %eax, %eax
jne 0x1f0e
movl 0x8(%r15), %edi
callq 0x3118
movl %eax, 0xc(%r15)
leaq -0x8(%r15), %rdi
movq 0x673d(%rip), %rsi      # 0x8248
movl %eax, %edx
callq 0x1240
testl %eax, %eax
jne 0x1f27
leaq 0x8(%r15), %r13
movq (%rbp), %rsi
movl 0xc(%rsp), %edi
movq %r13, %rdx
callq 0x2b94
testl %eax, %eax
jne 0x1f64
cmpl %ebx, (%r13)
jne 0x1f99
subq %rbx, %r14
addq $0x28, %r15
movq 0x18(%rsp), %r13
jmp 0x1a99
cmpl $0x0, 0x1038(%r13)
je 0x1bab
pushq $-0x1
jmp 0x1be2
movq (%r13), %rax
movq 0x8(%r13), %rsi
movq 0x30(%rax), %rdx
leaq 0x38b0(%rip), %rdi      # 0x5425
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x10f0
cmpl $-0x1, 0x1018(%r13)
movl 0xc(%rsp), %r12d
je 0x1cb8
movq %r13, %rdi
movq 0x10(%rsp), %r15
movq %r15, %rsi
movq 0x20(%rsp), %rdx
callq 0x2be4
jmp 0x1fc7
cmpl $0x1, 0x1020(%r13)
jne 0x1cee
pushq $0x1
popq %r15
movl %r15d, %edi
callq 0x1090
testl %eax, %eax
jne 0x203e
movabsq $0x2974756f64747328, %rax # imm = 0x2974756F64747328
movq %rax, 0x10(%r13)
movb $0x0, 0x18(%r13)
pushq $0x1
popq %r15
xorl %ebx, %ebx
movl %r12d, %edi
movl %r15d, %esi
movq %r13, %rdx
callq 0x2155
testl %eax, %eax
je 0x1c49
movl %eax, %ebp
testb %bl, %bl
je 0x2004
leaq 0x10(%r13), %rdi
callq 0x1060
testl %eax, %eax
jns 0x2004
callq 0x1050
movl (%rax), %edi
movq 0x63d7(%rip), %rax      # 0x7ff8
movq (%rax), %rbx
movq 0x8(%r13), %r14
callq 0x1250
leaq 0x374b(%rip), %rsi      # 0x537f
movq %rbx, %rdi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1190
jmp 0x2004
xorl %ebp, %ebp
cmpl $0x1, 0x102c(%r13)
jne 0x2004
cmpl $0x0, 0x1038(%r13)
jne 0x2004
movq 0x8(%r13), %rdi
leaq 0x30(%rsp), %rsi
callq 0x11a0
testl %eax, %eax
js 0x20b6
movl %eax, %ebp
movq 0x30(%rsp), %rcx
movq (%r13), %rax
cmpq (%rax), %rcx
jne 0x2004
movq 0x38(%rsp), %rcx
cmpq 0x8(%rax), %rcx
jne 0x2004
movq 0x8(%r13), %rdi
callq 0x1060
testl %eax, %eax
js 0x2139
movl %eax, %ebp
jmp 0x2004
xorl %ebp, %ebp
xorl %eax, %eax
movq 0x10(%rsp), %r15
movq 0x20(%rsp), %rbx
movl %eax, 0x1018(%r13)
cmpl $0x7, %eax
ja 0x1fc7
movq %r13, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0x2be4
movl 0x1018(%r13), %eax
incl %eax
jmp 0x1cc6
cmpl $0x0, 0x1010(%r13)
je 0x1d94
movl %r12d, %r14d
leaq 0x10(%r13), %rbx
movq 0x8(%r13), %rsi
movl $0x1000, %edx           # imm = 0x1000
movq %rbx, %rdi
callq 0x1070
xorl %ebp, %ebp
movb %bpl, 0x100a(%r13)
movq %rbx, %rdi
callq 0x10d0
movb %bpl, 0x14(%r13,%rax)
movl $0x6d7a6c2e, 0x10(%r13,%rax) # imm = 0x6D7A6C2E
jmp 0x1def
movq 0x62b9(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
movq 0x8(%r13), %rdx
leaq 0x35f2(%rip), %rsi      # 0x533f
xorl %eax, %eax
callq 0x1190
pushq $0x16
popq %rbp
jmp 0x202a
callq 0x1050
movl (%rax), %ebp
movq 0x628e(%rip), %rax      # 0x7ff8
movq (%rax), %rbx
movq 0x8(%r13), %r14
movl %ebp, %edi
callq 0x1250
leaq 0x35de(%rip), %rsi      # 0x535d
movq %rbx, %rdi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1190
jmp 0x2000
movq 0x8(%r13), %rbx
movq %rbx, %rdi
callq 0x10d0
movq %rax, %r15
cmpl $0x4, %r15d
jbe 0x2093
addl $-0x4, %r15d
leaq (%rbx,%r15), %rdi
leaq 0x379c(%rip), %rsi      # 0x5558
callq 0x1170
testl %eax, %eax
jne 0x2093
movl %r12d, %r14d
leaq 0x10(%r13), %rdi
movl $0x1000, %edx           # imm = 0x1000
movq %rbx, %rsi
callq 0x1070
movl $0xfff, %eax            # imm = 0xFFF
cmpl %eax, %r15d
cmovbl %r15d, %eax
movb $0x0, 0x10(%r13,%rax)
leaq 0x10(%r13), %r12
leaq 0x30(%rsp), %rsi
movq %r12, %rdi
callq 0x11a0
testl %eax, %eax
jne 0x1e22
cmpl $0x1, 0x1024(%r13)
jne 0x20de
movq %r12, %rdi
callq 0x1060
testl %eax, %eax
js 0x20fe
movq %r12, %rdi
movl $0xc1, %esi
movl $0x180, %edx            # imm = 0x180
xorl %eax, %eax
callq 0x11d0
movl %eax, %r15d
movb $0x1, %bl
testl %eax, %eax
js 0x205f
movl %r14d, %r12d
jmp 0x1be6
callq 0x1050
movq %rbx, %rcx
movl (%rax), %ebp
movq 0x619c(%rip), %rax      # 0x7ff8
movq (%rax), %rbx
movq 0x8(%r13), %r14
imulq $0x28, %rcx, %r15
movl %ebp, %edi
callq 0x1250
leaq 0x354e(%rip), %rsi      # 0x53c3
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x1190
jmp 0x2000
callq 0x1050
movl (%rax), %ebp
movq 0x615d(%rip), %rax      # 0x7ff8
movq (%rax), %rbx
movl %ebp, %edi
callq 0x1250
leaq 0x3542(%rip), %rsi      # 0x53ee
jmp 0x1ecd
callq 0x1050
movl (%rax), %ebp
movq 0x613c(%rip), %rax      # 0x7ff8
movq (%rax), %rbx
movl %ebp, %edi
callq 0x1250
leaq 0x3538(%rip), %rsi      # 0x5405
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1190
jmp 0x1fc7
movq 0x6112(%rip), %rax      # 0x7ff8
movq (%rax), %rbx
movq 0x18(%rsp), %rax
movq 0x8(%rax), %r14
pushq $0xc
popq %rbp
movl %ebp, %edi
callq 0x1250
leaq 0x323c(%rip), %rsi      # 0x513f
movq %rbx, %rdi
movq %r14, %rdx
movl %r13d, %ecx
jmp 0x1f58
movq 0x60e3(%rip), %rax      # 0x7ff8
movq (%rax), %rbx
movq 0x18(%rsp), %rax
movq 0x8(%rax), %r14
movl 0x8(%r15), %r15d
jmp 0x1f3e
movq 0x60ca(%rip), %rax      # 0x7ff8
movq (%rax), %rbx
movq 0x18(%rsp), %rax
movq 0x8(%rax), %r14
movl 0xc(%r15), %r15d
pushq $0xc
popq %rbp
movl %ebp, %edi
callq 0x1250
leaq 0x31f0(%rip), %rsi      # 0x513f
movq %rbx, %rdi
movq %r14, %rdx
movl %r15d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x1190
jmp 0x1fbd
movl %eax, %ebp
movq 0x608b(%rip), %rax      # 0x7ff8
movq (%rax), %rbx
movq 0x18(%rsp), %rax
movq 0x8(%rax), %r14
movl %ebp, %edi
callq 0x1250
leaq 0x3226(%rip), %rsi      # 0x51ad
movq %rbx, %rdi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1190
jmp 0x1fbd
movq 0x6058(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rdx
leaq 0x348b(%rip), %rsi      # 0x543e
xorl %eax, %eax
callq 0x1190
pushq $0x16
popq %rbp
movl 0xc(%rsp), %r12d
movq 0x10(%rsp), %r15
imulq $0x28, 0x28(%rsp), %rbx
xorl %r14d, %r14d
cmpq %r14, %rbx
je 0x1ff8
movq (%r15,%r14), %rdi
callq 0x1030
movq 0x8(%r15,%r14), %rdi
callq 0x1030
movq 0x10(%r15,%r14), %rdi
callq 0x1030
addq $0x28, %r14
jmp 0x1fd0
movq %r15, %rdi
callq 0x1030
pushq $-0x1
popq %r15
movl %r12d, %eax
decl %eax
cmpl $-0x3, %eax
ja 0x2016
movl %r12d, %edi
callq 0x1120
cmpl $-0x1, %r15d
je 0x202a
cmpl $0x1, %r15d
je 0x202a
movl %r15d, %edi
callq 0x1120
movl %ebp, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5fb3(%rip), %rax      # 0x7ff8
movq (%rax), %rcx
leaq 0x30cb(%rip), %rdi      # 0x511a
pushq $0x1b
popq %rsi
pushq $0x1
popq %rdx
callq 0x1230
pushq $0x5
popq %rbp
jmp 0x2004
callq 0x1050
movl (%rax), %ebp
movq 0x5f8b(%rip), %rax      # 0x7ff8
movq (%rax), %rbx
movl %ebp, %edi
callq 0x1250
leaq 0x32df(%rip), %rsi      # 0x535d
movq %rbx, %rdi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1190
jmp 0x2131
movq 0x5f5e(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq 0x34b9(%rip), %rsi      # 0x555d
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1190
pushq $0x16
popq %rbp
jmp 0x2000
callq 0x1050
movl (%rax), %ebp
movq 0x5f34(%rip), %rax      # 0x7ff8
movq (%rax), %rbx
movq 0x8(%r13), %r14
movl %ebp, %edi
callq 0x1250
leaq 0x2fcc(%rip), %rsi      # 0x50a5
jmp 0x1c34
movq 0x5f13(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq 0x32ac(%rip), %rsi      # 0x539b
movq %r12, %rdx
xorl %eax, %eax
callq 0x1190
pushq $0x11
popq %rbp
jmp 0x212d
callq 0x1050
movl (%rax), %ebp
movq 0x5eec(%rip), %rax      # 0x7ff8
movq (%rax), %rbx
movl %ebp, %edi
callq 0x1250
leaq 0x3262(%rip), %rsi      # 0x537f
movq %rbx, %rdi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1190
pushq $-0x1
popq %r15
movl %r14d, %r12d
jmp 0x2004
callq 0x1050
movl (%rax), %ebp
movq 0x5eb1(%rip), %rax      # 0x7ff8
movq (%rax), %rbx
movq 0x8(%r13), %r14
movl %ebp, %edi
jmp 0x1c28