// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/iff.c
// Function: do_aiff_comt_chunk
static void do_aiff_comt_chunk(deark *c, struct de_iffctx *ictx)
{
	i64 pos = ictx->chunkctx->dpos;
	i64 endpos = ictx->chunkctx->dpos + ictx->chunkctx->dlen;
	i64 ncomments;
	i64 i;
	de_ucstring *s = NULL;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);
	ncomments = dbuf_getu16be_p(ictx->f, &pos);
	de_dbg(c, "num comments: %d", (int)ncomments);
	s = ucstring_create(c);
	for(i=0; i<ncomments; i++) {
		i64 textlen;

		if(pos+8 >= endpos) goto done;
		de_dbg(c, "comment at %"I64_FMT, pos);
		de_dbg_indent(c, 1);
		pos += 4; // timestamp
		pos += 2; // MarkerID
		textlen = dbuf_getu16be_p(ictx->f, &pos);
		if(pos+textlen > endpos) goto done;
		ucstring_empty(s);
		dbuf_read_to_ucstring_n(ictx->f, pos, textlen, 1000, s, 0, DE_ENCODING_ASCII);
		de_dbg(c, "text: \"%s\"", ucstring_getpsz_d(s));
		pos += de_pad_to_2(textlen);
		de_dbg_indent(c, -1);
	}

done:
	ucstring_destroy(s);
	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 -0x10(%rbp), %rax
movq 0x128(%rax), %rax
movq 0x40(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x128(%rax), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x128(%rcx), %rcx
addq 0x48(%rcx), %rax
movq %rax, -0x20(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
callq 0x15b580
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x18(%rbp), %rsi
callq 0x165210
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %edx
leaq 0x106143(%rip), %rsi    # 0x1b3ff3
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x28(%rbp), %rax
jge 0xadfd8
movq -0x18(%rbp), %rax
addq $0x8, %rax
cmpq -0x20(%rbp), %rax
jl 0xadeed
jmp 0xadfda
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x100be1(%rip), %rsi    # 0x1aeadd
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x18(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x18(%rbp), %rsi
callq 0x165210
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
addq -0x48(%rbp), %rax
cmpq -0x20(%rbp), %rax
jle 0xadf51
jmp 0xadfda
movq -0x38(%rbp), %rdi
callq 0x171210
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x38(%rbp), %r8
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %r9d, %r9d
movl $0x1, (%rsp)
callq 0x166a40
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rdi
callq 0x172650
movq -0x50(%rbp), %rdi
movq %rax, %rdx
leaq 0x118ab1(%rip), %rsi    # 0x1c6a52
movb $0x0, %al
callq 0x15b0d0
movq -0x48(%rbp), %rdi
callq 0x15cdf0
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xadecc
jmp 0xadfda
movq -0x38(%rbp), %rdi
callq 0x171750
movq -0x8(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x15b5a0
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)