// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/jbf.c
// Function: do_read_header
static int do_read_header(deark *c, lctx *d, i64 pos)
{
	int retval = 0;

	de_dbg(c, "header at %"I64_FMT, pos);
	de_dbg_indent(c, 1);

	pos += 15;
	d->ver_major = (UI)de_getu16be_p(&pos);
	d->ver_minor = (UI)de_getu16be_p(&pos);
	d->ver_combined = (d->ver_major<<16) | d->ver_minor;
	de_dbg(c, "format version: %u.%u", d->ver_major, d->ver_minor);

	if(d->ver_major<1 || d->ver_major>2) {
		de_err(c, "Unsupported JBF format version: %u.%u", d->ver_major, d->ver_minor);
		goto done;
	}
	if(d->ver_major==1 && (d->ver_minor==2 || d->ver_minor>3)) {
		de_warn(c, "Unrecognized JBF format version (%u.%u). File may not be "
			"decoded correctly.", d->ver_major, d->ver_minor);
	}

	d->image_count = de_getu32le(pos);
	de_dbg(c, "image count: %d", (int)d->image_count);
	//pos+=4;
	if(!de_good_image_count(c, d->image_count)) goto done;

	retval = 1;
done:
	de_dbg_indent(c, -1);
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0xf4fe9(%rip), %rsi     # 0x1aed63
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x18(%rbp), %rax
addq $0xf, %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x18(%rbp), %rsi
callq 0x165210
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x18(%rbp), %rsi
callq 0x165210
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
shll $0x10, %ecx
movq -0x10(%rbp), %rax
orl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
leaq 0xeb192(%rip), %rsi     # 0x1a4f92
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
cmpl $0x1, 0x4(%rax)
jb 0xb9e1b
movq -0x10(%rbp), %rax
cmpl $0x2, 0x4(%rax)
jbe 0xb9e40
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
leaq 0xfc1cb(%rip), %rsi     # 0x1b5fff
movb $0x0, %al
callq 0x15bfb0
jmp 0xb9ed5
movq -0x10(%rbp), %rax
cmpl $0x1, 0x4(%rax)
jne 0xb9e7e
movq -0x10(%rbp), %rax
cmpl $0x2, 0x8(%rax)
je 0xb9e5e
movq -0x10(%rbp), %rax
cmpl $0x3, 0x8(%rax)
jbe 0xb9e7e
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
leaq 0xfc1ae(%rip), %rsi     # 0x1b6025
movb $0x0, %al
callq 0x15bc10
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x165540
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, %edx
leaq 0xfb22a(%rip), %rsi     # 0x1b50d9
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x16a9a0
cmpl $0x0, %eax
jne 0xb9ece
jmp 0xb9ed5
movl $0x1, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movl -0x1c(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)