// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/sis.c
// Function: do_extract_file
static void do_extract_file(deark *c, lctx *d, struct file_rec *fr,
	i64 fork_num)
{
	de_finfo *fi = NULL;
	de_ucstring *fn = NULL;
	dbuf *outf = NULL;

	if(fr->ffi[fork_num].ptr<0 ||
		fr->ffi[fork_num].ptr + fr->ffi[fork_num].len > c->infile->len)
	{
		goto done;
	}

	fi = de_finfo_create(c);

	fn = ucstring_create(c);

	if(fr->rectype==0x1 && fork_num<d->nlangs && d->langi &&
		d->langi[fork_num].sz[0])
	{
		// Prepend a code for the language
		ucstring_append_sz(fn, d->langi[fork_num].sz, DE_ENCODING_LATIN1);
		ucstring_append_sz(fn, ".", DE_ENCODING_LATIN1);
	}
	ucstring_append_ucstring(fn, fr->name_to_use);
	de_finfo_set_name_from_ucstring(c, fi, fn, 0);

	outf = dbuf_create_output_file(c, NULL, fi, 0);
	if(d->files_are_compressed) {
		if(!fmtutil_decompress_deflate(c->infile, fr->ffi[fork_num].ptr, fr->ffi[fork_num].len,
			outf, fr->ffi[fork_num].orig_len, NULL,
			DE_DEFLATEFLAG_ISZLIB|DE_DEFLATEFLAG_USEMAXUNCMPRSIZE))
		{
			goto done;
		}
		if(outf->len != fr->ffi[fork_num].orig_len) {
			de_warn(c, "expected %"I64_FMT" bytes, got %"I64_FMT,
				fr->ffi[fork_num].orig_len, outf->len);
		}
	}
	else {
		dbuf_copy(c->infile, fr->ffi[fork_num].ptr, fr->ffi[fork_num].len, outf);
	}

done:
	dbuf_close(outf);
	de_finfo_destroy(c, fi);
	ucstring_destroy(fn);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
imulq $0x18, -0x20(%rbp), %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
jl 0x14402b
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
imulq $0x18, -0x20(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x20(%rcx), %rcx
imulq $0x18, -0x20(%rbp), %rdx
addq %rdx, %rcx
addq 0x8(%rcx), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jle 0x144030
jmp 0x1441eb
movq -0x8(%rbp), %rdi
callq 0x15d230
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x1, 0x10(%rax)
jne 0x1440b8
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jge 0x1440b8
movq -0x10(%rbp), %rax
cmpq $0x0, 0x60(%rax)
je 0x1440b8
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq -0x20(%rbp), %rcx
movsbl (%rax,%rcx,4), %eax
cmpl $0x0, %eax
je 0x1440b8
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rsi
movq -0x20(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rsi
movl $0x5, %edx
callq 0x1715e0
movq -0x30(%rbp), %rdi
leaq 0x830f5(%rip), %rsi     # 0x1c71a3
movl $0x5, %edx
callq 0x1715e0
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0x171460
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
xorl %ecx, %ecx
callq 0x15d2c0
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
xorl %ecx, %ecx
callq 0x166c60
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpb $0x0, 0xd(%rax)
je 0x1441b1
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
imulq $0x18, -0x20(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
imulq $0x18, -0x20(%rbp), %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdx
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
imulq $0x18, -0x20(%rbp), %r8
addq %r8, %rax
movq 0x10(%rax), %r8
xorl %eax, %eax
movl %eax, %r9d
movl $0x3, (%rsp)
callq 0x17f4f0
cmpl $0x0, %eax
jne 0x144163
jmp 0x1441eb
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x20(%rcx), %rcx
imulq $0x18, -0x20(%rbp), %rdx
addq %rdx, %rcx
cmpq 0x10(%rcx), %rax
je 0x1441af
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
imulq $0x18, -0x20(%rbp), %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdx
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rcx
leaq 0x67313(%rip), %rsi     # 0x1ab4bb
movb $0x0, %al
callq 0x15bc10
jmp 0x1441e9
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
imulq $0x18, -0x20(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
imulq $0x18, -0x20(%rbp), %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdx
movq -0x38(%rbp), %rcx
callq 0x166070
jmp 0x1441eb
movq -0x38(%rbp), %rdi
callq 0x1676a0
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x15d260
movq -0x30(%rbp), %rdi
callq 0x171750
addq $0x40, %rsp
popq %rbp
retq