// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/tiff.c
// Function: do_dbg_print_text_multi_values
static void do_dbg_print_text_multi_values(deark *c, lctx *d, const struct taginfo *tg,
	const struct tagnuminfo *tni, de_ucstring *dbgline)
{
	int is_truncated = 0;
	int str_count = 0;
	i64 pos, endpos;
	i64 adj_totalsize;
	de_encoding enc;

	enc = (tg->datatype==DATATYPE_UTF8) ? DE_ENCODING_UTF8 : d->current_textfield_encoding;

	// An ASCII field is a sequence of NUL-terminated strings.
	// The spec does not say what to do if an ASCII field does not end in a NUL.
	// Our rule is that if the field does not end in a NUL byte (including the case
	// where it is 0 length), then treat it as if it has a NUL byte appended to it.
	// The other options would be to pretend the last byte is always NUL, or to
	// ignore everything after the last NUL byte.

	adj_totalsize = tg->total_size;
	if(adj_totalsize > DE_TIFF_MAX_CHARS_TO_PRINT) {
		adj_totalsize = DE_TIFF_MAX_CHARS_TO_PRINT;
		// FIXME: Suboptimal things might happen if we truncate exactly one byte
		is_truncated = 1;
	}
	endpos = tg->val_offset + adj_totalsize;

	ucstring_append_sz(dbgline, " {", DE_ENCODING_LATIN1);

	pos = tg->val_offset;
	while(1) {
		struct de_stringreaderdata *srd;

		if(pos>=endpos && str_count>0) break;

		srd = dbuf_read_string(c->infile, pos, endpos-pos, endpos-pos,
			DE_CONVFLAG_STOP_AT_NUL, enc);

		if(str_count>0) ucstring_append_sz(dbgline, ",", DE_ENCODING_LATIN1);
		ucstring_append_sz(dbgline, "\"", DE_ENCODING_LATIN1);
		ucstring_append_ucstring(dbgline, srd->str);
		ucstring_append_sz(dbgline, "\"", DE_ENCODING_LATIN1);
		str_count++;

		pos += srd->bytes_consumed;
		de_destroy_stringreaderdata(c, srd);
	}

	if(is_truncated) {
		ucstring_append_sz(dbgline, "...", DE_ENCODING_LATIN1);
	}
	ucstring_append_sz(dbgline, "}", DE_ENCODING_LATIN1);
}

// 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 %r8, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x81, 0xc(%rax)
jne 0x1347a1
movl $0x2, %eax
movl %eax, -0x5c(%rbp)
jmp 0x1347ab
movq -0x10(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x48(%rbp)
cmpq $0x1f4, -0x48(%rbp)     # imm = 0x1F4
jle 0x1347d6
movq $0x1f4, -0x48(%rbp)     # imm = 0x1F4
movl $0x1, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
addq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rdi
leaq 0x96e53(%rip), %rsi     # 0x1cb644
movl $0x5, %edx
callq 0x1715e0
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jl 0x13481c
cmpl $0x0, -0x30(%rbp)
jle 0x13481c
jmp 0x1348cb
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
subq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
subq -0x38(%rbp), %rcx
movl -0x4c(%rbp), %r9d
movl $0x1, %r8d
callq 0x1664c0
movq %rax, -0x58(%rbp)
cmpl $0x0, -0x30(%rbp)
jle 0x134866
movq -0x28(%rbp), %rdi
leaq 0x7b90d(%rip), %rsi     # 0x1b0169
movl $0x5, %edx
callq 0x1715e0
movq -0x28(%rbp), %rdi
leaq 0xa0f70(%rip), %rsi     # 0x1d57e1
movl $0x5, %edx
callq 0x1715e0
movq -0x28(%rbp), %rdi
movq -0x58(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x171460
movq -0x28(%rbp), %rdi
leaq 0xa0f4a(%rip), %rsi     # 0x1d57e1
movl $0x5, %edx
callq 0x1715e0
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x58(%rbp), %rax
movq (%rax), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x166830
jmp 0x134807
cmpl $0x0, -0x2c(%rbp)
je 0x1348e6
movq -0x28(%rbp), %rdi
leaq 0x9d76d(%rip), %rsi     # 0x1d2049
movl $0x5, %edx
callq 0x1715e0
movq -0x28(%rbp), %rdi
leaq 0x96d5b(%rip), %rsi     # 0x1cb64c
movl $0x5, %edx
callq 0x1715e0
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)