// File: /workspace/github_c_makefile_star2_O0/lmcilroy[P]lzm/lzdata.c
// Function: process_file
static unsigned int
process_file(struct lzdata_args * const args)
{
	unsigned char *buffer = NULL;
	off_t written;
	unsigned int size;
	int fd = -1;
	int ret;

	ret = posix_memalign((void **)&buffer, getpagesize(),
	    args->chunk_size);
	if (ret != 0) {
		ret = ENOMEM;
		fprintf(stderr, "File %s: failed to allocate %d bytes: %s\n",
		    args->filename, args->chunk_size, strerror(ret));
		goto out;
	}

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

	args->literals = 0;
	args->literal_bytes = 0;
	args->matches = 0;
	args->match_bytes = 0;

	for (written = 0; written < args->file_size; written += size) {

		size = args->chunk_size;
		if (written + size > args->file_size)
			size = args->file_size - written;

		generate_data(args, buffer, size);

		ret = write_data(fd, buffer, size);
		if (ret != 0) {
			fprintf(stderr, "File %s: failed to write data: %s\n",
			    args->filename, strerror(ret));
			goto out;
		}
	}

	if (args->verbose == true) {
		printf("literals %ld/%ld, matches %ld/%ld, dupe data %.4f%%\n",
		    args->literals, args->literal_bytes,
		    args->matches, args->match_bytes,
		    (float)args->match_bytes * 100 /
		    (float)(args->literal_bytes + args->match_bytes));
	}

 out:

	if (buffer != NULL)
		free(buffer);

	if (fd != -1)
		close(fd);

	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq $0x0, -0x10(%rbp)
movl $0xffffffff, -0x20(%rbp) # imm = 0xFFFFFFFF
callq 0x10f0
movslq %eax, %rsi
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %edx
leaq -0x10(%rbp), %rdi
callq 0x1110
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x1a44
movl $0xc, -0x24(%rbp)
movq 0x35f9(%rip), %rax      # 0x4ff8
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %edi
callq 0x1120
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rdx
movl -0x28(%rbp), %ecx
movq %rax, %r8
leaq 0x1d13(%rip), %rsi      # 0x374b
movb $0x0, %al
callq 0x10b0
jmp 0x1ca4
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movl $0xc1, %esi
movl $0x180, %edx            # imm = 0x180
movb $0x0, %al
callq 0x10d0
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x1aae
callq 0x1040
movl (%rax), %eax
movl %eax, -0x24(%rbp)
movq 0x3582(%rip), %rax      # 0x4ff8
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movl -0x24(%rbp), %edi
callq 0x1120
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rdx
movq %rax, %rcx
leaq 0x1cd3(%rip), %rsi      # 0x3775
movb $0x0, %al
callq 0x10b0
jmp 0x1ca4
movq -0x8(%rbp), %rax
movq $0x0, 0x50(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x60(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x58(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x68(%rax)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jge 0x1ba0
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
addq %rcx, %rax
movq -0x8(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jle 0x1b25
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
subq -0x18(%rbp), %rax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0x1cd0
movl -0x20(%rbp), %edi
movq -0x10(%rbp), %rsi
movl -0x1c(%rbp), %eax
movl %eax, %edx
callq 0x1da0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x1b8e
movq 0x34a2(%rip), %rax      # 0x4ff8
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movl -0x24(%rbp), %edi
callq 0x1120
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rdx
movq %rax, %rcx
leaq 0x1c15(%rip), %rsi      # 0x3797
movb $0x0, %al
callq 0x10b0
jmp 0x1ca4
jmp 0x1b90
movl -0x1c(%rbp), %eax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x1ae6
movq -0x8(%rbp), %rax
cmpl $0x1, 0x2c(%rax)
jne 0x1ca2
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rcx
movq %rcx, -0x80(%rbp)
movq 0x58(%rax), %rcx
movq %rcx, -0x78(%rbp)
movq 0x60(%rax), %rcx
movq %rcx, -0x70(%rbp)
movq 0x68(%rax), %rax
movq %rax, -0x68(%rbp)
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x60(%rbp)
testq %rax, %rax
movss %xmm0, -0x5c(%rbp)
js 0x1c07
movss -0x60(%rbp), %xmm0
movss %xmm0, -0x5c(%rbp)
movq -0x68(%rbp), %rcx
movq -0x70(%rbp), %rax
movss -0x5c(%rbp), %xmm0
movss 0x15e0(%rip), %xmm1     # 0x31fc
mulss %xmm1, %xmm0
movss %xmm0, -0x8c(%rbp)
addq %rcx, %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x88(%rbp)
testq %rax, %rax
movss %xmm0, -0x84(%rbp)
js 0x1c6c
movss -0x88(%rbp), %xmm0
movss %xmm0, -0x84(%rbp)
movq -0x68(%rbp), %r8
movq -0x78(%rbp), %rcx
movq -0x70(%rbp), %rdx
movq -0x80(%rbp), %rsi
movss -0x8c(%rbp), %xmm0
movss -0x84(%rbp), %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x1b1f(%rip), %rdi      # 0x37ba
movb $0x1, %al
callq 0x1080
jmp 0x1ca4
cmpq $0x0, -0x10(%rbp)
je 0x1cb4
movq -0x10(%rbp), %rdi
callq 0x1030
cmpl $-0x1, -0x20(%rbp)
je 0x1cc2
movl -0x20(%rbp), %edi
callq 0x1090
movl -0x24(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nop