// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/hlp.c
// Function: do_topiclink_rectype_32_linkdata1
static int do_topiclink_rectype_32_linkdata1(deark *c, lctx *d,
	struct topic_ctx *tctx, struct topiclink_data *tld)
{
	i64 pos = tld->linkdata1_pos;
	dbuf *inf = tctx->unc_topicdata;
	i64 topicsize;
	i64 topiclength;
	UI id;
	UI bits;
	int retval = 0;

	// TODO: type 33 (table)
	if(tld->recordtype!=1 && tld->recordtype!=32) goto done;

	topicsize = fmtutil_hlp_get_csl_p(inf, &pos);
	de_dbg(c, "topic size: %"I64_FMT, topicsize);

	if(tld->recordtype==32) {
		topiclength = fmtutil_hlp_get_cus_p(inf, &pos);
		de_dbg(c, "topic length: %"I64_FMT, topiclength);
	}

	pos++; // unknownUnsignedChar
	pos++; // unknownBiasedChar
	id = (UI)dbuf_getu16le_p(inf, &pos);
	de_dbg(c, "id: %u", id);
	bits = (UI)dbuf_getu16le_p(inf, &pos);
	de_dbg(c, "bits: 0x%04x", bits);

	if(bits & 0x0001) { // Unknown
		(void)fmtutil_hlp_get_csl_p(inf, &pos);
	}
	if(bits & 0x0002) { // SpacingAbove
		(void)fmtutil_hlp_get_css_p(inf, &pos);
	}
	if(bits & 0x0004) { // SpacingBelow
		(void)fmtutil_hlp_get_css_p(inf, &pos);
	}
	if(bits & 0x0008) { // SpacingLines
		(void)fmtutil_hlp_get_css_p(inf, &pos);
	}
	if(bits & 0x0010) { // LeftIndent
		(void)fmtutil_hlp_get_css_p(inf, &pos);
	}
	if(bits & 0x0020) { // RightIndent
		(void)fmtutil_hlp_get_css_p(inf, &pos);
	}
	if(bits & 0x0040) { // FirstlineIndent
		(void)fmtutil_hlp_get_css_p(inf, &pos);
	}
	// 0x0080 = unused
	if(bits & 0x0100) { // Borderinfo
		goto done; // TODO
	}
	if(bits & 0x0200) { // Tabinfo
		goto done; // TODO
	}
	// 0x0400 = RightAlignedParagraph
	// 0x0800 = CenterAlignedParagraph

	tld->paragraphinfo_pos = pos;
	retval = 1;
done:
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x4c(%rbp)
movq -0x20(%rbp), %rax
movzbl 0x20(%rax), %eax
cmpl $0x1, %eax
je 0x7e626
movq -0x20(%rbp), %rax
movzbl 0x20(%rax), %eax
cmpl $0x20, %eax
je 0x7e626
jmp 0x7e7bc
movq -0x30(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x176270
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rdx
leaq 0x12ecdc(%rip), %rsi    # 0x1ad322
movb $0x0, %al
callq 0x15b0d0
movq -0x20(%rbp), %rax
movzbl 0x20(%rax), %eax
cmpl $0x20, %eax
jne 0x7e681
movq -0x30(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x1760d0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rdx
leaq 0x12ecb8(%rip), %rsi    # 0x1ad332
movb $0x0, %al
callq 0x15b0d0
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x1652c0
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %edx
leaq 0x13c178(%rip), %rsi    # 0x1ba82f
movb $0x0, %al
callq 0x15b0d0
movq -0x30(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x1652c0
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movl -0x48(%rbp), %edx
leaq 0x12ec68(%rip), %rsi    # 0x1ad344
movb $0x0, %al
callq 0x15b0d0
movl -0x48(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x7e6fb
movq -0x30(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x176270
movl -0x48(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x7e713
movq -0x30(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x176150
movl -0x48(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x7e72b
movq -0x30(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x176150
movl -0x48(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x7e743
movq -0x30(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x176150
movl -0x48(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x7e75b
movq -0x30(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x176150
movl -0x48(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x7e773
movq -0x30(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x176150
movl -0x48(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x7e78b
movq -0x30(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x176150
movl -0x48(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x7e79a
jmp 0x7e7bc
movl -0x48(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x7e7a9
jmp 0x7e7bc
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x50(%rax)
movl $0x1, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)