// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/bmff.c
// Function: do_box_stsc
static void do_box_stsc(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!=0 || 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/12 < e_count) return;

	e_to_print = de_min_int(e_count, d->max_entries_to_print);

	for(k=0; k<e_to_print; k++) {
		i64 first_chunk, spc, sdi;
		first_chunk = dbuf_getu32be_p(bctx->f, &pos);
		spc = dbuf_getu32be_p(bctx->f, &pos);
		sdi = dbuf_getu32be_p(bctx->f, &pos);
		de_dbg(c, "entry[%d]: first chunk=%d, samples/chunk=%d, descr. index=%d",
			(int)k, (int)first_chunk, (int)spc, (int)sdi);
	}
	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 $0x70, %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 $0x0, %eax
jne 0x38006
cmpl $0x0, -0x20(%rbp)
je 0x3800b
jmp 0x38136
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 0x16993f(%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
movl $0xc, %ecx
cqto
idivq %rcx
cmpq -0x38(%rbp), %rax
jge 0x38069
jmp 0x38136
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x15ccf0
movq %rax, -0x40(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x40(%rbp), %rax
jge 0x3810c
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x1654b0
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x1654b0
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x1654b0
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rax
movl %eax, %edx
movq -0x58(%rbp), %rax
movl %eax, %ecx
movq -0x60(%rbp), %rax
movl %eax, %r8d
movq -0x68(%rbp), %rax
movl %eax, %r9d
leaq 0x169a9c(%rip), %rsi    # 0x1a1b90
movb $0x0, %al
callq 0x15b0d0
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x38086
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jge 0x38136
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
movl %eax, %edx
movq -0x30(%rbp), %rcx
leaq 0x169a9e(%rip), %rsi    # 0x1a1bcd
movb $0x0, %al
callq 0x15b0d0
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)