// File: /workspace/github_c_makefile_star2_O0/lmcilroy[P]lzm/lzm.c
// Function: compress_fd
static unsigned int
compress_fd(const int fd_in, const int fd_out,
    const struct compress_args * const args)
{
	struct lzm_state *state = NULL;
	unsigned char *buffer_in = NULL;
	unsigned char *buffer_out = NULL;
	unsigned char *write_buffer = NULL;
	off_t total_in = 0;
	off_t total_out = 0;
	unsigned int size_out;
	unsigned int size_in;
	unsigned int size_flag;
	unsigned int write_size;
	unsigned int header;
	int ret;

	ret = posix_memalign((void **)&buffer_in, pagesize, 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;
	}

	ret = posix_memalign((void **)&buffer_out, pagesize, 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;
	}

	ret = lzm_encode_init(&state, args->format, args->level);
	if (ret != 0) {
		fprintf(stderr, "File %s: failed to init lzm: %s\n",
		    args->filename, strerror(ret));
		goto out;
	}

	header = HEADER_VALUE;
	ret = write_data(fd_out, &header, sizeof(header));
	if (ret != 0) {
		fprintf(stderr, "File %s: failed to write data: %s\n",
		    args->filename_out, strerror(ret));
		goto out;
	}

	total_out += sizeof(header);

	ret = write_data(fd_out, &args->format, sizeof(args->format));
	if (ret != 0) {
		fprintf(stderr, "File %s: failed to write data: %s\n",
		    args->filename_out, strerror(ret));
		goto out;
	}

	total_out += sizeof(args->format);

	ret = write_data(fd_out, &args->chunk_size, sizeof(args->chunk_size));
	if (ret != 0) {
		fprintf(stderr, "File %s: failed to write data: %s\n",
		    args->filename_out, strerror(ret));
		goto out;
	}

	total_out += sizeof(args->chunk_size);

	for (;;) {

		size_in = args->chunk_size;
		ret = read_data(fd_in, buffer_in, &size_in);
		if (ret != 0) {
			fprintf(stderr, "File %s: failed to read data: %s\n",
			    args->filename, strerror(ret));
			goto out;
		}

		if (size_in == 0)
			break;

		size_out = args->chunk_size;
		size_flag = 0;
		write_buffer = buffer_out;
		ret = lzm_encode(state, buffer_in, size_in, buffer_out,
		    &size_out);
		if (ret == EOVERFLOW &&
		    args->chunk_size < LZM_NO_COMPRESSION) {
			size_out = size_in;
			size_flag = LZM_NO_COMPRESSION;
			write_buffer = buffer_in;
			ret = 0;
		}

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

		write_size = size_out | size_flag;
		ret = write_data(fd_out, &write_size, sizeof(write_size));
		if (ret != 0) {
			fprintf(stderr, "File %s: failed to write data: %s\n",
			    args->filename_out, strerror(ret));
			goto out;
		}

		ret = write_data(fd_out, write_buffer, size_out);
		if (ret != 0) {
			fprintf(stderr, "File %s: failed to write data: %s\n",
			    args->filename_out, strerror(ret));
			goto out;
		}

		total_in += size_in;
		total_out += size_out + sizeof(size_out);
	}

	ret = 0;

 out:

	lzm_encode_finish(state);

	if (buffer_in != NULL)
		free(buffer_in);
	if (buffer_out != NULL)
		free(buffer_out);

	if (args->verbose == true && ret == 0 && fd_out != STDOUT_FILENO) {
		float perc = (float)total_out / (float)total_in * (float)100;
		printf("Compressed %s: in %ld, out %ld, %.4f%%\n",
		    args->filename_out, total_in, total_out, perc);
	}

	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq 0x815c(%rip), %rsi      # 0xa248
movq -0x10(%rbp), %rax
movl 0x101c(%rax), %eax
movl %eax, %edx
leaq -0x20(%rbp), %rdi
callq 0x1240
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x2161
movl $0xc, -0x58(%rbp)
movq 0x7ee0(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movl 0x101c(%rax), %eax
movl %eax, -0x60(%rbp)
movl -0x58(%rbp), %edi
callq 0x1250
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rdx
movl -0x60(%rbp), %ecx
movq %rax, %r8
leaq 0x525f(%rip), %rsi      # 0x73b4
movb $0x0, %al
callq 0x1190
jmp 0x25f4
movq 0x80e0(%rip), %rsi      # 0xa248
movq -0x10(%rbp), %rax
movl 0x101c(%rax), %eax
movl %eax, %edx
leaq -0x28(%rbp), %rdi
callq 0x1240
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x21e3
movl $0xc, -0x58(%rbp)
movq 0x7e64(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rax
movl 0x101c(%rax), %eax
movl %eax, -0x74(%rbp)
movl -0x58(%rbp), %edi
callq 0x1250
movq -0x88(%rbp), %rdi
movq -0x80(%rbp), %rdx
movl -0x74(%rbp), %ecx
movq %rax, %r8
leaq 0x51dd(%rip), %rsi      # 0x73b4
movb $0x0, %al
callq 0x1190
jmp 0x25f4
movq -0x10(%rbp), %rax
movl 0x1014(%rax), %esi
movq -0x10(%rbp), %rax
movl 0x1018(%rax), %edx
leaq -0x18(%rbp), %rdi
callq 0x4b60
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x2255
movq 0x7de8(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x90(%rbp)
movl -0x58(%rbp), %edi
callq 0x1250
movq -0x98(%rbp), %rdi
movq -0x90(%rbp), %rdx
movq %rax, %rcx
leaq 0x5195(%rip), %rsi      # 0x73de
movb $0x0, %al
callq 0x1190
jmp 0x25f4
movl $0x314d5a4c, -0x54(%rbp) # imm = 0x314D5A4C
movl -0x8(%rbp), %edi
leaq -0x54(%rbp), %rsi
movl $0x4, %edx
callq 0x2e60
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x22c2
movq 0x7d7b(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rax
addq $0x10, %rax
movq %rax, -0xa0(%rbp)
movl -0x58(%rbp), %edi
callq 0x1250
movq -0xa8(%rbp), %rdi
movq -0xa0(%rbp), %rdx
movq %rax, %rcx
leaq 0x5149(%rip), %rsi      # 0x73ff
movb $0x0, %al
callq 0x1190
jmp 0x25f4
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
addq $0x1014, %rsi           # imm = 0x1014
movl $0x4, %edx
callq 0x2e60
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x233b
movq 0x7d02(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rax
addq $0x10, %rax
movq %rax, -0xb0(%rbp)
movl -0x58(%rbp), %edi
callq 0x1250
movq -0xb8(%rbp), %rdi
movq -0xb0(%rbp), %rdx
movq %rax, %rcx
leaq 0x50d0(%rip), %rsi      # 0x73ff
movb $0x0, %al
callq 0x1190
jmp 0x25f4
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
addq $0x101c, %rsi           # imm = 0x101C
movl $0x4, %edx
callq 0x2e60
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x23b4
movq 0x7c89(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0xc8(%rbp)
movq -0x10(%rbp), %rax
addq $0x10, %rax
movq %rax, -0xc0(%rbp)
movl -0x58(%rbp), %edi
callq 0x1250
movq -0xc8(%rbp), %rdi
movq -0xc0(%rbp), %rdx
movq %rax, %rcx
leaq 0x5057(%rip), %rsi      # 0x73ff
movb $0x0, %al
callq 0x1190
jmp 0x25f4
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movl 0x101c(%rax), %eax
movl %eax, -0x48(%rbp)
movl -0x4(%rbp), %edi
movq -0x20(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x2ee0
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x2432
movq 0x7c0b(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0xd8(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xd0(%rbp)
movl -0x58(%rbp), %edi
callq 0x1250
movq -0xd8(%rbp), %rdi
movq -0xd0(%rbp), %rdx
movq %rax, %rcx
leaq 0x4ffc(%rip), %rsi      # 0x7422
movb $0x0, %al
callq 0x1190
jmp 0x25f4
cmpl $0x0, -0x48(%rbp)
jne 0x243d
jmp 0x25ed
movq -0x10(%rbp), %rax
movl 0x101c(%rax), %eax
movl %eax, -0x44(%rbp)
movl $0x0, -0x4c(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x48(%rbp), %edx
movq -0x28(%rbp), %rcx
leaq -0x44(%rbp), %r8
callq 0x4db0
movl %eax, -0x58(%rbp)
cmpl $0x4b, -0x58(%rbp)
jne 0x24aa
movq -0x10(%rbp), %rax
movl 0x101c(%rax), %eax
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
jae 0x24aa
movl -0x48(%rbp), %eax
movl %eax, -0x44(%rbp)
movl $0x80000000, -0x4c(%rbp) # imm = 0x80000000
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x24fc
movq 0x7b41(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0xe8(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xe0(%rbp)
movl -0x58(%rbp), %edi
callq 0x1250
movq -0xe8(%rbp), %rdi
movq -0xe0(%rbp), %rdx
movq %rax, %rcx
leaq 0x4f54(%rip), %rsi      # 0x7444
movb $0x0, %al
callq 0x1190
jmp 0x25f4
movl -0x44(%rbp), %eax
orl -0x4c(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x8(%rbp), %edi
leaq -0x50(%rbp), %rsi
movl $0x4, %edx
callq 0x2e60
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x256b
movq 0x7ad2(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0xf8(%rbp)
movq -0x10(%rbp), %rax
addq $0x10, %rax
movq %rax, -0xf0(%rbp)
movl -0x58(%rbp), %edi
callq 0x1250
movq -0xf8(%rbp), %rdi
movq -0xf0(%rbp), %rdx
movq %rax, %rcx
leaq 0x4ea0(%rip), %rsi      # 0x73ff
movb $0x0, %al
callq 0x1190
jmp 0x25f4
movl -0x8(%rbp), %edi
movq -0x30(%rbp), %rsi
movl -0x44(%rbp), %eax
movl %eax, %edx
callq 0x2e60
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x25ce
movq 0x7a6c(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0x108(%rbp)
movq -0x10(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x100(%rbp)
movl -0x58(%rbp), %edi
callq 0x1250
movq -0x108(%rbp), %rdi
movq -0x100(%rbp), %rdx
movq %rax, %rcx
leaq 0x4e3a(%rip), %rsi      # 0x73ff
movb $0x0, %al
callq 0x1190
jmp 0x25f4
movl -0x48(%rbp), %eax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x44(%rbp), %eax
addq $0x4, %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x23c0
movl $0x0, -0x58(%rbp)
movq -0x18(%rbp), %rdi
callq 0x4d50
cmpq $0x0, -0x20(%rbp)
je 0x260d
movq -0x20(%rbp), %rdi
callq 0x1030
cmpq $0x0, -0x28(%rbp)
je 0x261d
movq -0x28(%rbp), %rdi
callq 0x1030
movq -0x10(%rbp), %rax
cmpl $0x1, 0x1034(%rax)
jne 0x267e
cmpl $0x0, -0x58(%rbp)
jne 0x267e
cmpl $0x1, -0x8(%rbp)
je 0x267e
cvtsi2ssq -0x40(%rbp), %xmm0
cvtsi2ssq -0x38(%rbp), %xmm1
divss %xmm1, %xmm0
movss 0x4ada(%rip), %xmm1     # 0x7128
mulss %xmm1, %xmm0
movss %xmm0, -0x5c(%rbp)
movq -0x10(%rbp), %rsi
addq $0x10, %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
movss -0x5c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x4df1(%rip), %rdi      # 0x7468
movb $0x1, %al
callq 0x10e0
movl -0x58(%rbp), %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopw (%rax,%rax)