// File: /workspace/github_c_makefile_star2_O1/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 $0xd8, %rsp
movq %rdi, %r12
movq (%rdi), %rax
cmpq $0x0, 0x30(%rax)
je 0x374a
leaq 0x8(%r12), %r13
movq 0x8(%r12), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x11e0
movl %eax, %r15d
testl %eax, %eax
js 0x3762
movl %r15d, %edi
xorl %esi, %esi
xorl %edx, %edx
movl $0x2, %ecx
callq 0x1150
cmpl $0x1, 0x1030(%r12)
jne 0x357c
movq (%r12), %rcx
movl 0x101c(%r12), %esi
leal -0x1(%rsi), %eax
addq 0x30(%rcx), %rax
cqto
idivq %rsi
movq %rax, %rbx
movl %ebx, %edi
movl $0x28, %esi
movq %rdi, 0x28(%rsp)
callq 0x1170
movq %rax, 0x10(%rsp)
testq %rax, %rax
movq %r15, 0x30(%rsp)
movq %rbx, 0x20(%rsp)
je 0x3874
callq 0x1220
cmpl $-0x1, %eax
je 0x38bd
xorps %xmm0, %xmm0
movaps %xmm0, 0xb0(%rsp)
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)
cmpl $0x3ff, %eax            # imm = 0x3FF
ja 0x33d2
movl $0x1, %edx
movl %eax, %ecx
shlq %cl, %rdx
shrl $0x6, %eax
orq %rdx, 0x40(%rsp,%rax,8)
leaq 0x40(%rsp), %rdx
movl $0x80, %esi
xorl %edi, %edi
callq 0x1140
testl %eax, %eax
jne 0x38cc
movq %r13, 0x18(%rsp)
xorl %edi, %edi
xorl %esi, %esi
movl $0xffffffec, %edx       # imm = 0xFFFFFFEC
callq 0x1110
testl %ebx, %ebx
movq 0x10(%rsp), %r13
je 0x3592
movq (%r12), %rax
movq 0x30(%rax), %r14
xorl %r15d, %r15d
movq %r12, 0x8(%rsp)
movl 0x101c(%r12), %eax
cmpq %rax, %r14
movl %r14d, %ebx
cmovgel %eax, %ebx
leaq (%r15,%r15,4), %r12
leaq (%r13,%r12,8), %rbp
movl %ebx, 0x18(%r13,%r12,8)
movq 0x5e07(%rip), %rsi      # 0x9248
movq %rbp, %rdi
movq %rbx, %rdx
callq 0x1250
movl 0x18(%r13,%r12,8), %edx
testl %eax, %eax
jne 0x3511
leaq 0x18(%r13,%r12,8), %r13
leaq 0x10(%rbp), %rdi
movq 0x5ddf(%rip), %rsi      # 0x9248
callq 0x1250
testl %eax, %eax
jne 0x3529
movl 0x18(%rbp), %edi
callq 0x4ab0
movl %eax, 0x1c(%rbp)
leaq 0x8(%rbp), %rdi
movq 0x5dbc(%rip), %rsi      # 0x9248
movl %eax, %edx
callq 0x1250
testl %eax, %eax
jne 0x3538
movl (%r13), %r12d
testl %r12d, %r12d
je 0x34ce
movq (%rbp), %rbp
movl %r12d, %edx
movq 0x30(%rsp), %rdi
movq %rbp, %rsi
callq 0x1160
testl %eax, %eax
js 0x34d6
je 0x34ce
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
addq %rcx, %rbp
subl %eax, %r12d
jne 0x34a8
subl %r12d, (%r13)
xorl %ebp, %ebp
jmp 0x34dd
callq 0x1050
movl (%rax), %ebp
testl %ebp, %ebp
movq 0x8(%rsp), %r12
jne 0x3555
xorl %ebp, %ebp
cmpl %ebx, (%r13)
movq 0x10(%rsp), %r13
jne 0x3568
testl %ebp, %ebp
jne 0x38e1
subq %rbx, %r14
incq %r15
cmpq 0x28(%rsp), %r15
jne 0x341b
jmp 0x3592
movq 0x18(%rsp), %rdi
movl %edx, %esi
callq 0x1398
movl $0xc, %ebp
movq 0x8(%rsp), %r12
jmp 0x34f3
movq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x13d3
jmp 0x3549
addq $0x1c, %rbp
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
callq 0x140c
movl $0xc, %ebp
movq 0x8(%rsp), %r12
jmp 0x3561
movq 0x18(%rsp), %rdi
movl %ebp, %esi
callq 0x1445
movq 0x10(%rsp), %r13
jmp 0x34f3
movq 0x18(%rsp), %rdi
callq 0x147c
movl $0x16, %ebp
jmp 0x34f3
cmpl $0x0, 0x1038(%r12)
je 0x35d3
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x3615
movq (%r12), %rax
movq 0x8(%r12), %rsi
movq 0x30(%rax), %rdx
leaq 0x2eab(%rip), %rdi      # 0x6451
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x10f0
cmpl $-0x1, 0x1018(%r12)
je 0x36c5
movq %r12, %rdi
movq %r13, %rsi
movq 0x20(%rsp), %rdx
callq 0x44ad
jmp 0x38e1
cmpl $0x1, 0x1020(%r12)
jne 0x36ff
movl $0x1, %r14d
movl $0x1, %edi
callq 0x1090
testl %eax, %eax
jne 0x397f
movabsq $0x2974756f64747328, %rax # imm = 0x2974756F64747328
movq %rax, 0x10(%r12)
movb $0x0, 0x18(%r12)
movl $0x1, %r14d
xorl %ebx, %ebx
movl %r15d, %edi
movl %r14d, %esi
movq %r12, %rdx
callq 0x3a8a
testl %eax, %eax
je 0x3654
movl %eax, %ebp
testb %bl, %bl
je 0x3946
addq $0x10, %r12
movq %r12, %rdi
callq 0x1060
testl %eax, %eax
jns 0x3946
movq %r13, %rdi
callq 0x1328
jmp 0x3946
xorl %ebp, %ebp
cmpl $0x1, 0x102c(%r12)
jne 0x3946
cmpl $0x0, 0x1038(%r12)
jne 0x3946
movq (%r13), %rdi
leaq 0x40(%rsp), %rsi
callq 0x11b0
testl %eax, %eax
js 0x39d8
movl %eax, %ebp
movq 0x40(%rsp), %rcx
movq (%r12), %rax
cmpq (%rax), %rcx
jne 0x3946
movq 0x48(%rsp), %rcx
cmpq 0x8(%rax), %rcx
jne 0x3946
movq (%r13), %rdi
callq 0x1060
testl %eax, %eax
js 0x3a5f
movl %eax, %ebp
jmp 0x3946
movl $0x0, 0x1018(%r12)
movq 0x20(%rsp), %rbx
movq %r12, %rdi
movq %r13, %rsi
movl %ebx, %edx
callq 0x44ad
movl 0x1018(%r12), %eax
incl %eax
movl %eax, 0x1018(%r12)
cmpl $0x8, %eax
jb 0x36d6
jmp 0x38e1
cmpl $0x0, 0x1010(%r12)
je 0x37a0
leaq 0x10(%r12), %r14
movq 0x8(%r12), %rsi
movl $0x1000, %edx           # imm = 0x1000
movq %r14, %rdi
callq 0x1070
xorl %ebp, %ebp
movb %bpl, 0x100a(%r12)
movq %r14, %rdi
callq 0x10d0
movb %bpl, 0x14(%r12,%rax)
movl $0x6d7a6c2e, 0x10(%r12,%rax) # imm = 0x6D7A6C2E
jmp 0x3806
movq %r12, %rdi
callq 0x14d1
movl $0x16, %ebp
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x3940
callq 0x1050
movl (%rax), %ebp
movq 0x5888(%rip), %rax      # 0x8ff8
movq (%rax), %r14
movq %r15, %rbx
movq (%r13), %r15
movl %ebp, %edi
callq 0x1260
leaq 0x2c01(%rip), %rsi      # 0x6389
movq %r14, %rdi
movq %r15, %rdx
movq %rbx, %r15
movq %rax, %rcx
xorl %eax, %eax
callq 0x11a0
jmp 0x3940
movq %r12, 0x8(%rsp)
movq (%r13), %r14
movq %r14, %rdi
callq 0x10d0
movq %rax, %r12
cmpl $0x4, %r12d
jbe 0x398b
addl $-0x4, %r12d
leaq (%r14,%r12), %rdi
leaq 0x2db7(%rip), %rsi      # 0x6584
callq 0x1180
testl %eax, %eax
jne 0x398b
movq 0x8(%rsp), %rbx
leaq 0x10(%rbx), %rdi
movl $0x1000, %edx           # imm = 0x1000
movq %r14, %rsi
callq 0x1070
movl $0xfff, %eax            # imm = 0xFFF
cmpl %eax, %r12d
cmovbl %r12d, %eax
movq %rbx, %r12
movb $0x0, 0x10(%rbx,%rax)
xorl %ebp, %ebp
movb $0x1, %bl
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testb %bl, %bl
je 0x3946
movq %r12, %rbp
addq $0x10, %r12
leaq 0x40(%rsp), %rsi
movq %r12, %rdi
callq 0x11b0
testl %eax, %eax
jne 0x384b
cmpl $0x1, 0x1024(%rbp)
jne 0x3a06
movq %r12, %rdi
callq 0x1060
testl %eax, %eax
js 0x3a2b
movq %r12, %rdi
movl $0xc1, %esi
movl $0x180, %edx            # imm = 0x180
xorl %eax, %eax
callq 0x11e0
movl %eax, %r14d
movb $0x1, %bl
testl %eax, %eax
js 0x39b7
movq %rbp, %r12
jmp 0x3617
callq 0x1050
movl (%rax), %ebp
movq 0x5776(%rip), %rax      # 0x8ff8
movq (%rax), %r14
movq (%r13), %r15
movq 0x28(%rsp), %rax
leaq (,%rax,8), %rax
leaq (%rax,%rax,4), %r13
movl %ebp, %edi
callq 0x1260
leaq 0x2b47(%rip), %rsi      # 0x63ef
movq %r14, %rdi
movq %r15, %rdx
movq %r13, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x11a0
jmp 0x38dc
leaq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x14a0
jmp 0x38d9
leaq 0x3c(%rsp), %r14
movq %r14, %rdi
callq 0x1366
movl (%r14), %ebp
movq 0x10(%rsp), %r13
testq %r13, %r13
movq 0x30(%rsp), %r15
je 0x3940
cmpl $0x0, 0x20(%rsp)
je 0x3938
movq 0x28(%rsp), %rax
shlq $0x3, %rax
leaq (%rax,%rax,4), %rbx
xorl %r14d, %r14d
movq (%r13,%r14), %rdi
testq %rdi, %rdi
je 0x3911
callq 0x1030
movq 0x8(%r13,%r14), %rdi
testq %rdi, %rdi
je 0x3920
callq 0x1030
movq 0x10(%r13,%r14), %rdi
testq %rdi, %rdi
je 0x392f
callq 0x1030
addq $0x28, %r14
cmpq %r14, %rbx
jne 0x3902
movq %r13, %rdi
callq 0x1030
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
leal -0x1(%r15), %eax
cmpl $-0x3, %eax
ja 0x3957
movl %r15d, %edi
callq 0x1130
cmpl $-0x1, %r14d
je 0x396b
cmpl $0x1, %r14d
je 0x396b
movl %r14d, %edi
callq 0x1130
movl %ebp, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x130c
movl $0x5, %ebp
jmp 0x3946
movq 0x5666(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x2bed(%rip), %rsi      # 0x6589
xorl %ebx, %ebx
movq %r14, %rdx
xorl %eax, %eax
callq 0x11a0
movl $0x16, %ebp
movq 0x8(%rsp), %r12
jmp 0x3808
callq 0x1050
movl (%rax), %ebp
movq 0x5633(%rip), %rax      # 0x8ff8
movq (%rax), %rbx
movl %ebp, %edi
callq 0x1260
leaq 0x29b3(%rip), %rsi      # 0x6389
jmp 0x3a4a
callq 0x1050
movl (%rax), %ebp
movq 0x5612(%rip), %rax      # 0x8ff8
movq %r15, %rbx
movq (%rax), %r15
movq (%r13), %r12
movl %ebp, %edi
callq 0x1260
leaq 0x26d3(%rip), %rsi      # 0x60d1
movq %r15, %rdi
movq %rbx, %r15
jmp 0x3a4d
movq 0x55eb(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x29b0(%rip), %rsi      # 0x63c7
movq %r12, %rdx
xorl %eax, %eax
callq 0x11a0
movl $0x11, %ebp
jmp 0x3946
callq 0x1050
movl (%rax), %ebp
movq 0x55bf(%rip), %rax      # 0x8ff8
movq (%rax), %rbx
movl %ebp, %edi
callq 0x1260
leaq 0x2961(%rip), %rsi      # 0x63ab
movq %rbx, %rdi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x11a0
jmp 0x3946
callq 0x1050
movl (%rax), %ebp
movq 0x558b(%rip), %rax      # 0x8ff8
movq %r15, %rbx
movq (%rax), %r15
movq (%r13), %r12
movl %ebp, %edi
callq 0x1260
leaq 0x2926(%rip), %rsi      # 0x63ab
jmp 0x39fe