// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/ilbm.c
// Function: do_bmhd
static int do_bmhd(deark *c, lctx *d, i64 pos1, i64 len)
{
	i64 pos = pos1;
	int retval = 0;
	const char *masking_name;

	d->bmhd_changed_flag = 1;
	if(len<20) {
		de_err(c, "Bad BMHD chunk");
		goto done;
	}

	d->found_bmhd = 1;
	d->width = de_getu16be_p(&pos);
	d->height = de_getu16be_p(&pos);
	de_dbg_dimensions(c, d->width, d->height);
	pos += 4;

	d->planes_raw = (i64)de_getbyte_p(&pos);
	de_dbg(c, "planes: %d", (int)d->planes_raw);
	d->masking_code = de_getbyte_p(&pos);
	masking_name = get_maskingtype_name(d->masking_code);

	d->compression = de_getbyte_p(&pos);
	de_dbg(c, "compression: %d (%s)", (int)d->compression, get_cmprtype_name(d, d->compression));

	pos++;
	d->transparent_color = (UI)de_getu16be_p(&pos);
	de_dbg(c, "masking: %d (%s)", (int)d->masking_code, masking_name);
	if(d->masking_code==MASKINGTYPE_COLORKEY || d->masking_code==MASKINGTYPE_LASSO) {
		de_dbg_indent(c, 1);
		de_dbg(c, "color key: %u", d->transparent_color);
		de_dbg_indent(c, -1);
	}

	d->x_aspect = (i64)de_getbyte_p(&pos);
	d->y_aspect = (i64)de_getbyte_p(&pos);
	de_dbg(c, "aspect ratio: %d, %d", (int)d->x_aspect, (int)d->y_aspect);

	retval = 1;
done:
	return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq %rdx, (%rsp)
movb $0x1, 0x35(%rsi)
cmpq $0x13, %rcx
jg 0x796f9
leaq 0xaf524(%rip), %rsi     # 0x128c0c
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
jmp 0x798c3
movq %rsi, %r14
movb $0x1, 0x32(%rsi)
movq 0x18(%rbx), %rdi
movq %rsp, %r15
movq %r15, %rsi
callq 0xeeb91
movq %rax, 0x50(%r14)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeeb91
movq %rax, 0x58(%r14)
movq 0x50(%r14), %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0xe8f88
addq $0x4, (%r15)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeeb4b
movzbl %al, %edx
movq %rdx, 0x60(%r14)
leaq 0xc1d5f(%rip), %rsi     # 0x13b4af
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeeb4b
movb %al, 0x69(%r14)
cmpb $0x3, %al
ja 0x79781
movzbl %al, %eax
leaq 0xaf358(%rip), %rcx     # 0x128ad0
movslq (%rcx,%rax,4), %r15
addq %rcx, %r15
jmp 0x79788
leaq 0xb29c9(%rip), %r15     # 0x12c151
movq 0x18(%rbx), %rdi
movq %rsp, %rsi
callq 0xeeb4b
movb %al, 0x68(%r14)
movzbl %al, %edx
movl 0x4(%r14), %eax
cmpl $0x4143424d, %eax       # imm = 0x4143424D
jne 0x797af
leaq 0xa052e(%rip), %rcx     # 0x119cdb
jmp 0x7980a
cmpl $0x4, %edx
ja 0x79803
movl %edx, %ecx
leaq 0xaf263(%rip), %rsi     # 0x128a20
movslq (%rsi,%rcx,4), %rcx
addq %rsi, %rcx
jmpq *%rcx
cmpl $0x52474238, %eax       # imm = 0x52474238
leaq 0xaf4e5(%rip), %rsi     # 0x128cb7
leaq 0xb2978(%rip), %rcx     # 0x12c151
cmoveq %rsi, %rcx
cmpl $0x5247424e, %eax       # imm = 0x5247424E
cmoveq %rsi, %rcx
jmp 0x7980a
leaq 0xaf4c3(%rip), %rcx     # 0x128cb2
jmp 0x7980a
leaq 0xd0b90(%rip), %rcx     # 0x14a388
jmp 0x7980a
leaq 0xaf4a8(%rip), %rcx     # 0x128ca9
jmp 0x7980a
leaq 0xb2947(%rip), %rcx     # 0x12c151
leaq 0xaf40a(%rip), %rsi     # 0x128c1b
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq %rsp, %rsi
incq (%rsi)
movq 0x18(%rbx), %rdi
callq 0xeeb91
movl %eax, 0x6c(%r14)
movzbl 0x69(%r14), %edx
leaq 0xaf3f6(%rip), %rsi     # 0x128c30
movq %rbx, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0xe8617
movb 0x69(%r14), %al
andb $-0x2, %al
cmpb $0x2, %al
jne 0x79880
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movl 0x6c(%r14), %edx
leaq 0xaf3d8(%rip), %rsi     # 0x128c41
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq 0x18(%rbx), %rdi
movq %rsp, %r15
movq %r15, %rsi
callq 0xeeb4b
movzbl %al, %eax
movq %rax, 0x70(%r14)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeeb4b
movzbl %al, %ecx
movq %rcx, 0x78(%r14)
movl 0x70(%r14), %edx
leaq 0xaf39b(%rip), %rsi     # 0x128c4f
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movl $0x1, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq