// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/mac-arch.c
// Function: de_run_tome
static void de_run_tome(deark *c, de_module_params *mparams)
{
	struct tome_ctx *d = NULL;
	struct tome_md *md = NULL;
	i64 pos;
	i64 i;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);
	d = de_malloc(c, sizeof(struct tome_ctx));
	d->input_encoding = de_get_input_encoding(c, NULL, DE_ENCODING_MACROMAN);

	pos = 0;
	de_dbg(c, "archive header at %"I64_FMT, pos);
	de_dbg_indent(c, 1);
	pos += 4;
	pos += 24;
	d->num_members = de_getu32be_p(&pos);
	de_dbg(c, "number of members: %"I64_FMT, d->num_members);
	pos += 4;
	de_dbg_indent(c, -1);

	for(i=0; i<d->num_members; i++) {
		if(md) {
			destroy_tome_md(c, md);
		}
		md = de_malloc(c, sizeof(struct tome_md));
		md->c = c;
		md->d = d;
		md->frk[0].md = md;
		md->frk[1].md = md;
		md->frk[0].forknum = 0;
		md->frk[1].forknum = 1;
		de_strlcpy(md->frk[0].forkname, "data", sizeof(md->frk[0].forkname));
		de_strlcpy(md->frk[1].forkname, "rsrc", sizeof(md->frk[1].forkname));
		md->advf = de_advfile_create(c);
		md->advf->enable_wbuffer = 1;
		md->member_idx = i;
		md->hdr_pos = pos;
		tome_do_member(c, d, md);
		if(d->fatalerrflag) goto done;
		pos += 128;
	}

