// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/dms.c
// Function: dms_decompress_track
static int dms_decompress_track(deark *c, struct dmsctx *d, struct dms_track_info *tri,
	dbuf *outf)
{
	int retval = 0;
	i64 unc_nbytes;
	struct de_dfilter_in_params dcmpri;
	struct de_dfilter_out_params dcmpro;
	struct de_dfilter_results dres;

	if(outf->len!=0) goto done;

	if(tri->dpos + tri->cmpr_len > c->infile->len) {
		de_err(c, "Track goes beyond end of file");
		goto done;
	}

	de_dfilter_init_objects(c, &dcmpri, &dcmpro, &dres);
	dcmpri.f = c->infile;
	dcmpri.pos = tri->dpos;
	dcmpri.len = tri->cmpr_len;
	dcmpro.f = outf;
	dcmpro.len_known = 1;
	dcmpro.expected_len = tri->uncmpr_len;

	tri->cksum_calc = 0;

	if(tri->cmpr_type==DMSCMPR_NONE) {
		fmtutil_decompress_uncompressed(c, &dcmpri, &dcmpro, &dres, 0);
	}
	else if(tri->cmpr_type==DMSCMPR_RLE) {
		de_dfilter_decompress_oneshot(c, dmsrle_codec, NULL,
			&dcmpri, &dcmpro, &dres);
	}
	else if(tri->cmpr_type==DMSCMPR_QUICK || tri->cmpr_type==DMSCMPR_MEDIUM ||
		tri->cmpr_type==DMSCMPR_DEEP)
	{
		do_decompress_track_q_m_d(c, d, tri, &dcmpri, &dcmpro, &dres);
	}
	else if(tri->cmpr_type==DMSCMPR_HEAVY1 || tri->cmpr_type==DMSCMPR_HEAVY2) {
		do_decompress_heavy(c, d, tri, &dcmpri, &dcmpro, &dres);
	}
	else {
		de_err(c, "[%s] Unsupported compression method: %u (%s)",
			tri->shortname, tri->cmpr_type,
			dms_get_cmprtype_name(tri->cmpr_type));
		goto done;
	}
	dbuf_flush(dcmpro.f);

	if(dres.errcode) {
		de_err(c, "[%s] Decompression failed: %s", tri->shortname,
			de_dfilter_get_errmsg(c, &dres));
		goto done;
	}

	unc_nbytes = outf->len;

	dbuf_truncate(outf, tri->uncmpr_len);

	if(unc_nbytes < tri->uncmpr_len) {
		de_err(c, "[%s] Expected %"I64_FMT" decompressed bytes, got %"I64_FMT,
			tri->shortname, tri->uncmpr_len, unc_nbytes);
		goto done;
	}
	if(unc_nbytes > tri->uncmpr_len) {
		de_warn(c, "[%s] Expected %"I64_FMT" decompressed bytes, got %"I64_FMT,
			tri->shortname, tri->uncmpr_len, unc_nbytes);
	}

	retval = 1;

done:
	if(tri->is_real && !(tri->track_flags & 0x1)) {
		destroy_saved_dcrmpr_state(c, d);
	}
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x65c12
jmp 0x65ecc
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
addq 0x10(%rcx), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jle 0x65c47
movq -0x8(%rbp), %rdi
leaq 0x144026(%rip), %rsi    # 0x1a9c61
movb $0x0, %al
callq 0x15bfb0
jmp 0x65ecc
movq -0x8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x68(%rbp), %rdx
leaq -0xc8(%rbp), %rcx
callq 0x1773f0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
movb $0x1, -0x60(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movl $0x0, 0x40(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x2c(%rax)
jne 0x65cd0
movq -0x8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x68(%rbp), %rdx
leaq -0xc8(%rbp), %rcx
xorl %r8d, %r8d
callq 0x1778b0
jmp 0x65dde
movq -0x18(%rbp), %rax
cmpl $0x1, 0x2c(%rax)
jne 0x65d02
movq -0x8(%rbp), %rdi
leaq 0x29b(%rip), %rsi       # 0x65f80
xorl %eax, %eax
movl %eax, %edx
leaq -0x50(%rbp), %rcx
leaq -0x68(%rbp), %r8
leaq -0xc8(%rbp), %r9
callq 0x177820
jmp 0x65ddc
movq -0x18(%rbp), %rax
cmpl $0x2, 0x2c(%rax)
je 0x65d20
movq -0x18(%rbp), %rax
cmpl $0x3, 0x2c(%rax)
je 0x65d20
movq -0x18(%rbp), %rax
cmpl $0x4, 0x2c(%rax)
jne 0x65d45
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x50(%rbp), %rcx
leaq -0x68(%rbp), %r8
leaq -0xc8(%rbp), %r9
callq 0x66000
jmp 0x65dda
movq -0x18(%rbp), %rax
cmpl $0x5, 0x2c(%rax)
je 0x65d59
movq -0x18(%rbp), %rax
cmpl $0x6, 0x2c(%rax)
jne 0x65d7b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x50(%rbp), %rcx
leaq -0x68(%rbp), %r8
leaq -0xc8(%rbp), %r9
callq 0x66390
jmp 0x65dd8
movq -0x8(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x18(%rbp), %rax
addq $0x44, %rax
movq %rax, -0xd8(%rbp)
movq -0x18(%rbp), %rax
movl 0x2c(%rax), %eax
movl %eax, -0xcc(%rbp)
movq -0x18(%rbp), %rax
movl 0x2c(%rax), %edi
callq 0x65590
movq -0xe0(%rbp), %rdi
movq -0xd8(%rbp), %rdx
movl -0xcc(%rbp), %ecx
movq %rax, %r8
leaq 0x143eb3(%rip), %rsi    # 0x1a9c7f
movb $0x0, %al
callq 0x15bfb0
jmp 0x65ecc
jmp 0x65dda
jmp 0x65ddc
jmp 0x65dde
movq -0x68(%rbp), %rdi
callq 0x167c30
cmpl $0x0, -0xc8(%rbp)
je 0x65e3e
movq -0x8(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x18(%rbp), %rax
addq $0x44, %rax
movq %rax, -0xe8(%rbp)
movq -0x8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x177360
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rdx
movq %rax, %rcx
leaq 0x143e7a(%rip), %rsi    # 0x1a9cac
movb $0x0, %al
callq 0x15bfb0
jmp 0x65ecc
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x168900
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jge 0x65e91
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
addq $0x44, %rdx
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x30(%rbp), %r8
leaq 0x143e42(%rip), %rsi    # 0x1a9cca
movb $0x0, %al
callq 0x15bfb0
jmp 0x65ecc
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jle 0x65ec5
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
addq $0x44, %rdx
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x30(%rbp), %r8
leaq 0x143e0c(%rip), %rsi    # 0x1a9cca
movb $0x0, %al
callq 0x15bc10
movl $0x1, -0x24(%rbp)
movq -0x18(%rbp), %rax
movzbl 0x30(%rax), %eax
cmpl $0x0, %eax
je 0x65ef5
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x65ef5
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x65430
movl -0x24(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)