// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/bmff.c
// Function: do_box_ctts
static void do_box_ctts(deark *c, lctx *d, struct de_boxesctx *bctx)
{
	u8 version;
	u32 flags;
	struct de_boxdata *curbox = bctx->curbox;
	i64 pos = curbox->payload_pos;
	i64 e_count, e_to_print;
	i64 bytesleft;
	i64 k;

	do_read_version_and_flags(c, d, bctx, &version, &flags, 1);
	pos += 4;
	if(version>1 || flags!=0) return;

	e_count = dbuf_getu32be_p(bctx->f, &pos);
	de_dbg(c, "entry count: %u", (unsigned int)e_count);

	bytesleft = curbox->payload_pos + curbox->payload_len - pos;
	if(bytesleft < e_count*8) return;

	e_to_print = e_count;
	if(e_to_print > d->max_entries_to_print) {
		e_to_print = d->max_entries_to_print;
	}

	for(k=0; k<e_to_print; k++) {
		i64 s_count, s_offset;
		s_count = dbuf_getu32be_p(bctx->f, &pos);
		if(version==0) {
			s_offset = dbuf_getu32be_p(bctx->f, &pos);
		}
		else {
			s_offset = dbuf_geti32be(bctx->f, pos); pos += 4;
		}
		de_dbg(c, "entry[%d]: sample count=%"I64_FMT", offset=%"I64_FMT,
			(int)k, s_count, s_offset);
	}
	if(e_to_print < e_count) {
		de_dbg(c, "[%d more entry(s) omitted, starting at %"I64_FMT"]",
			(int)(e_count-e_to_print), pos);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x19(%rbp), %rcx
leaq -0x20(%rbp), %r8
movl $0x1, %r9d
callq 0x39eb0
movq -0x30(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x30(%rbp)
movzbl -0x19(%rbp), %eax
cmpl $0x1, %eax
jg 0x38686
cmpl $0x0, -0x20(%rbp)
je 0x3868b
jmp 0x387cf
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x1654b0
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
movl %eax, %edx
leaq 0x1692bf(%rip), %rsi    # 0x1a1970
movb $0x0, %al
callq 0x15b0d0
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x28(%rbp), %rcx
addq 0x40(%rcx), %rax
subq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x38(%rbp), %rcx
shlq $0x3, %rcx
cmpq %rcx, %rax
jge 0x386e6
jmp 0x387cf
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jle 0x38708
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x40(%rbp), %rax
jge 0x387a5
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x1654b0
movq %rax, -0x58(%rbp)
movzbl -0x19(%rbp), %eax
cmpl $0x0, %eax
jne 0x38753
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x1654b0
movq %rax, -0x60(%rbp)
jmp 0x38774
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x1655d0
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rax
movl %eax, %edx
movq -0x58(%rbp), %rcx
movq -0x60(%rbp), %r8
leaq 0x16952d(%rip), %rsi    # 0x1a1cba
movb $0x0, %al
callq 0x15b0d0
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x38710
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jge 0x387cf
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
movl %eax, %edx
movq -0x30(%rbp), %rcx
leaq 0x169405(%rip), %rsi    # 0x1a1bcd
movb $0x0, %al
callq 0x15b0d0
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)