// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/hlp.c
// Function: do_topicdata
static void do_topicdata(deark *c, lctx *d, struct topic_ctx *tctx)
{
	i64 pos;
	int saved_indent_level, saved_indent_level2;
	dbuf *inf = tctx->unc_topicdata;

	de_dbg_indent_save(c, &saved_indent_level);

	de_dbg(c, "topic data");

	de_dbg_indent(c, 1);
	if(!inf) {
		goto done;
	}

	de_dbg_indent_save(c, &saved_indent_level2);

	if(tctx->pos_of_first_topiclink==INVALIDPOS || tctx->pos_of_first_topiclink<TOPICBLOCKHDRSIZE) {
		de_warn(c, "Bad first topic link");
		pos = 0;
	}
	else {
		// Maybe we should call topicpos_to_abspos(), etc., but this should be
		// correct since an offset in the first topicblock.
		pos = tctx->pos_of_first_topiclink - TOPICBLOCKHDRSIZE;
	}

	while(1) {
		u32 next_pos_code;
		i64 next_pos = 0;
		int ret;

		if(pos > inf->len) {
			de_dbg(c, "[stopping TOPIC parsing, exceeded end of data]");
			break;
		}
		if(pos == inf->len) {
			de_dbg(c, "[stopping TOPIC parsing, reached end of data]");
			break;
		}
		if(pos + 21 > inf->len) {
			de_warn(c, "Error parsing TOPIC, not enough room for another TOPICLINK (%"I64_FMT
				", %"I64_FMT")", pos, inf->len);
			break;
		}

		// TODO: Display as "Blk#:offs"
		de_dbg(c, "topiclink at [%"I64_FMT"]", pos);
		de_dbg_indent(c, 1);
		next_pos_code = 0;
		if(!do_topiclink(c, d, tctx, pos, &next_pos_code)) goto done;
		de_dbg_indent(c, -1);

		ret = calc_next_topiclink_pos(c, d, tctx, pos, next_pos_code, &next_pos);
		if(!ret) break;
		pos = next_pos;
	}

done:
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
leaq 0x12f9ce(%rip), %rsi    # 0x1ad116
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
cmpq $0x0, -0x30(%rbp)
jne 0x7d769
jmp 0x7d8cf
movq -0x8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x15b580
movq -0x18(%rbp), %rax
cmpl $-0x1, 0x18(%rax)
je 0x7d78a
movq -0x18(%rbp), %rax
cmpl $0xc, 0x18(%rax)
jae 0x7d7a6
movq -0x8(%rbp), %rdi
leaq 0x12f98c(%rip), %rsi    # 0x1ad121
movb $0x0, %al
callq 0x15bc10
movq $0x0, -0x20(%rbp)
jmp 0x7d7b6
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
subl $0xc, %eax
movl %eax, %eax
movq %rax, -0x20(%rbp)
jmp 0x7d7b8
movq $0x0, -0x40(%rbp)
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jle 0x7d7e5
movq -0x8(%rbp), %rdi
leaq 0x12f95d(%rip), %rsi    # 0x1ad136
movb $0x0, %al
callq 0x15b0d0
jmp 0x7d8cd
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jne 0x7d80a
movq -0x8(%rbp), %rdi
leaq 0x12f967(%rip), %rsi    # 0x1ad165
movb $0x0, %al
callq 0x15b0d0
jmp 0x7d8cd
movq -0x20(%rbp), %rax
addq $0x15, %rax
movq -0x30(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jle 0x7d83f
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
leaq 0x12f960(%rip), %rsi    # 0x1ad193
movb $0x0, %al
callq 0x15bc10
jmp 0x7d8cd
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq 0x12f98b(%rip), %rsi    # 0x1ad1d9
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movl $0x0, -0x34(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x34(%rbp), %r8
callq 0x7d8f0
cmpl $0x0, %eax
jne 0x7d88a
jmp 0x7d8cf
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movl -0x34(%rbp), %r8d
leaq -0x40(%rbp), %r9
callq 0x7de30
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0x7d8c0
jmp 0x7d8cd
movq -0x40(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x7d7b8
jmp 0x7d8cf
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x15b5a0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)