done:
	destroy_tome_md(c, md);
	if(d) {
		if(d->need_errmsg) {
			de_err(c, "Failed to decode Tome file");
		}
		de_free(c, d);
	}
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
leaq 0x8(%rsp), %rsi
callq 0xe958c
movl $0x10, %esi
movq %rbx, %rdi
callq 0xe969b
movq %rax, %r15
movq %rbx, %rdi
xorl %esi, %esi
movl $0x11, %edx
callq 0xeb7d1
movl %eax, (%r15)
leaq 0x18(%rsp), %r14
movq $0x0, (%r14)
leaq 0x87ced(%rip), %rsi     # 0x122e25
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
addq $0x1c, (%r14)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef34e
movq %rax, 0x8(%r15)
leaq 0x794f0(%rip), %rsi     # 0x11465c
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
addq $0x4, (%r14)
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
cmpq $0x0, 0x8(%r15)
movl $0x0, %ebp
jle 0x9b6e9
xorl %r14d, %r14d
xorl %ebp, %ebp
movq %r15, 0x10(%rsp)
testq %rbp, %rbp
je 0x9b1b4
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x9b74f
movl $0x130, %esi            # imm = 0x130
movq %rbx, %rdi
callq 0xe969b
movq %rax, %rbp
movq %rbx, (%rax)
movq %r15, 0x8(%rax)
movq %rax, 0xc0(%rax)
movq %rax, 0xf8(%rax)
movl $0x0, 0xc8(%rax)
movl $0x1, 0x100(%rax)
leaq 0xf0(%rax), %r12
movl $0x8, %edx
movq %r12, %rdi
leaq 0x9ed9e(%rip), %rsi     # 0x139fa1
callq 0xe8ded
leaq 0x128(%rbp), %rdi
movl $0x8, %edx
leaq 0x81e95(%rip), %rsi     # 0x11d0b0
callq 0xe8ded
movq %rbx, %rdi
callq 0xfca54
movq %rax, 0x30(%rbp)
movb $0x1, 0x78(%rax)
movq %r14, 0x30(%rsp)
movq %r14, 0x10(%rbp)
movq 0x18(%rsp), %rax
movq %rax, 0x18(%rbp)
movq %rax, (%rsp)
movq %rbx, %rdi
leaq 0xc(%rsp), %rsi
callq 0xe958c
movq 0x18(%rbp), %rdx
movq %rbx, %rdi
leaq 0xa9431(%rip), %rsi     # 0x144692
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rdi
movq %rsp, %r14
movq %r14, %rsi
callq 0xef193
movq %rbx, %rdi
leaq 0x95ece(%rip), %rsi     # 0x13115c
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef34e
movq %rax, %r13
movq %rbx, %rdi
leaq 0x95eb8(%rip), %rsi     # 0x131168
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x10(%rbp), %rax
incq %rax
cmpq %rax, %r13
jne 0x9b6b2
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef14d
cmpb $0x1f, %al
ja 0x9b6b9
leaq 0xc0(%rbp), %rcx
movq %rcx, 0x28(%rsp)
leaq 0xf8(%rbp), %rcx
movq %rcx, 0x20(%rsp)
movzbl %al, %ecx
movq 0x18(%rbx), %rdi
movq (%rsp), %rsi
movq 0x10(%rsp), %rax
movl (%rax), %r9d
movq %rcx, %rdx
xorl %r8d, %r8d
callq 0xefe67
movq %rax, 0x38(%rbp)
addq $0x1f, (%rsp)
movq 0x18(%rax), %rdi
callq 0xf7557
movq %rbx, %rdi
leaq 0xa06a4(%rip), %rsi     # 0x13b9d4
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq (%rsp), %rsi
leaq 0x40(%rbp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0xf1d74
leaq 0x50(%rbp), %rdx
movq %rbx, %rdi
leaq 0x794ff(%rip), %rsi     # 0x114860
xorl %eax, %eax
callq 0xe9226
movq 0x30(%rbp), %rax
movl 0x40(%rbp), %ecx
movl %ecx, 0x90(%rax)
movq 0x30(%rbp), %rax
movb $0x1, %r14b
movb %r14b, 0x7b(%rax)
movq (%rsp), %rsi
addq $0x4, %rsi
movq %rsi, (%rsp)
movq 0x18(%rbx), %rdi
leaq 0x70(%rbp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0xf1d74
movq %rbp, %rdx
subq $-0x80, %rdx
movq %rbx, %rdi
leaq 0x98b41(%rip), %rsi     # 0x133ef3
xorl %eax, %eax
callq 0xe9226
movq 0x30(%rbp), %rax
movl 0x70(%rbp), %ecx
movl %ecx, 0x94(%rax)
movq 0x30(%rbp), %rax
movb %r14b, 0x7c(%rax)
movq (%rsp), %rdx
addq $0x4, %rdx
movq %rdx, (%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
movl $0x1, %ecx
leaq 0x7cdfa(%rip), %r8      # 0x1181e6
callq 0x9b786
movq (%rsp), %rdx
addq $0x4, %rdx
movq %rdx, (%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
xorl %ecx, %ecx
leaq 0x95d6a(%rip), %r8      # 0x131176
callq 0x9b786
addq $0x8, (%rsp)
movq 0x18(%rbx), %rdi
movq %rsp, %r15
movq %r15, %rsi
callq 0xef193
movl %eax, 0x28(%rbp)
movq %rbx, %rdi
leaq 0x7943d(%rip), %rsi     # 0x11486f
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movzwl 0x28(%rbp), %eax
movq 0x30(%rbp), %rcx
movw %ax, 0x7e(%rcx)
movb %r14b, 0x7d(%rcx)
movl $0x1, %r14d
leaq 0x95d5e(%rip), %r13     # 0x1311b6
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef34e
movq %rax, -0x18(%r12)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef34e
movq %rax, -0x10(%r12)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef34e
movq %rax, -0x8(%r12)
movq -0x18(%r12), %rcx
movq %rbx, %rdi
leaq 0x95ce3(%rip), %rsi     # 0x13117d
movq %r12, %rdx
xorl %eax, %eax
callq 0xe9226
movq -0x10(%r12), %rcx
movq %rbx, %rdi
leaq 0x95cdd(%rip), %rsi     # 0x131190
movq %r12, %rdx
xorl %eax, %eax
callq 0xe9226
movq -0x8(%r12), %rcx
movq %rbx, %rdi
leaq 0x95cd7(%rip), %rsi     # 0x1311a3
movq %r12, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef34e
movl %eax, -0x20(%r12)
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe9226
addq $0x38, %r12
decq %r14
je 0x9b458
movq 0x30(%rbp), %rax
movq 0xd8(%rbp), %rcx
movq %rcx, 0x18(%rax)
movq 0x110(%rbp), %rdx
movq %rdx, 0x40(%rax)
testq %rcx, %rcx
setne %cl
testq %rdx, %rdx
sete %dl
setne 0x38(%rax)
orb %cl, %dl
movb %dl, 0x10(%rax)
leaq 0x2de(%rip), %rcx       # 0x9b81a
movq %rcx, 0x30(%rax)
movq 0x28(%rsp), %r13
movq %r13, 0x28(%rax)
movq %rcx, 0x58(%rax)
movq 0x20(%rsp), %rcx
movq %rcx, 0x50(%rax)
xorl %eax, %eax
movl %eax, 0xd4(%rbp)
movl %eax, 0x10c(%rbp)
movl $0xcc, %r14d
movq 0xc(%rbp,%r14), %rdi
testq %rdi, %rdi
je 0x9b5a2
movl $0x10000, %esi          # imm = 0x10000
callq 0xea80b
leaq 0x3fff(%rax), %rcx
testq %rax, %rax
cmovnsq %rax, %rcx
sarq $0xe, %rcx
addq 0xc(%rbp,%r14), %rcx
cmpq %rcx, 0x1c(%rbp,%r14)
je 0x9b5a2
movb $0x1, (%rbp,%r14)
addq $0x38, %r14
cmpq $0x104, %r14            # imm = 0x104
je 0x9b56a
movq 0x30(%rbp), %rax
movq %rbp, 0x8(%rax)
leaq 0x28e(%rip), %rcx       # 0x9b84c
movq %rcx, 0x60(%rax)
movq 0x68(%rax), %rdi
movq 0x38(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0xf6969
movq 0x30(%rbp), %rdi
movb $0x1, 0x79(%rdi)
movq 0x38(%rbp), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
callq 0xfcaec
movq 0x30(%rbp), %rdi
callq 0xfcb73
xorl %r14d, %r14d
imulq $0x38, %r14, %r15
cmpq $0x0, 0x18(%r13,%r15)
je 0x9b6a0
addq %r13, %r15
cmpb $0x0, 0xd(%r15)
je 0x9b6a0
leaq 0x30(%r15), %r12
movl 0x14(%r15), %ecx
movq %rbx, %rdi
leaq 0x95baf(%rip), %rsi     # 0x1311d7
movq %r12, %rdx
xorl %eax, %eax
callq 0xe9226
movl 0x14(%r15), %ecx
xorl 0x10(%r15), %ecx
movl $0x4, %eax
movl %ecx, %edx
cmpb $-0x1, %dl
je 0x9b64d
movzbl %dl, %esi
testl %esi, %esi
jne 0x9b671
shrl $0x8, %edx
decl %eax
jne 0x9b641
movq %rbx, %rdi
leaq 0x95b9c(%rip), %rsi     # 0x1311fa
movq %r12, %rdx
leaq 0x7de48(%rip), %r8      # 0x1194b0
xorl %eax, %eax
callq 0xe9226
jmp 0x9b6a0
movq %rbx, %rdi
leaq 0x95b7f(%rip), %rsi     # 0x1311fa
movq %r12, %rdx
leaq 0xb17aa(%rip), %r8      # 0x14ce2f
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
leaq 0x95b86(%rip), %rsi     # 0x13121c
movq %r12, %rdx
xorl %eax, %eax
callq 0xe9df7
leaq 0x1(%r14), %rax
testq %r14, %r14
movq %rax, %r14
je 0x9b5f8
jmp 0x9b6b9
movw $0x101, 0x4(%r15)       # imm = 0x101
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
movq 0x10(%rsp), %r15
cmpb $0x0, 0x4(%r15)
jne 0x9b6e9
subq $-0x80, 0x18(%rsp)
movq 0x30(%rsp), %r14
incq %r14
cmpq 0x8(%r15), %r14
jl 0x9b1a4
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x9b74f
cmpb $0x0, 0x5(%r15)
je 0x9b70c
leaq 0x95a3f(%rip), %rsi     # 0x131141
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe9752
movl 0x8(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq