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

	de_dbg(c, "%s record list at %d", d->fmt_shortname, (int)pos1);
	de_dbg_indent(c, 1);

	// 6-byte header

	x = de_getu32be(pos1);
	de_dbg(c, "nextRecordListID: %d", (int)x);
	if(x!=0) {
		de_warn(c, "This file contains multiple record lists, which is not supported.");
	}

	d->rec_list.num_recs = de_getu16be(pos1+4);
	de_dbg(c, "number of records: %d", (int)d->rec_list.num_recs);

	/////

	if(d->file_fmt==FMT_PRC) d->rec_size = 10;
	else d->rec_size = 8;

	de_dbg(c, "[pre-scanning record list]");
	if(!do_prescan_records(c, d, pos1+6)) goto done;
	de_dbg(c, "[main pass through record list]");

	// i is the index in rec_list.order_to_read
	// n is the index in rec_list.rec_data
	for(i=0; i<d->rec_list.num_recs; i++) {
		i64 n;
		n = (i64)d->rec_list.order_to_read[i];
		if(d->file_fmt==FMT_PRC) {
			if(!do_read_prc_record(c, d, n, pos1+6+d->rec_size*n))
				goto done;
		}
		else {
			if(!do_read_pdb_record(c, d, n, pos1+6+d->rec_size*n))
				goto done;
		}
	}
	retval = 1;
done:
	de_dbg_indent(c, -1);
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x18(%rbp), %rax
movl %eax, %ecx
leaq 0xc1f96(%rip), %rsi     # 0x1c102a
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x165470
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %edx
leaq 0xc1f70(%rip), %rsi     # 0x1c103f
movb $0x0, %al
callq 0x15b0d0
cmpq $0x0, -0x28(%rbp)
je 0xff0ef
movq -0x8(%rbp), %rdi
leaq 0xc1f6c(%rip), %rsi     # 0x1c1054
movb $0x0, %al
callq 0x15bc10
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x4, %rsi
callq 0x1651d0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xa0(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0xa0(%rax), %rax
movl %eax, %edx
leaq 0xc0681(%rip), %rsi     # 0x1bf7ab
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0xff148
movq -0x10(%rbp), %rax
movq $0xa, 0x18(%rax)
jmp 0xff154
movq -0x10(%rbp), %rax
movq $0x8, 0x18(%rax)
movq -0x8(%rbp), %rdi
leaq 0xc1f37(%rip), %rsi     # 0x1c1096
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
addq $0x6, %rdx
callq 0xff8a0
cmpl $0x0, %eax
jne 0xff185
jmp 0xff252
movq -0x8(%rbp), %rdi
leaq 0xc1f21(%rip), %rsi     # 0x1c10b1
movb $0x0, %al
callq 0x15b0d0
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0xa0(%rcx), %rax
jge 0xff24b
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rax
movq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0xff206
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rcx
addq $0x6, %rcx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
imulq -0x38(%rbp), %rax
addq %rax, %rcx
callq 0xffc00
cmpl $0x0, %eax
jne 0xff204
jmp 0xff252
jmp 0xff238
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rcx
addq $0x6, %rcx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
imulq -0x38(%rbp), %rax
addq %rax, %rcx
callq 0xfff70
cmpl $0x0, %eax
jne 0xff236
jmp 0xff252
jmp 0xff238
jmp 0xff23a
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0xff19f
movl $0x1, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movl -0x2c(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)