// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/hlp.c
// Function: do_topiclink_rectype_1_32
static void do_topiclink_rectype_1_32(deark *c, lctx *d,
	struct topic_ctx *tctx, struct topiclink_data *tld, dbuf *linkdata2)
{
	i64 pos;
	int in_string = 0;
	int string_count = 0;
	int byte_count = 0;

	if(!d->extract_text) goto done;
	ensure_text_output_file_open(c, d);

	do_topiclink_rectype_32_linkdata1(c, d, tctx, tld);

	// TODO: This is very quick & dirty.
	// The linkdata2 is a collection of NUL-terminated strings. We'd have to
	// interpret the command bytes from linkdata1 to know how to format them.

	pos = 0;
	dbuf_truncate(d->tmpdbuf1, 0); // A place to collect the current output string

	while(1) {
		u8 b;

		if(pos >= linkdata2->len) break;
		b = dbuf_getbyte_p(linkdata2, &pos);
		if(b==0x00) {
			if(in_string) {
				emit_slice(c, d, d->tmpdbuf1, 0, d->tmpdbuf1->len);
				dbuf_truncate(d->tmpdbuf1, 0);
				emit_raw_sz(c, d, "\n");
				string_count++;
				in_string = 0;
			}
		}
		else {
			dbuf_writebyte(d->tmpdbuf1, b);
			byte_count++;
			in_string = 1;
		}
	}
	if(in_string) {
		emit_slice(c, d, d->tmpdbuf1, 0, d->tmpdbuf1->len);
		dbuf_truncate(d->tmpdbuf1, 0);
		emit_raw_sz(c, d, "\n");
		string_count++;
	}
	de_dbg2(c, "[emitted %d strings, totaling %d bytes]", string_count, byte_count);

done:
	;
}

// Assembly:
cmpl $0x0, 0x8(%rsi)
je 0x59293
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r15
movq %rcx, %r12
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %rbp
callq 0x59371
movq 0x10(%rbx), %r13
movq 0x28(%r12), %rax
movq %rax, (%rsp)
movzbl 0x20(%r12), %eax
cmpl $0x20, %eax
je 0x59045
cmpl $0x1, %eax
jne 0x5915f
movq %rsp, %rsi
movq %r13, %rdi
callq 0xf9a8f
leaq 0xc8722(%rip), %rsi     # 0x121779
movq %rbp, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
cmpb $0x20, 0x20(%r12)
jne 0x5908b
movq %rsp, %rsi
movq %r13, %rdi
callq 0xf99d5
leaq 0xc870b(%rip), %rsi     # 0x121789
movq %rbp, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq %rsp, %rbx
addq $0x2, (%rbx)
movq %r13, %rdi
movq %rbx, %rsi
callq 0xeebeb
leaq 0xd5c85(%rip), %rsi     # 0x12ed29
movq %rbp, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq %r13, %rdi
movq %rbx, %rsi
callq 0xeebeb
movq %rbp, %rdi
movq %rax, %rbp
leaq 0xc86d3(%rip), %rsi     # 0x12179b
movq %rdi, %rbx
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
testb $0x1, %bpl
je 0x590e5
movq %rsp, %rsi
movq %r13, %rdi
callq 0xf9a8f
testb $0x2, %bpl
je 0x590f6
movq %rsp, %rsi
movq %r13, %rdi
callq 0xf9a0f
testb $0x4, %bpl
je 0x59107
movq %rsp, %rsi
movq %r13, %rdi
callq 0xf9a0f
testb $0x8, %bpl
je 0x59118
movq %rsp, %rsi
movq %r13, %rdi
callq 0xf9a0f
testb $0x10, %bpl
je 0x59129
movq %rsp, %rsi
movq %r13, %rdi
callq 0xf9a0f
testb $0x20, %bpl
je 0x5913a
movq %rsp, %rsi
movq %r13, %rdi
callq 0xf9a0f
testb $0x40, %bpl
je 0x5914b
movq %rsp, %rsi
movq %r13, %rdi
callq 0xf9a0f
testl $0x300, %ebp            # imm = 0x300
movq %rbx, %rbp
jne 0x5915f
movq (%rsp), %rax
movq %rax, 0x50(%r12)
movq $0x0, (%rsp)
movq 0xd0(%r14), %rdi
xorl %r12d, %r12d
xorl %esi, %esi
callq 0xf0f27
cmpq $0x0, 0x18(%r15)
movl $0x0, %edx
jle 0x59271
movq %rbp, 0x10(%rsp)
xorl %r13d, %r13d
xorl %r12d, %r12d
movl $0x0, 0xc(%rsp)
movq %r15, %rdi
movq %rsp, %rsi
callq 0xeeb4b
movl %eax, %ebx
testb %al, %al
je 0x591c5
movq 0xd0(%r14), %rdi
movzbl %bl, %esi
callq 0xf0bd6
incl %r12d
movl $0x1, %ebp
jmp 0x5920e
xorl %ebp, %ebp
testl %r13d, %r13d
je 0x5920e
movq 0xd0(%r14), %rdx
movq 0x18(%rdx), %rcx
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x59468
movq 0xd0(%r14), %rdi
xorl %esi, %esi
callq 0xf0f27
movq 0xc0(%r14), %rdi
testq %rdi, %rdi
je 0x5920a
leaq 0xb6f82(%rip), %rsi     # 0x110187
callq 0xf10ed
incl 0xc(%rsp)
movq (%rsp), %rax
movl %ebp, %r13d
cmpq 0x18(%r15), %rax
jl 0x5919b
testb %bl, %bl
je 0x59268
movq 0xd0(%r14), %rdx
movq 0x18(%rdx), %rcx
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
callq 0x59468
movq 0xd0(%r14), %rdi
xorl %esi, %esi
callq 0xf0f27
movq 0xc0(%r14), %rdi
testq %rdi, %rdi
je 0x59260
leaq 0xb6f2c(%rip), %rsi     # 0x110187
callq 0xf10ed
movl 0xc(%rsp), %edx
incl %edx
jmp 0x59271
movq 0x10(%rsp), %rbp
movl 0xc(%rsp), %edx
leaq 0xc84bc(%rip), %rsi     # 0x121734
movq %rbp, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0xe87e4
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq