// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/plist.c
// Function: do_trailer
static int do_trailer(deark *c, lctx *d, i64 pos1)
{
	int retval = 0;
	i64 pos = pos1;

	de_dbg(c, "trailer at %d", (int)pos);
	de_dbg_indent(c, 1);
	pos += 5; // unused
	pos++; // sort version

	d->nbytes_per_objref_table_entry = (unsigned int)de_getbyte_p(&pos);
	de_dbg(c, "bytes per objref table entry: %u", d->nbytes_per_objref_table_entry);

	d->nbytes_per_object_refnum = (unsigned int)de_getbyte_p(&pos);
	de_dbg(c, "bytes per object refnum: %u", d->nbytes_per_object_refnum);

	d->num_objrefs = de_geti64be(pos);
	de_dbg(c, "num objrefs: %d", (int)d->num_objrefs);
	pos += 8;

	d->top_object_refnum = de_geti64be(pos);
	de_dbg(c, "root object refnum: %"I64_FMT, d->top_object_refnum);
	pos += 8;

	d->objref_table_start = de_geti64be(pos);
	de_dbg(c, "objref table start: %"I64_FMT, d->objref_table_start);
	dbuf_constrain_offset(c->infile, &d->objref_table_start);
	pos += 8;

	if(d->nbytes_per_objref_table_entry<1 || d->nbytes_per_objref_table_entry>8 ||
		d->nbytes_per_object_refnum<1 || d->nbytes_per_object_refnum>8)
	{
		de_err(c, "Bad or unsupported PLIST format");
		goto done;
	}

	if(d->num_objrefs<0 || d->num_objrefs>MAX_PLIST_OBJECTS) {
		de_err(c, "Too many PLIST objects (%"I64_FMT")", d->num_objrefs);
		goto done;
	}

	retval = 1;
done:
	de_dbg_indent(c, -1);
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %edx
leaq 0xa8791(%rip), %rsi     # 0x1c5905
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x28(%rbp), %rax
addq $0x5, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x165170
movzbl %al, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x10(%rax), %edx
leaq 0xa8745(%rip), %rsi     # 0x1c5913
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x165170
movzbl %al, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x14(%rax), %edx
leaq 0xa8732(%rip), %rsi     # 0x1c5934
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x165730
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl %eax, %edx
leaq 0xa8716(%rip), %rsi     # 0x1c5950
movb $0x0, %al
callq 0x15b0d0
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x165730
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
leaq 0xa86e4(%rip), %rsi     # 0x1c5960
movb $0x0, %al
callq 0x15b0d0
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x165730
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdx
leaq 0xa86ba(%rip), %rsi     # 0x1c5978
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
addq $0x20, %rsi
callq 0x164c60
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x1, 0x10(%rax)
jb 0x11d30e
movq -0x10(%rbp), %rax
cmpl $0x8, 0x10(%rax)
ja 0x11d30e
movq -0x10(%rbp), %rax
cmpl $0x1, 0x14(%rax)
jb 0x11d30e
movq -0x10(%rbp), %rax
cmpl $0x8, 0x14(%rax)
jbe 0x11d322
movq -0x8(%rbp), %rdi
leaq 0xa8677(%rip), %rsi     # 0x1c5990
movb $0x0, %al
callq 0x15bfb0
jmp 0x11d35e
movq -0x10(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jl 0x11d33b
movq -0x10(%rbp), %rax
cmpq $0xf4240, 0x28(%rax)    # imm = 0xF4240
jle 0x11d357
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdx
leaq 0xa8662(%rip), %rsi     # 0x1c59b0
movb $0x0, %al
callq 0x15bfb0
jmp 0x11d35e
movl $0x1, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movl -0x1c(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)