// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/bmff.c
// Function: de_run_bmff
static void de_run_bmff(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	struct de_boxesctx *bctx = NULL;
	int skip_autodetect = 0;
	const char *s;

	d = de_malloc(c, sizeof(lctx));
	bctx = de_malloc(c, sizeof(struct de_boxesctx));

	if(de_havemodcode(c, mparams, 'T')) {
		d->is_jumbf = 1;
		skip_autodetect = 1;
	}
	if(de_havemodcode(c, mparams, 'X')) {
		d->is_jpx = 1;
		d->is_jp2_jpx_jpm = 1;
		skip_autodetect = 1;
	}
	if(de_havemodcode(c, mparams, 'B')) {
		d->is_bmff = 1;
		skip_autodetect = 1;
	}

	if(!skip_autodetect) {
		u32 first_boxtype;
		// Try to detect old QuickTime files that don't have an ftyp box.
		first_boxtype = (u32)de_getu32be(4);
		if(first_boxtype==BOX_mdat || first_boxtype==BOX_moov ||
			first_boxtype==BOX_free || first_boxtype==BOX_wide ||
			first_boxtype==BOX_skip || first_boxtype==BOX_pnot)
		{
			d->is_bmff = 1;
		}
	}

	s = de_get_ext_option(c, "bmff:maxentries");
	if(s) {
		d->max_entries_to_print = de_atoi64(s);
	}
	else {
		d->max_entries_to_print = 32;
	}
	if(d->max_entries_to_print<0) {
		d->max_entries_to_print = 0;
	}

	bctx->userdata = (void*)d;
	bctx->f = c->infile;
	bctx->identify_box_fn = my_box_identify_fn;
	bctx->handle_box_fn = my_box_handler;

	fmtutil_read_boxes_format(c, bctx);

	de_free(c, bctx);
	de_free(c, d);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r12
movq %rdi, %rbx
movl $0x30, %esi
callq 0xe8b2b
movq %rax, %r14
movl $0x30, %esi
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, %r15
movq %rbx, %rdi
movq %r12, %rsi
movl $0x54, %edx
callq 0xea4d9
movl %eax, %ebp
testl %eax, %eax
je 0x2a909
movb $0x1, 0xa(%r14)
movq %rbx, %rdi
movq %r12, %rsi
movl $0x58, %edx
callq 0xea4d9
testl %eax, %eax
je 0x2a93a
movw $0x101, 0x5(%r14)       # imm = 0x101
movq %rbx, %rdi
movq %r12, %rsi
movl $0x42, %edx
callq 0xea4d9
testl %eax, %eax
jne 0x2a94e
jmp 0x2a953
movq %rbx, %rdi
movq %r12, %rsi
movl $0x42, %edx
callq 0xea4d9
testl %eax, %eax
je 0x2a9cd
movb $0x1, 0x4(%r14)
leaq 0xeaa7f(%rip), %rsi     # 0x1153d9
movq %rbx, %rdi
callq 0xe9b74
testq %rax, %rax
je 0x2a97a
movq %rax, %rdi
callq 0xe9c2f
xorl %ecx, %ecx
testq %rax, %rax
cmovgq %rax, %rcx
jmp 0x2a97f
movl $0x20, %ecx
movq %rcx, 0x10(%r14)
movq %r14, (%r15)
movq 0x18(%rbx), %rax
movq %rax, 0x10(%r15)
leaq 0x18e(%rip), %rax       # 0x2ab23
movq %rax, 0x18(%r15)
leaq 0x278(%rip), %rax       # 0x2ac18
movq %rax, 0x20(%r15)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xf8316
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe8be2
movq %rbx, %rdi
movq %r14, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xe8be2
testl %ebp, %ebp
jne 0x2a953
movq 0x18(%rbx), %rdi
movl $0x4, %esi
callq 0xeed0d
cmpl $0x706e6f73, %eax       # imm = 0x706E6F73
jg 0x2aa0c
cmpl $0x66726565, %eax       # imm = 0x66726565
je 0x2a94e
cmpl $0x6d646174, %eax       # imm = 0x6D646174
je 0x2a94e
cmpl $0x6d6f6f76, %eax       # imm = 0x6D6F6F76
je 0x2a94e
jmp 0x2a953
cmpl $0x706e6f74, %eax       # imm = 0x706E6F74
je 0x2a94e
cmpl $0x77696465, %eax       # imm = 0x77696465
je 0x2a94e
cmpl $0x736b6970, %eax       # imm = 0x736B6970
je 0x2a94e
jmp 0x2a953