// File: /workspace/github_c_makefile_star2_O3/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, %rbx
movq (%rdi), %rax
cmpq $0x0, 0x30(%rax)
je 0x36c9
leaq 0x8(%rbx), %r15
movq 0x8(%rbx), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x11e0
movl %eax, %r13d
testl %eax, %eax
js 0x36dc
movl %r13d, %edi
xorl %esi, %esi
xorl %edx, %edx
movl $0x2, %ecx
callq 0x1150
cmpl $0x1, 0x1030(%rbx)
jne 0x35de
movq (%rbx), %rcx
movl 0x101c(%rbx), %esi
leal -0x1(%rsi), %eax
addq 0x30(%rcx), %rax
cqto
idivq %rsi
movq %rax, %r14
movl %r14d, %edi
movl $0x28, %esi
movq %rdi, 0x28(%rsp)
callq 0x1170
testq %rax, %rax
je 0x387e
movq %rax, %rbp
callq 0x1220
cmpl $-0x1, %eax
je 0x38c7
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 0x3424
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 0x38d6
movq %rbp, 0x8(%rsp)
xorl %edi, %edi
xorl %esi, %esi
movl $0xffffffec, %edx       # imm = 0xFFFFFFEC
callq 0x1110
movq (%rbx), %rax
movq 0x30(%rax), %rdx
testl %r14d, %r14d
je 0x35a4
movq %r14, 0x10(%rsp)
movq %r15, 0x18(%rsp)
movl %r13d, 0x4(%rsp)
xorl %r15d, %r15d
movq %rbx, 0x20(%rsp)
movq 0x8(%rsp), %rbp
movl 0x101c(%rbx), %eax
cmpq %rax, %rdx
movq %rdx, 0x30(%rsp)
movl %edx, %r14d
cmovgel %eax, %r14d
leaq (%r15,%r15,4), %r12
leaq (%rbp,%r12,8), %rbx
movl %r14d, 0x18(%rbp,%r12,8)
movq 0x5da2(%rip), %rsi      # 0x9248
movq %rbx, %rdi
movq %r14, %rdx
callq 0x1250
movl 0x18(%rbp,%r12,8), %edx
testl %eax, %eax
jne 0x38e8
leaq 0x18(,%r12,8), %r13
addq %rbp, %r13
leaq 0x10(%rbx), %rdi
movq 0x5d74(%rip), %rsi      # 0x9248
callq 0x1250
testl %eax, %eax
jne 0x3901
movl 0x18(%rbx), %edi
callq 0x4ac0
movl %eax, 0x1c(%rbx)
leaq 0x8(%rbx), %rdi
movq 0x5d51(%rip), %rsi      # 0x9248
movl %eax, %edx
callq 0x1250
testl %eax, %eax
jne 0x3910
movl (%r13), %r12d
testl %r12d, %r12d
je 0x3548
movq (%rbx), %rbx
movl %r12d, %edx
movl 0x4(%rsp), %edi
movq %rbx, %rsi
callq 0x1160
testl %eax, %eax
js 0x355a
je 0x353a
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
addq %rcx, %rbx
subl %eax, %r12d
jne 0x3512
xorl %r12d, %r12d
movq 0x20(%rsp), %rbx
movl (%r13), %eax
subl %r12d, %eax
jmp 0x354f
xorl %eax, %eax
movq 0x20(%rsp), %rbx
movq 0x30(%rsp), %rdx
movl %eax, (%r13)
jmp 0x3579
callq 0x1050
movl (%rax), %r12d
testl %r12d, %r12d
jne 0x3a42
movl (%r13), %eax
movq 0x20(%rsp), %rbx
movq 0x30(%rsp), %rdx
cmpl %r14d, %eax
jne 0x3925
subq %r14, %rdx
incq %r15
cmpq 0x28(%rsp), %r15
jne 0x347c
movq (%rbx), %rax
movq 0x30(%rax), %rdx
movl 0x4(%rsp), %r13d
movq 0x10(%rsp), %r14
movq 0x8(%rbx), %rsi
leaq 0x2eaa(%rip), %rdi      # 0x6459
xorl %r12d, %r12d
xorl %eax, %eax
callq 0x10f0
cmpl $-0x1, 0x1018(%rbx)
je 0x3648
movq %rbx, %rdi
movq 0x8(%rsp), %rbp
movq %rbp, %rsi
movl %r14d, %edx
callq 0x44ba
jmp 0x3944
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
cmpl $0x0, 0x1038(%rbx)
jne 0x362a
cmpl $0x1, 0x1020(%rbx)
jne 0x367d
movl $0x1, %r14d
movl $0x1, %edi
callq 0x1090
testl %eax, %eax
jne 0x39d8
movabsq $0x2974756f64747328, %rax # imm = 0x2974756F64747328
movq %rax, 0x10(%rbx)
movb $0x0, 0x18(%rbx)
movl $0x1, %r14d
movl %r13d, %edi
movl %r14d, %esi
movq %rbx, %rdx
callq 0x3ae0
testl %eax, %eax
je 0x37f0
movl %eax, %r12d
jmp 0x399d
movl $0x0, 0x1018(%rbx)
movq 0x8(%rsp), %rbp
movq %rbx, %rdi
movq %rbp, %rsi
movl %r14d, %edx
callq 0x44ba
movl 0x1018(%rbx), %eax
incl %eax
movl %eax, 0x1018(%rbx)
cmpl $0x8, %eax
jb 0x3657
jmp 0x3944
cmpl $0x0, 0x1010(%rbx)
je 0x3715
movq %rbx, %r14
addq $0x10, %rbx
movq 0x8(%r14), %rsi
movl $0x1000, %edx           # imm = 0x1000
movq %rbx, %rdi
callq 0x1070
xorl %ebp, %ebp
movb %bpl, 0x100a(%r14)
movq %rbx, %rdi
movq %r14, %rbx
callq 0x10d0
movb %bpl, 0x14(%r14,%rax)
movl $0x6d7a6c2e, 0x10(%r14,%rax) # imm = 0x6D7A6C2E
jmp 0x3773
movq %rbx, %rdi
callq 0x14d2
movl $0x16, %r12d
jmp 0x39c3
callq 0x1050
movl (%rax), %r12d
movq 0x590d(%rip), %rax      # 0x8ff8
movq (%rax), %rbx
movq (%r15), %r14
movl %r12d, %edi
callq 0x1260
leaq 0x2c91(%rip), %rsi      # 0x6391
movq %rbx, %rdi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x11a0
jmp 0x3997
movq %rbx, %r12
movq (%r15), %rbx
movq %rbx, %rdi
callq 0x10d0
movq %rax, %r14
cmpl $0x4, %r14d
jbe 0x3a0f
addl $-0x4, %r14d
leaq (%rbx,%r14), %rdi
leaq 0x2e4d(%rip), %rsi      # 0x658c
callq 0x1180
testl %eax, %eax
jne 0x3a0f
leaq 0x10(%r12), %rdi
movl $0x1000, %edx           # imm = 0x1000
movq %rbx, %rsi
movq %r12, %rbx
callq 0x1070
movl $0xfff, %eax            # imm = 0xFFF
cmpl %eax, %r14d
cmovbl %r14d, %eax
movb $0x0, 0x10(%r12,%rax)
leaq 0x10(%rbx), %r12
leaq 0x40(%rsp), %rsi
movq %r12, %rdi
callq 0x11b0
testl %eax, %eax
jne 0x37a5
cmpl $0x1, 0x1024(%rbx)
jne 0x3a8d
movq %r12, %rdi
callq 0x1060
testl %eax, %eax
js 0x3ab3
movq %r12, %rdi
movl $0xc1, %esi
movl $0x180, %edx            # imm = 0x180
xorl %eax, %eax
callq 0x11e0
movl %eax, %r14d
testl %eax, %eax
js 0x39e5
movl %r13d, %edi
movl %r14d, %esi
movq %rbx, %rdx
callq 0x3ae0
testl %eax, %eax
je 0x37f0
movl %eax, %ebp
movq %r12, %rdi
callq 0x1060
testl %eax, %eax
js 0x3a35
movl %ebp, %r12d
jmp 0x399d
xorl %r12d, %r12d
cmpl $0x1, 0x102c(%rbx)
jne 0x399d
cmpl $0x0, 0x1038(%rbx)
jne 0x399d
movq (%r15), %rdi
leaq 0x40(%rsp), %rsi
callq 0x11b0
testl %eax, %eax
js 0x3a54
movl %eax, %r12d
movq 0x40(%rsp), %rcx
movq (%rbx), %rax
cmpq (%rax), %rcx
jne 0x399d
movq 0x48(%rsp), %rcx
cmpq 0x8(%rax), %rcx
jne 0x399d
movq (%r15), %rdi
callq 0x1060
testl %eax, %eax
jns 0x3640
callq 0x1050
movl (%rax), %r12d
movq 0x5794(%rip), %rax      # 0x8ff8
movq (%rax), %rbx
movq (%r15), %r15
movl %r12d, %edi
callq 0x1260
leaq 0x2b3a(%rip), %rsi      # 0x63b3
jmp 0x3a78
callq 0x1050
movl (%rax), %r12d
movq 0x576b(%rip), %rax      # 0x8ff8
movq (%rax), %rbx
movq (%r15), %r14
movq 0x28(%rsp), %rax
shlq $0x3, %rax
leaq (%rax,%rax,4), %r15
movl %r12d, %edi
callq 0x1260
leaq 0x2b48(%rip), %rsi      # 0x63f7
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x11a0
jmp 0x3997
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x14a1
jmp 0x38e3
leaq 0x3c(%rsp), %rbx
movq %rbx, %rdi
callq 0x1366
movl (%rbx), %r12d
jmp 0x3944
movq 0x18(%rsp), %rdi
movl %edx, %esi
callq 0x1398
movl $0xc, %r12d
movl 0x4(%rsp), %r13d
jmp 0x393f
movq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x13d3
jmp 0x391d
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0x140c
movl $0xc, %r12d
jmp 0x3935
movq 0x18(%rsp), %rdi
callq 0x147d
movl $0x16, %r12d
movl 0x4(%rsp), %r13d
movq 0x8(%rsp), %rbp
movq 0x10(%rsp), %r14
testl %r14d, %r14d
je 0x398f
movq 0x28(%rsp), %rax
shlq $0x3, %rax
leaq (%rax,%rax,4), %rbx
xorl %r14d, %r14d
movq (%rbp,%r14), %rdi
testq %rdi, %rdi
je 0x3968
callq 0x1030
movq 0x8(%rbp,%r14), %rdi
testq %rdi, %rdi
je 0x3977
callq 0x1030
movq 0x10(%rbp,%r14), %rdi
testq %rdi, %rdi
je 0x3986
callq 0x1030
addq $0x28, %r14
cmpq %r14, %rbx
jne 0x3959
movq %rbp, %rdi
callq 0x1030
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl %r13d, %eax
decl %eax
cmpl $-0x3, %eax
ja 0x39af
movl %r13d, %edi
callq 0x1130
cmpl $-0x1, %r14d
je 0x39c3
cmpl $0x1, %r14d
je 0x39c3
movl %r14d, %edi
callq 0x1130
movl %r12d, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x134a
movl $0x5, %r12d
jmp 0x399d
callq 0x1050
movl (%rax), %ebp
movq 0x5605(%rip), %rax      # 0x8ff8
movq (%rax), %rbx
movl %ebp, %edi
callq 0x1260
leaq 0x298d(%rip), %rsi      # 0x6391
movq %rbx, %rdi
movq %r12, %rdx
movl %ebp, %r12d
jmp 0x3a7e
movq 0x55e2(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x2b71(%rip), %rsi      # 0x6591
movq %rbx, %rdx
xorl %eax, %eax
callq 0x11a0
movl $0x16, %r12d
jmp 0x3997
movq %r15, %rdi
callq 0x130c
jmp 0x37e8
movq 0x18(%rsp), %rdi
movl %r12d, %esi
callq 0x1446
jmp 0x3935
callq 0x1050
movl (%rax), %r12d
movq 0x5595(%rip), %rax      # 0x8ff8
movq (%rax), %rbx
movq (%r15), %r15
movl %r12d, %edi
callq 0x1260
leaq 0x2661(%rip), %rsi      # 0x60d9
movq %rbx, %rdi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x11a0
jmp 0x399d
movq 0x5564(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x2931(%rip), %rsi      # 0x63cf
movq %r12, %rdx
xorl %eax, %eax
callq 0x11a0
movl $0x11, %r12d
jmp 0x3997
callq 0x1050
movl (%rax), %ebp
movq 0x5537(%rip), %rax      # 0x8ff8
movq (%rax), %rbx
movl %ebp, %edi
callq 0x1260
leaq 0x28e1(%rip), %rsi      # 0x63b3
movq %rbx, %rdi
movq %r12, %rdx
movl %ebp, %r12d
jmp 0x3706