// File: /workspace/github_c_makefile_star2_O3/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 0x10(%rsp), %rsi
callq 0xe8a1c
movl $0x10, %esi
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, %r15
movq %rbx, %rdi
xorl %esi, %esi
movl $0x11, %edx
callq 0xeb220
movl %eax, (%r15)
leaq 0x88882(%rip), %rsi     # 0x123012
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
leaq 0x20(%rsp), %r14
movq $0x1c, (%r14)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xeed31
movq %rax, 0x8(%r15)
leaq 0x79f6b(%rip), %rsi     # 0x114737
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
addq $0x4, (%r14)
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
cmpq $0x0, 0x8(%r15)
movl $0x0, %esi
jle 0x9ad87
movq %rsp, %r14
leaq 0x96c98(%rip), %rbp     # 0x13149c
xorl %r12d, %r12d
xorl %esi, %esi
movq %r15, 0x18(%rsp)
testq %rsi, %rsi
je 0x9a81b
movq %rbx, %rdi
callq 0x9adea
movl $0x130, %esi            # imm = 0x130
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, %r13
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), %rdi
movl $0x8, %edx
leaq 0x9fabe(%rip), %rsi     # 0x13a325
callq 0xe8219
leaq 0x128(%r13), %rdi
movl $0x8, %edx
leaq 0x82941(%rip), %rsi     # 0x11d1c0
callq 0xe8219
movq %rbx, %rdi
callq 0xfc498
movq %rax, 0x30(%r13)
movb $0x1, 0x78(%rax)
movq %r12, 0x30(%rsp)
movq %r12, 0x10(%r13)
movq 0x20(%rsp), %rax
movq %rax, 0x18(%r13)
movq %rax, (%rsp)
movq %rbx, %rdi
leaq 0x14(%rsp), %rsi
callq 0xe8a1c
movq 0x18(%r13), %rdx
movq %rbx, %rdi
leaq 0xaa2ad(%rip), %rsi     # 0x144b72
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xeeb91
movq %rbx, %rdi
movq %rbp, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xeed31
movq %rax, %r12
movq %rbx, %rdi
leaq 0x96b9b(%rip), %rsi     # 0x1314a8
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq %r13, 0x8(%rsp)
movq 0x10(%r13), %rax
incq %rax
cmpq %rax, %r12
jne 0x9ad41
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xeeb4b
cmpb $0x1f, %al
ja 0x9ad48
movq 0x8(%rsp), %r15
leaq 0xc0(%r15), %r14
leaq 0xf8(%r15), %rcx
movq %rcx, 0x28(%rsp)
movzbl %al, %ecx
movq 0x18(%rbx), %rdi
movq (%rsp), %rsi
movq 0x18(%rsp), %rax
movl (%rax), %r9d
movq %rcx, %rdx
xorl %r8d, %r8d
callq 0xef87c
movq %rax, 0x38(%r15)
addq $0x1f, (%rsp)
movq 0x18(%rax), %rdi
callq 0xf70f6
movq %rbx, %rdi
leaq 0xa13bc(%rip), %rsi     # 0x13bd4e
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq (%rsp), %rsi
leaq 0x40(%r15), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0xf1762
leaq 0x50(%r15), %rdx
movq %rbx, %rdi
leaq 0x79f78(%rip), %rsi     # 0x11493b
xorl %eax, %eax
callq 0xe8617
movq 0x30(%r15), %rax
movl 0x40(%r15), %ecx
movl %ecx, 0x90(%rax)
movq 0x30(%r15), %rax
movb $0x1, %r13b
movb %r13b, 0x7b(%rax)
movq (%rsp), %rsi
addq $0x4, %rsi
movq %rsi, (%rsp)
movq 0x18(%rbx), %rdi
leaq 0x70(%r15), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0xf1762
movq %r15, %rdx
subq $-0x80, %rdx
movq %rbx, %rdi
leaq 0x998d6(%rip), %rsi     # 0x1342eb
xorl %eax, %eax
callq 0xe8617
movq 0x30(%r15), %rax
movl 0x70(%r15), %ecx
movl %ecx, 0x94(%rax)
movq 0x30(%r15), %rax
movb %r13b, 0x7c(%rax)
movq (%rsp), %rdx
addq $0x4, %rdx
movq %rdx, (%rsp)
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %ecx
leaq 0x7d8ce(%rip), %r8      # 0x11831e
callq 0x9ae21
movq (%rsp), %rdx
addq $0x4, %rdx
movq %rdx, (%rsp)
movq %rbx, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
leaq 0x96a46(%rip), %r8      # 0x1314b6
callq 0x9ae21
addq $0x8, (%rsp)
movq 0x18(%rbx), %rdi
movq %rsp, %rbp
movq %rbp, %rsi
callq 0xeeb91
movl %eax, 0x28(%r15)
movq %rbx, %rdi
leaq 0x79eb3(%rip), %rsi     # 0x11494a
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movzwl 0x28(%r15), %eax
movq 0x30(%r15), %rcx
movw %ax, 0x7e(%rcx)
movb %r13b, 0x7d(%rcx)
xorl %r15d, %r15d
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeed31
imulq $0x38, %r15, %rcx
leaq (%r14,%rcx), %r12
addq $0x30, %r12
movq %rax, -0x18(%r12)
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeed31
movq %rax, -0x10(%r12)
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeed31
movq %rax, -0x8(%r12)
movq -0x18(%r12), %rcx
movq %rbx, %rdi
leaq 0x969bb(%rip), %rsi     # 0x1314bd
movq %r12, %rdx
xorl %eax, %eax
callq 0xe8617
movq -0x10(%r12), %rcx
movq %rbx, %rdi
leaq 0x969b5(%rip), %rsi     # 0x1314d0
movq %r12, %rdx
xorl %eax, %eax
callq 0xe8617
movq -0x8(%r12), %rcx
movq %rbx, %rdi
leaq 0x969af(%rip), %rsi     # 0x1314e3
movq %r12, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeed31
movl %eax, -0x20(%r12)
movq %rbx, %rdi
leaq 0x9699d(%rip), %rsi     # 0x1314f6
movq %r12, %rdx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe8617
movl $0x1, %r15d
testb $0x1, %r13b
movl $0x0, %r13d
jne 0x9aab4
movq 0x8(%rsp), %rsi
movq 0x30(%rsi), %rax
movq 0xd8(%rsi), %rcx
movq %rcx, 0x18(%rax)
movq 0x110(%rsi), %rdx
movq %rdx, 0x40(%rax)
testq %rcx, %rcx
setne %cl
testq %rdx, %rdx
setne 0x38(%rax)
sete %dl
orb %cl, %dl
movb %dl, 0x10(%rax)
leaq 0x2ff(%rip), %rcx       # 0x9aeb5
movq %rcx, 0x30(%rax)
movq %r14, 0x28(%rax)
movq %rcx, 0x58(%rax)
movq 0x28(%rsp), %rcx
movq %rcx, 0x50(%rax)
xorl %eax, %eax
movl %eax, 0xd4(%rsi)
movl %eax, 0x10c(%rsi)
movb $0x1, %r12b
xorl %eax, %eax
leaq 0x968b7(%rip), %rbp     # 0x13149c
imulq $0x38, %rax, %r13
movq 0x18(%r14,%r13), %rdi
testq %rdi, %rdi
je 0x9ac21
addq %r14, %r13
movl $0x10000, %esi          # imm = 0x10000
callq 0xe9cb4
leaq 0x3fff(%rax), %rcx
testq %rax, %rax
cmovnsq %rax, %rcx
sarq $0xe, %rcx
addq 0x18(%r13), %rcx
cmpq %rcx, 0x28(%r13)
je 0x9ac21
movb $0x1, 0xc(%r13)
movl $0x1, %eax
testb $0x1, %r12b
movl $0x0, %r12d
jne 0x9abe5
movq 0x8(%rsp), %r15
movq 0x30(%r15), %rax
movq %r15, 0x8(%rax)
leaq 0x2a1(%rip), %rcx       # 0x9aee7
movq %rcx, 0x60(%rax)
movq 0x68(%rax), %rdi
movq 0x38(%r15), %rax
movq 0x18(%rax), %rsi
callq 0xf6509
movq 0x30(%r15), %rdi
movb $0x1, 0x79(%rdi)
movq 0x38(%r15), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
callq 0xfc530
movq 0x30(%r15), %rdi
callq 0xfc5b7
movb $0x1, %r13b
xorl %eax, %eax
imulq $0x38, %rax, %r15
cmpq $0x0, 0x18(%r14,%r15)
je 0x9ad2a
addq %r14, %r15
cmpb $0x0, 0xd(%r15)
je 0x9ad2a
leaq 0x30(%r15), %r12
movl 0x14(%r15), %ecx
movq %rbx, %rdi
leaq 0x96865(%rip), %rsi     # 0x131517
movq %r12, %rdx
xorl %eax, %eax
callq 0xe8617
movl 0x14(%r15), %ecx
xorl 0x10(%r15), %ecx
movl $0x4, %eax
movl %ecx, %edx
cmpb $-0x1, %dl
je 0x9acd7
movzbl %dl, %esi
testl %esi, %esi
jne 0x9acfb
shrl $0x8, %edx
decl %eax
jne 0x9accb
movq %rbx, %rdi
leaq 0x96852(%rip), %rsi     # 0x13153a
movq %r12, %rdx
leaq 0x7e8de(%rip), %r8      # 0x1195d0
xorl %eax, %eax
callq 0xe8617
jmp 0x9ad2a
movq %rbx, %rdi
leaq 0x96835(%rip), %rsi     # 0x13153a
movq %r12, %rdx
leaq 0xb2740(%rip), %r8      # 0x14d44f
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
leaq 0x9683c(%rip), %rsi     # 0x13155c
movq %r12, %rdx
xorl %eax, %eax
callq 0xe9295
movl $0x1, %eax
testb $0x1, %r13b
movl $0x0, %r13d
jne 0x9ac82
jmp 0x9ad48
movw $0x101, 0x4(%r15)       # imm = 0x101
movl 0x14(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
movq 0x18(%rsp), %r15
cmpb $0x0, 0x4(%r15)
jne 0x9ad82
subq $-0x80, 0x20(%rsp)
movq 0x30(%rsp), %r12
incq %r12
cmpq 0x8(%r15), %r12
movq %rsp, %r14
movq 0x8(%rsp), %rsi
jl 0x9a80e
jmp 0x9ad87
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x9adea
cmpb $0x0, 0x5(%r15)
je 0x9ada7
leaq 0x966e4(%rip), %rsi     # 0x131481
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe8be2
movl 0x10(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq