// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/zoo.c
// Function: de_run_zoo
static void de_run_zoo(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	i64 pos = 0;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);
	d = de_malloc(c, sizeof(lctx));
	d->da = de_arch_create_lctx(c);
	d->da->userdata = (void*)d;
	d->da->is_le = 1;

	d->da->input_encoding = de_get_input_encoding(c, NULL, DE_ENCODING_ASCII);
	d->undelete = de_get_ext_option_bool(c, "zoo:undelete", 0);
	d->extract_comments_to_files = (c->extract_level>=2);

	d->da->crco = de_crcobj_create(c, DE_CRCOBJ_CRC16_ARC);
	d->min_offset_found = c->infile->len;

	if(!do_global_header(c, d, pos)) {
		de_err(c, "Bad global header");
		goto done;
	}

	d->offsets_seen = de_inthashtable_create(c); // For protection against infinite loops
	pos = d->first_member_hdr_pos;
	while ( 1 ) {
		i64 next_member_hdr_pos;

		de_dbg_indent_restore(c, saved_indent_level);

		if(pos==0) break;

		if(pos >= c->infile->len) {
			de_err(c, "Unexpected EOF, expected member header at %"I64_FMT, pos);
			goto after_members;
		}

		if(!de_inthashtable_add_item(c, d->offsets_seen, pos, NULL)) {
			de_err(c, "Loop detected");
			goto after_members;
		}

		de_dbg(c, "entry at %"I64_FMT, pos);
		de_dbg_indent(c, 1);

		next_member_hdr_pos = 0;
		do_member(c, d, pos, &next_member_hdr_pos);
		pos = next_member_hdr_pos;
	}

after_members:
	check_for_orphaned_comment(c, d);

	if(d->num_deleted_files_found>0 && !d->undelete) {
		de_info(c, "Note: %d deleted file(s) found. Use \"-opt zoo:undelete\" "
			"to extract them.", d->num_deleted_files_found);
	}

done:
	if(d) {
		de_inthashtable_destroy(c, d->offsets_seen);
		de_arch_destroy_lctx(c, d->da);
		de_free(c, d);
	}
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
movl $0x48, %esi
callq 0x15b780
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x17c220
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x40(%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl $0x1, 0x10(%rax)
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x1, %edx
callq 0x15e4a0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl %ecx, 0x18(%rax)
movq -0x8(%rbp), %rdi
leaq 0x82562(%rip), %rsi     # 0x1d065a
xorl %edx, %edx
callq 0x15cbc0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x8(%rbp), %rax
cmpl $0x2, 0x90(%rax)
setge %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rdi
movl $0x21, %esi
callq 0x15eac0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x30(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x14eb70
cmpl $0x0, %eax
jne 0x14e17f
movq -0x8(%rbp), %rdi
leaq 0x824f4(%rip), %rsi     # 0x1d0667
movb $0x0, %al
callq 0x15bfb0
jmp 0x14e2a2
movq -0x8(%rbp), %rdi
callq 0x15e600
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x15b5a0
cmpq $0x0, -0x20(%rbp)
jne 0x14e1b7
jmp 0x14e264
movq -0x20(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jl 0x14e1e4
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq 0x824a1(%rip), %rsi     # 0x1d0679
movb $0x0, %al
callq 0x15bfb0
jmp 0x14e266
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x20(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x15e810
cmpl $0x0, %eax
jne 0x14e216
movq -0x8(%rbp), %rdi
leaq 0x7fecf(%rip), %rsi     # 0x1ce0dc
movb $0x0, %al
callq 0x15bfb0
jmp 0x14e266
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq 0x504d8(%rip), %rsi     # 0x19e6fd
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq $0x0, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq -0x30(%rbp), %rcx
callq 0x14eed0
movq -0x30(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x14e19f
jmp 0x14e266
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x14f150
movq -0x18(%rbp), %rax
cmpl $0x0, 0x3c(%rax)
jle 0x14e2a0
movq -0x18(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x14e2a0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x3c(%rax), %edx
leaq 0x8240e(%rip), %rsi     # 0x1d06a7
movb $0x0, %al
callq 0x15c0c0
jmp 0x14e2a2
cmpq $0x0, -0x18(%rbp)
je 0x14e2d7
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x15e630
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
callq 0x17c270
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x15b820
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x15b5a0
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)