// File: /workspace/github_c_makefile_star2_O0/lmcilroy[P]lzm/lzm.c
// Function: decompress_fd
static unsigned int
decompress_fd(const int fd_in, const int fd_out,
    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 header;
	unsigned int bytes;
	unsigned int no_compression;
	int ret;

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

	if (bytes != sizeof(header)) {
		ret = EIO;
		fprintf(stderr, "File %s: unexpected eof\n",
		    args->filename);
		goto out;
	}

	total_in += bytes;

	if (header != HEADER_VALUE) {
		ret = EINVAL;
		fprintf(stderr, "File %s: bad header value\n",
		    args->filename);
		goto out;
	}

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

	if (bytes != sizeof(args->format)) {
		ret = EIO;
		fprintf(stderr, "File %s: Unexpected eof\n",
		    args->filename);
		goto out;
	}

	total_in += bytes;

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

	if (bytes != sizeof(args->chunk_size)) {
		ret = EIO;
		fprintf(stderr, "File %s: Unexpected eof\n",
		    args->filename);
		goto out;
	}

	total_in += bytes;

	if (args->chunk_size == 0) {
		ret = EINVAL;
		fprintf(stderr, "File %s: Invalid chunk size\n",
		    args->filename);
		goto out;
	}

	ret = posix_memalign((void **)&buffer_in, pagesize, args->chunk_size);
	if (ret != 0) {
		ret = ENOMEM;
		fprintf(stderr,
		    "File %s: failed to allocate memory (%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 memory (%d bytes): %s\n",
		    args->filename, args->chunk_size, strerror(ret));
		goto out;
	}

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

	for (;;) {

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

		if (bytes == 0)
			break;

		if (bytes != sizeof(size_in)) {
			ret = EIO;
			fprintf(stderr, "File %s: unexpected eof\n",
			    args->filename);
			goto out;
		}

		total_in += bytes;

		no_compression = 0;
		if (args->chunk_size < LZM_NO_COMPRESSION &&
		    (size_in & LZM_NO_COMPRESSION) != 0) {
			no_compression = 1;
			size_in &= ~LZM_NO_COMPRESSION;
		}

		if (size_in > args->chunk_size) {
			ret = EINVAL;
			fprintf(stderr, "File %s: Invalid chunk size\n",
			    args->filename);
			goto out;
		}

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

		if (bytes != size_in) {
			ret = EIO;
			fprintf(stderr, "File %s: unexpected eof\n",
			    args->filename);
			goto out;
		}

		size_out = args->chunk_size;
		if (!no_compression) {
			ret = lzm_decode(state, buffer_in, size_in,
			    buffer_out, &size_out);
			if (ret != 0) {
				fprintf(stderr,
				    "File %s: failed to decode data: %s\n",
				    args->filename, strerror(ret));
				goto out;
			}
			write_buffer = buffer_out;
		} else {
			write_buffer = buffer_in;
		}

		if (args->test == false) {
			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;
	}

	ret = 0;

 out:

	lzm_decode_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("Decompressed %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)
movl $0x4, -0x50(%rbp)
movl -0x4(%rbp), %edi
leaq -0x4c(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x2ee0
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x2735
movq 0x78fc(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
movl -0x58(%rbp), %edi
callq 0x1250
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rdx
movq %rax, %rcx
leaq 0x4cf9(%rip), %rsi      # 0x7422
movb $0x0, %al
callq 0x1190
jmp 0x2dc5
movl -0x50(%rbp), %eax
cmpq $0x4, %rax
je 0x276a
movl $0x5, -0x58(%rbp)
movq 0x78ac(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x4d32(%rip), %rsi      # 0x7490
movb $0x0, %al
callq 0x1190
jmp 0x2dc5
movl -0x50(%rbp), %eax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpl $0x314d5a4c, -0x4c(%rbp) # imm = 0x314D5A4C
je 0x27aa
movl $0x16, -0x58(%rbp)
movq 0x786c(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x4d0b(%rip), %rsi      # 0x74a9
movb $0x0, %al
callq 0x1190
jmp 0x2dc5
movl $0x4, -0x50(%rbp)
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
addq $0x1014, %rsi           # imm = 0x1014
leaq -0x50(%rbp), %rdx
callq 0x2ee0
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x2811
movq 0x7820(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
movl -0x58(%rbp), %edi
callq 0x1250
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rdx
movq %rax, %rcx
leaq 0x4c1d(%rip), %rsi      # 0x7422
movb $0x0, %al
callq 0x1190
jmp 0x2dc5
movl -0x50(%rbp), %eax
cmpq $0x4, %rax
je 0x2846
movl $0x5, -0x58(%rbp)
movq 0x77d0(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x4c8a(%rip), %rsi      # 0x74c4
movb $0x0, %al
callq 0x1190
jmp 0x2dc5
movl -0x50(%rbp), %eax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x4, -0x50(%rbp)
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
addq $0x101c, %rsi           # imm = 0x101C
leaq -0x50(%rbp), %rdx
callq 0x2ee0
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x28c4
movq 0x7779(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x88(%rbp)
movl -0x58(%rbp), %edi
callq 0x1250
movq -0x90(%rbp), %rdi
movq -0x88(%rbp), %rdx
movq %rax, %rcx
leaq 0x4b6a(%rip), %rsi      # 0x7422
movb $0x0, %al
callq 0x1190
jmp 0x2dc5
movl -0x50(%rbp), %eax
cmpq $0x4, %rax
je 0x28f9
movl $0x5, -0x58(%rbp)
movq 0x771d(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x4bd7(%rip), %rsi      # 0x74c4
movb $0x0, %al
callq 0x1190
jmp 0x2dc5
movl -0x50(%rbp), %eax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x101c(%rax)
jne 0x293d
movl $0x16, -0x58(%rbp)
movq 0x76d9(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x4bac(%rip), %rsi      # 0x74dd
movb $0x0, %al
callq 0x1190
jmp 0x2dc5
movq 0x7904(%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 0x29cb
movl $0xc, -0x58(%rbp)
movq 0x7688(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rax
movl 0x101c(%rax), %eax
movl %eax, -0x94(%rbp)
movl -0x58(%rbp), %edi
callq 0x1250
movq -0xa8(%rbp), %rdi
movq -0xa0(%rbp), %rdx
movl -0x94(%rbp), %ecx
movq %rax, %r8
leaq 0x4b3b(%rip), %rsi      # 0x74fa
movb $0x0, %al
callq 0x1190
jmp 0x2dc5
movq 0x7876(%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 0x2a59
movl $0xc, -0x58(%rbp)
movq 0x75fa(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rax
movl 0x101c(%rax), %eax
movl %eax, -0xac(%rbp)
movl -0x58(%rbp), %edi
callq 0x1250
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rdx
movl -0xac(%rbp), %ecx
movq %rax, %r8
leaq 0x4aad(%rip), %rsi      # 0x74fa
movb $0x0, %al
callq 0x1190
jmp 0x2dc5
movq -0x10(%rbp), %rax
movl 0x1014(%rax), %esi
leaq -0x18(%rbp), %rdi
callq 0x5df0
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x2ac1
movq 0x757c(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xc8(%rbp)
movl -0x58(%rbp), %edi
callq 0x1250
movq -0xd0(%rbp), %rdi
movq -0xc8(%rbp), %rdx
movq %rax, %rcx
leaq 0x4929(%rip), %rsi      # 0x73de
movb $0x0, %al
callq 0x1190
jmp 0x2dc5
jmp 0x2ac3
movl $0x4, -0x50(%rbp)
movl -0x4(%rbp), %edi
leaq -0x48(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x2ee0
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x2b2f
movq 0x750e(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0xe0(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xd8(%rbp)
movl -0x58(%rbp), %edi
callq 0x1250
movq -0xe0(%rbp), %rdi
movq -0xd8(%rbp), %rdx
movq %rax, %rcx
leaq 0x48ff(%rip), %rsi      # 0x7422
movb $0x0, %al
callq 0x1190
jmp 0x2dc5
cmpl $0x0, -0x50(%rbp)
jne 0x2b3a
jmp 0x2dbe
movl -0x50(%rbp), %eax
cmpq $0x4, %rax
je 0x2b6f
movl $0x5, -0x58(%rbp)
movq 0x74a7(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x492d(%rip), %rsi      # 0x7490
movb $0x0, %al
callq 0x1190
jmp 0x2dc5
movl -0x50(%rbp), %eax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x54(%rbp)
movq -0x10(%rbp), %rax
movl 0x101c(%rax), %eax
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
jae 0x2bc5
movl -0x48(%rbp), %eax
movabsq $0x80000000, %rcx       # imm = 0x80000000
andq %rcx, %rax
cmpq $0x0, %rax
je 0x2bc5
movl $0x1, -0x54(%rbp)
movl -0x48(%rbp), %eax
movabsq $-0x80000001, %rcx      # imm = 0xFFFFFFFF7FFFFFFF
andq %rcx, %rax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x101c(%rcx), %eax
jbe 0x2c00
movl $0x16, -0x58(%rbp)
movq 0x7416(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x48e9(%rip), %rsi      # 0x74dd
movb $0x0, %al
callq 0x1190
jmp 0x2dc5
movl -0x48(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x4(%rbp), %edi
movq -0x20(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x2ee0
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x2c6b
movq 0x73d2(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0xf0(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xe8(%rbp)
movl -0x58(%rbp), %edi
callq 0x1250
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rdx
movq %rax, %rcx
leaq 0x47c3(%rip), %rsi      # 0x7422
movb $0x0, %al
callq 0x1190
jmp 0x2dc5
movl -0x50(%rbp), %eax
cmpl -0x48(%rbp), %eax
je 0x2c9f
movl $0x5, -0x58(%rbp)
movq 0x7377(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x47fd(%rip), %rsi      # 0x7490
movb $0x0, %al
callq 0x1190
jmp 0x2dc5
movq -0x10(%rbp), %rax
movl 0x101c(%rax), %eax
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x54(%rbp)
jne 0x2d29
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x48(%rbp), %edx
movq -0x28(%rbp), %rcx
leaq -0x44(%rbp), %r8
callq 0x5e20
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x2d1f
movq 0x731e(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0x100(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xf8(%rbp)
movl -0x58(%rbp), %edi
callq 0x1250
movq -0x100(%rbp), %rdi
movq -0xf8(%rbp), %rdx
movq %rax, %rcx
leaq 0x481a(%rip), %rsi      # 0x752d
movb $0x0, %al
callq 0x1190
jmp 0x2dc5
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x2d31
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1038(%rax)
jne 0x2da3
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 0x2da1
movq 0x7299(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0x110(%rbp)
movq -0x10(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x108(%rbp)
movl -0x58(%rbp), %edi
callq 0x1250
movq -0x110(%rbp), %rdi
movq -0x108(%rbp), %rdx
movq %rax, %rcx
leaq 0x4667(%rip), %rsi      # 0x73ff
movb $0x0, %al
callq 0x1190
jmp 0x2dc5
jmp 0x2da3
movl -0x48(%rbp), %eax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x44(%rbp), %eax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x2ac3
movl $0x0, -0x58(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5e10
cmpq $0x0, -0x20(%rbp)
je 0x2dde
movq -0x20(%rbp), %rdi
callq 0x1030
cmpq $0x0, -0x28(%rbp)
je 0x2dee
movq -0x28(%rbp), %rdi
callq 0x1030
movq -0x10(%rbp), %rax
cmpl $0x1, 0x1034(%rax)
jne 0x2e4f
cmpl $0x0, -0x58(%rbp)
jne 0x2e4f
cmpl $0x1, -0x8(%rbp)
je 0x2e4f
cvtsi2ssq -0x40(%rbp), %xmm0
cvtsi2ssq -0x38(%rbp), %xmm1
divss %xmm1, %xmm0
movss 0x4309(%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 0x4709(%rip), %rdi      # 0x7551
movb $0x1, %al
callq 0x10e0
movl -0x58(%rbp), %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopl (%rax,%rax)