// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/src/fmtutil-lzh.c
// Function: lzh_do_deflate_block_type1_2
static int lzh_do_deflate_block_type1_2(deark *c, struct lzh_ctx *cctx, UI blktype)
{
	int retval = 0;

	if(blktype==1) {
		if(!deflate_block_type1_make_fixed_trees(c, cctx)) goto done;
	}
	else {
		if(!deflate_block_type2_read_trees(c, cctx)) goto done;
	}

	while(1) {
		UI code;

		if(cctx->bitrd.eof_flag || cctx->err_flag) break;

		code = read_next_code_using_tree(cctx, &cctx->literals_tree);
		if(code<=255) {
			if(cctx->c->debug_level>=4) {
				de_dbg(c, "%u lit", code);
			}
			de_lz77buffer_add_literal_byte(cctx->ringbuf, (u8)code);
		}
		else if(code>=257 && code<=285) { // beginning of a match
			UI length = deflate_decode_length(c, cctx, code);
			UI dist = deflate_read_and_decode_distance(c, cctx);
			if(cctx->c->debug_level>=4) {
				de_dbg(c, "%u match d=%u l=%u", code, dist+1, length);
			}
			de_lz77buffer_copy_from_hist(cctx->ringbuf,
				(UI)(cctx->ringbuf->curpos-1-dist), length);
		}
		else if(code==256) { // end of block
			if(cctx->c->debug_level>=4) {
				de_dbg(c, "%u stop", code);
			}
			retval = 1;
			goto done;
		}
		else {
			de_dbg(c, "unsupported code %u", code);
			cctx->err_flag = 1;
			goto done;
		}
	}

done:
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
cmpl $0x1, -0x14(%rbp)
jne 0x182969
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x182ba0
cmpl $0x0, %eax
jne 0x182967
jmp 0x182ada
jmp 0x182982
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x182d30
cmpl $0x0, %eax
jne 0x182980
jmp 0x182ada
jmp 0x182982
jmp 0x182984
movq -0x10(%rbp), %rax
movzbl 0x50(%rax), %eax
cmpl $0x0, %eax
jne 0x18299b
movq -0x10(%rbp), %rax
cmpl $0x0, 0x30(%rax)
je 0x1829a0
jmp 0x182ad8
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x98, %rsi
callq 0x181ae0
movl %eax, -0x1c(%rbp)
cmpl $0xff, -0x1c(%rbp)
ja 0x1829f9
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpl $0x4, (%rax)
jl 0x1829e1
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %edx
leaq 0x5464c(%rip), %rsi     # 0x1d7026
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rdi
movl -0x1c(%rbp), %eax
movzbl %al, %esi
callq 0x178880
jmp 0x182ad3
cmpl $0x101, -0x1c(%rbp)     # imm = 0x101
jb 0x182a7c
cmpl $0x11d, -0x1c(%rbp)     # imm = 0x11D
ja 0x182a7c
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0x183350
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x183460
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpl $0x4, (%rax)
jl 0x182a59
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %edx
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
movl -0x20(%rbp), %r8d
leaq 0x545db(%rip), %rsi     # 0x1d702d
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movl 0x10(%rax), %esi
subl $0x1, %esi
subl -0x24(%rbp), %esi
movl -0x20(%rbp), %edx
callq 0x1788e0
jmp 0x182ad1
cmpl $0x100, -0x1c(%rbp)     # imm = 0x100
jne 0x182aaf
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpl $0x4, (%rax)
jl 0x182aa6
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %edx
leaq 0x545a1(%rip), %rsi     # 0x1d7040
movb $0x0, %al
callq 0x15b0d0
movl $0x1, -0x18(%rbp)
jmp 0x182ada
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %edx
leaq 0x5458b(%rip), %rsi     # 0x1d7048
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
movl $0x1, 0x30(%rax)
jmp 0x182ada
jmp 0x182ad3
jmp 0x182984
jmp 0x182ada
movl -0x18(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)