// File: /workspace/github_c_makefile_star2_O2/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 0xdebae
pushq $0x10
popq %rsi
movq %rbx, %rdi
callq 0xdecaf
movq %rax, %r15
pushq $0x11
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe08d2
movl %eax, (%r15)
leaq 0x80faa(%rip), %rsi     # 0x115e52
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
leaq 0x20(%rsp), %r14
movq $0x1c, (%r14)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xe4071
movq %rax, 0x8(%r15)
leaq 0x727ca(%rip), %rsi     # 0x1076ac
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
addq $0x4, (%r14)
movq %r15, %r14
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
xorl %ebp, %ebp
xorl %r13d, %r13d
movq %r15, 0x18(%rsp)
cmpq 0x8(%r14), %r13
jge 0x95451
testq %rbp, %rbp
je 0x94f25
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x954b5
movl $0x130, %esi            # imm = 0x130
movq %rbx, %rdi
callq 0xdecaf
movq %rax, %rbp
movq %rbx, (%rax)
movq %r14, 0x8(%rax)
movq %rax, 0xc0(%rax)
movq %rax, 0xf8(%rax)
andl $0x0, 0xc8(%rax)
movl $0x1, 0x100(%rax)
leaq 0xf0(%rax), %r12
movq %r12, %rdi
leaq 0x980c5(%rip), %rsi     # 0x12d031
pushq $0x8
popq %r15
movq %r15, %rdx
callq 0xde492
leaq 0x128(%rbp), %rdi
leaq 0x7b14a(%rip), %rsi     # 0x1100d0
movq %r15, %rdx
callq 0xde492
movq %rbx, %rdi
callq 0xf07cc
movq %rax, 0x30(%rbp)
movb $0x1, 0x78(%rax)
movq %r13, 0x30(%rsp)
movq %r13, 0x10(%rbp)
movq 0x20(%rsp), %rax
movq %rax, 0x18(%rbp)
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
leaq 0x14(%rsp), %rsi
callq 0xdebae
movq 0x18(%rbp), %rdx
movq %rbx, %rdi
leaq 0xa2752(%rip), %rsi     # 0x137722
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x18(%rbx), %rdi
leaq 0x8(%rsp), %r15
movq %r15, %rsi
callq 0xe3f6e
movq %rbx, %rdi
leaq 0x8f1af(%rip), %rsi     # 0x1241ac
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe4071
movq %rax, %r13
movq %rbx, %rdi
leaq 0x8f199(%rip), %rsi     # 0x1241b8
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x10(%rbp), %rax
incq %rax
cmpq %rax, %r13
jne 0x95278
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3f2a
cmpb $0x1f, %al
ja 0x9527f
leaq 0xc0(%rbp), %r13
leaq 0xf8(%rbp), %rcx
movq %rcx, 0x28(%rsp)
movzbl %al, %ecx
movq 0x18(%rbx), %rdi
movq 0x8(%rsp), %rsi
movq 0x18(%rsp), %rax
movl (%rax), %r9d
movq %rcx, %rdx
xorl %r8d, %r8d
callq 0xe495c
movq %rax, 0x38(%rbp)
addq $0x1f, 0x8(%rsp)
movq 0x18(%rax), %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0x999c2(%rip), %rsi     # 0x12ea5e
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq 0x8(%rsp), %rsi
leaq 0x40(%rbp), %rdx
pushq $0x4
popq %r14
movl %r14d, %ecx
xorl %r8d, %r8d
callq 0xe657c
leaq 0x50(%rbp), %rdx
movq %rbx, %rdi
leaq 0x727e0(%rip), %rsi     # 0x1078b0
xorl %eax, %eax
callq 0xde896
movq 0x30(%rbp), %rax
movl 0x40(%rbp), %ecx
movl %ecx, 0x90(%rax)
movq 0x30(%rbp), %rax
movb $0x1, %cl
movb %cl, 0x7b(%rax)
movq 0x8(%rsp), %rsi
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x70(%rbp), %rdx
movl %r14d, %ecx
xorl %r8d, %r8d
callq 0xe657c
movq %rbp, %rdx
subq $-0x80, %rdx
movq %rbx, %rdi
leaq 0x91ef4(%rip), %rsi     # 0x127013
xorl %eax, %eax
callq 0xde896
movq 0x30(%rbp), %rax
movl 0x70(%rbp), %ecx
movl %ecx, 0x94(%rax)
movq 0x30(%rbp), %rax
movb $0x1, %cl
movb %cl, 0x7c(%rax)
movb $0x1, %r14b
movq 0x8(%rsp), %rdx
addq $0x4, %rdx
movq %rdx, 0x8(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
pushq $0x1
popq %rcx
leaq 0x760d1(%rip), %r8      # 0x10b22e
callq 0x954ec
movq 0x8(%rsp), %rdx
addq $0x4, %rdx
movq %rdx, 0x8(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
xorl %ecx, %ecx
leaq 0x8f047(%rip), %r8      # 0x1241c6
callq 0x954ec
addq $0x8, 0x8(%rsp)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3f6e
movl %eax, 0x28(%rbp)
movq %rbx, %rdi
leaq 0x7271c(%rip), %rsi     # 0x1078bf
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movzwl 0x28(%rbp), %eax
movq 0x30(%rbp), %rcx
movw %ax, 0x7e(%rcx)
movb %r14b, 0x7d(%rcx)
pushq $0x2
popq %r14
subq $0x1, %r14
jb 0x952ae
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe4071
movq %rax, -0x18(%r12)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe4071
movq %rax, -0x10(%r12)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe4071
movq %rax, -0x8(%r12)
movq -0x18(%r12), %rcx
movq %rbx, %rdi
leaq 0x8efc1(%rip), %rsi     # 0x1241cd
movq %r12, %rdx
xorl %eax, %eax
callq 0xde896
movq -0x10(%r12), %rcx
movq %rbx, %rdi
leaq 0x8efbb(%rip), %rsi     # 0x1241e0
movq %r12, %rdx
xorl %eax, %eax
callq 0xde896
movq -0x8(%r12), %rcx
movq %rbx, %rdi
leaq 0x8efb5(%rip), %rsi     # 0x1241f3
movq %r12, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe4071
movl %eax, -0x20(%r12)
movq %rbx, %rdi
leaq 0x8efa3(%rip), %rsi     # 0x124206
movq %r12, %rdx
movl %eax, %ecx
xorl %eax, %eax
callq 0xde896
addq $0x38, %r12
jmp 0x951c0
movw $0x101, 0x4(%r14)       # imm = 0x101
movl 0x14(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
movq 0x18(%rsp), %r14
cmpb $0x0, 0x4(%r14)
jne 0x95451
subq $-0x80, 0x20(%rsp)
movq 0x30(%rsp), %r13
incq %r13
jmp 0x94f0b
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 0x29a(%rip), %rcx       # 0x9557e
movq %rcx, 0x30(%rax)
movq %r13, 0x28(%rax)
movq %rcx, 0x58(%rax)
movq 0x28(%rsp), %rcx
movq %rcx, 0x50(%rax)
andl $0x0, 0xd4(%rbp)
andl $0x0, 0x10c(%rbp)
movl $0xcc, %r14d
movl $0x4000, %r15d          # imm = 0x4000
cmpq $0x13c, %r14            # imm = 0x13C
je 0x9534d
movq 0xc(%rbp,%r14), %rdi
testq %rdi, %rdi
je 0x95347
movl $0x10000, %esi          # imm = 0x10000
callq 0xdfbb6
cqto
idivq %r15
addq 0xc(%rbp,%r14), %rax
cmpq %rax, 0x1c(%rbp,%r14)
je 0x95347
movb $0x1, (%rbp,%r14)
addq $0x38, %r14
jmp 0x95313
movq 0x30(%rbp), %rax
movq %rbp, 0x8(%rax)
leaq 0x25c(%rip), %rcx       # 0x955b8
movq %rcx, 0x60(%rax)
movq 0x68(%rax), %rdi
movq 0x38(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0xead71
movq 0x30(%rbp), %rdi
movb $0x1, 0x79(%rdi)
movq 0x38(%rbp), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
callq 0xf0864
movq 0x30(%rbp), %rdi
callq 0xf08e8
xorl %r14d, %r14d
cmpq $0x2, %r14
je 0x9527f
imulq $0x38, %r14, %r15
cmpq $0x0, 0x18(%r13,%r15)
je 0x95449
addq %r13, %r15
cmpb $0x0, 0xd(%r15)
je 0x95449
leaq 0x30(%r15), %r12
movl 0x14(%r15), %ecx
movq %rbx, %rdi
leaq 0x8ee57(%rip), %rsi     # 0x124227
movq %r12, %rdx
xorl %eax, %eax
callq 0xde896
movl 0x14(%r15), %ecx
xorl 0x10(%r15), %ecx
pushq $0x4
popq %rax
movl %ecx, %edx
subl $0x1, %eax
jb 0x953fd
cmpb $-0x1, %dl
je 0x953f8
movzbl %dl, %esi
testl %esi, %esi
jne 0x9541a
shrl $0x8, %edx
jmp 0x953e7
movq %rbx, %rdi
leaq 0x8ee43(%rip), %rsi     # 0x12424a
movq %r12, %rdx
leaq 0x770cf(%rip), %r8      # 0x10c4e0
xorl %eax, %eax
callq 0xde896
jmp 0x95449
movq %rbx, %rdi
leaq 0x8ee26(%rip), %rsi     # 0x12424a
movq %r12, %rdx
leaq 0xaab11(%rip), %r8      # 0x13ff3f
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
leaq 0x8ee2d(%rip), %rsi     # 0x12426c
movq %r12, %rdx
xorl %eax, %eax
callq 0xdf2a5
incq %r14
jmp 0x95396
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x954b5
cmpb $0x0, 0x5(%r14)
je 0x95474
leaq 0x8ed27(%rip), %rsi     # 0x124191
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
movq %rbx, %rdi
movq %r14, %rsi
callq 0xded32
movl 0x10(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq