// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/pklite.c
// Function: do_read_reloc_table_short
static void do_read_reloc_table_short(deark *c, lctx *d, i64 pos1, i64 len)
{
	i64 reloc_count = 0;
	i64 pos = pos1;
	i64 endpos = pos1+len;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);
	de_dbg(c, "reading 'short' reloc table at %"I64_FMT, pos1);
	de_dbg_indent(c, 1);

	while(1) {
		UI i;
		UI count;
		i64 seg, offs;

		if(pos+1 > endpos) {
			d->errflag = 1;
			goto done;
		}
		count = (UI)de_getbyte_p(&pos);
		if(count==0) {
			de_dbg2(c, "end-of-data");
			break; // normal completion
		}
		de_dbg2(c, "count: %u", count);

		if(reloc_count+count > MAX_RELOCS) {
			d->errflag = 1;
			goto done;
		}
		if(pos+2+(i64)count*2 > endpos) {
			d->errflag = 1;
			goto done;
		}
		seg = de_getu16le_p(&pos);
		de_dbg2(c, "seg: 0x%04x", (UI)seg);
		de_dbg_indent(c, 1);
		for(i=0; i<count; i++) {
			if(reloc_count>=MAX_RELOCS) {
				d->errflag = 1;
				goto done;
			}
			offs = de_getu16le_p(&pos);
			de_dbg2(c, "offs: 0x%04x", (UI)offs);
			dbuf_writeu16le(d->guest_reloc_table, offs);
			dbuf_writeu16le(d->guest_reloc_table, seg);
			reloc_count++;
		}
		de_dbg_indent(c, -1);
	}

	d->reloc_tbl_endpos = pos;
	de_dbg(c, "cmpr reloc table ends at %"I64_FMT", entries=%d", d->reloc_tbl_endpos,
		(int)reloc_count);

done:
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0xade22(%rip), %rsi     # 0x1c4512
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x30(%rbp), %rax
addq $0x1, %rax
cmpq -0x38(%rbp), %rax
jle 0x11671f
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
jmp 0x1168c1
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x165170
movzbl %al, %eax
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0x116753
movq -0x8(%rbp), %rdi
leaq 0xadd7d(%rip), %rsi     # 0x1c44c4
movb $0x0, %al
callq 0x15b350
jmp 0x11688f
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %edx
leaq 0xa73ee(%rip), %rsi     # 0x1bdb4f
movb $0x0, %al
callq 0x15b350
movq -0x28(%rbp), %rax
movl -0x44(%rbp), %ecx
addq %rcx, %rax
cmpq $0xffff, %rax           # imm = 0xFFFF
jle 0x116786
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
jmp 0x1168c1
movq -0x30(%rbp), %rax
addq $0x2, %rax
movl -0x44(%rbp), %ecx
shlq %rcx
addq %rcx, %rax
cmpq -0x38(%rbp), %rax
jle 0x1167a9
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
jmp 0x1168c1
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rax
movl %eax, %edx
leaq 0xadd01(%rip), %rsi     # 0x1c44d0
movb $0x0, %al
callq 0x15b350
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x44(%rbp), %eax
jae 0x11687c
cmpq $0xffff, -0x28(%rbp)    # imm = 0xFFFF
jl 0x11680d
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
jmp 0x1168c1
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rax
movl %eax, %edx
leaq 0xadca9(%rip), %rsi     # 0x1c44dc
movb $0x0, %al
callq 0x15b350
movq -0x10(%rbp), %rax
movq 0xd0(%rax), %rdi
movq -0x58(%rbp), %rsi
callq 0x168a10
movq -0x10(%rbp), %rax
movq 0xd0(%rax), %rdi
movq -0x50(%rbp), %rsi
callq 0x168a10
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x1167eb
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
jmp 0x116705
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x90(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rdx
movq -0x28(%rbp), %rax
movl %eax, %ecx
leaq 0xadc2f(%rip), %rsi     # 0x1c44e9
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x15b5a0
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)