// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/nufx.c
// Function: extract_from_record
static void extract_from_record(deark *c,
	struct nufx_ctx *d, struct nufx_record *rec)
{
	dbuf *filename_dbuf = NULL;
	UI tidx;
	int ret;

	if(rec->filename_thread_ptr) {
		filename_dbuf = dbuf_create_membuf(c, 0, 0);
		ret = decompress_thread(c, d, rec, rec->filename_thread_ptr,
			filename_dbuf);
		if(!ret || filename_dbuf->len<1) {
			goto done;
		}
		nufx_filename_to_ucstring(c, d, rec, filename_dbuf, 0, filename_dbuf->len,
			rec->filename);
		de_dbg(c, "filename: \"%s\"", ucstring_getpsz_d(rec->filename));
	}
	if(ucstring_isempty(rec->filename) && ucstring_isnonempty(rec->filename_old)) {
		ucstring_append_ucstring(rec->filename, rec->filename_old);
	}

	fixup_filename(c, rec);

	de_dbg(c, "[extracting files]");
	de_dbg_indent(c, 1);

	// A record shouldn't contain both a disk image, and a file, but for lack
	// of something better to do, we tolerate it.

	if(rec->disk_image_thread_ptr) {
		extract_main_threads(c, d, rec, 1);
	}

	if(rec->data_thread_ptr || rec->resource_thread_ptr) {
		extract_main_threads(c, d, rec, 0);
	}

	if(!rec->data_thread_ptr && !rec->resource_thread_ptr && !rec->disk_image_thread_ptr) {
		de_warn(c, "record #%u: No supported content found", rec->idx);
	}

	// Handle ancillary threads, such as comments.
	for(tidx=0; tidx<rec->num_threads; tidx++) {
		struct nufx_thread *t;

		t = &rec->threads[tidx];
		if(t->orig_len>0 && t->thread_class==0 && t->kind==1) {
			if(d->extract_comments) {
				do_extract_aux_thread(c, d, rec, t, "comment");
			}
			else {
				do_dbg_comment(c, d, rec, t);
			}
		}
	}

	de_dbg_indent(c, -1);

done:
	dbuf_close(filename_dbuf);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0xa8(%rax)
je 0xd6cc6
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x168020
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x18(%rbp), %rax
movq 0xa8(%rax), %rcx
movq -0x20(%rbp), %r8
callq 0xd75a0
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0xd6c65
movq -0x20(%rbp), %rax
cmpq $0x1, 0x18(%rax)
jge 0xd6c6a
jmp 0xd6e7a
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x20(%rbp), %rax
movq 0x18(%rax), %r9
movq -0x18(%rbp), %rax
movq 0x98(%rax), %rax
xorl %r8d, %r8d
movq %rax, (%rsp)
callq 0xd6e90
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x98(%rax), %rdi
callq 0x172650
movq -0x38(%rbp), %rdi
movq %rax, %rdx
leaq 0xf08c4(%rip), %rsi     # 0x1c7583
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rax
movq 0x98(%rax), %rdi
callq 0x1717b0
cmpl $0x0, %eax
je 0xd6d0b
movq -0x18(%rbp), %rax
movq 0x90(%rax), %rdi
callq 0x1717f0
cmpl $0x0, %eax
je 0xd6d0b
movq -0x18(%rbp), %rax
movq 0x98(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x90(%rax), %rsi
callq 0x171460
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xd77a0
movq -0x8(%rbp), %rdi
leaq 0xe44d0(%rip), %rsi     # 0x1bb1f3
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x18(%rbp), %rax
cmpq $0x0, 0xc0(%rax)
je 0xd6d5c
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl $0x1, %ecx
callq 0xd7860
movq -0x18(%rbp), %rax
cmpq $0x0, 0xb0(%rax)
jne 0xd6d78
movq -0x18(%rbp), %rax
cmpq $0x0, 0xb8(%rax)
je 0xd6d8b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
xorl %ecx, %ecx
callq 0xd7860
movq -0x18(%rbp), %rax
cmpq $0x0, 0xb0(%rax)
jne 0xd6dce
movq -0x18(%rbp), %rax
cmpq $0x0, 0xb8(%rax)
jne 0xd6dce
movq -0x18(%rbp), %rax
cmpq $0x0, 0xc0(%rax)
jne 0xd6dce
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edx
leaq 0xe443f(%rip), %rsi     # 0x1bb206
movb $0x0, %al
callq 0x15bc10
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x2c(%rcx), %eax
jae 0xd6e6c
movq -0x18(%rbp), %rax
movq 0xa0(%rax), %rax
movl -0x24(%rbp), %ecx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jle 0xd6e5c
movq -0x30(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0xd6e5c
movq -0x30(%rbp), %rax
cmpl $0x1, 0xc(%rax)
jne 0xd6e5c
movq -0x10(%rbp), %rax
cmpb $0x0, 0x2(%rax)
je 0xd6e45
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x30(%rbp), %rcx
leaq 0xf9507(%rip), %r8      # 0x1d0345
callq 0xd7ba0
jmp 0xd6e5a
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0xd7c50
jmp 0xd6e5c
jmp 0xd6e5e
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xd6dd5
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x20(%rbp), %rdi
callq 0x1676a0
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)