// File: /workspace/github_c_makefile_star2_O1/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 0x79af5
leaq 0xaeef8(%rip), %rsi     # 0x1289dc
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
jmp 0x79cbf
movq %rsi, %r14
movb $0x1, 0x32(%rsi)
movq 0x18(%rbx), %rdi
movq %rsp, %r15
movq %r15, %rsi
callq 0xef193
movq %rax, 0x50(%r14)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef193
movq %rax, 0x58(%r14)
movq 0x50(%r14), %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0xe9b05
addq $0x4, (%r15)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef14d
movzbl %al, %edx
movq %rdx, 0x60(%r14)
leaq 0xc15ab(%rip), %rsi     # 0x13b0f7
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef14d
movb %al, 0x69(%r14)
cmpb $0x3, %al
ja 0x79b7d
movzbl %al, %eax
leaq 0xaed2c(%rip), %rcx     # 0x1288a0
movslq (%rcx,%rax,4), %r15
addq %rcx, %r15
jmp 0x79b84
leaq 0xb22e5(%rip), %r15     # 0x12be69
movq 0x18(%rbx), %rdi
movq %rsp, %rsi
callq 0xef14d
movb %al, 0x68(%r14)
movzbl %al, %edx
movl 0x4(%r14), %eax
cmpl $0x4143424d, %eax       # imm = 0x4143424D
jne 0x79bab
leaq 0xa0012(%rip), %rcx     # 0x119bbb
jmp 0x79c06
cmpl $0x4, %edx
ja 0x79bff
movl %edx, %ecx
leaq 0xaec37(%rip), %rsi     # 0x1287f0
movslq (%rsi,%rcx,4), %rcx
addq %rsi, %rcx
jmpq *%rcx
cmpl $0x52474238, %eax       # imm = 0x52474238
leaq 0xaeeb9(%rip), %rsi     # 0x128a87
leaq 0xb2294(%rip), %rcx     # 0x12be69
cmoveq %rsi, %rcx
cmpl $0x5247424e, %eax       # imm = 0x5247424E
cmoveq %rsi, %rcx
jmp 0x79c06
leaq 0xaee97(%rip), %rcx     # 0x128a82
jmp 0x79c06
leaq 0xd01e4(%rip), %rcx     # 0x149dd8
jmp 0x79c06
leaq 0xaee7c(%rip), %rcx     # 0x128a79
jmp 0x79c06
leaq 0xb2263(%rip), %rcx     # 0x12be69
leaq 0xaedde(%rip), %rsi     # 0x1289eb
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rsp, %rsi
incq (%rsi)
movq 0x18(%rbx), %rdi
callq 0xef193
movl %eax, 0x6c(%r14)
movzbl 0x69(%r14), %edx
leaq 0xaedca(%rip), %rsi     # 0x128a00
movq %rbx, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0xe9226
movb 0x69(%r14), %al
andb $-0x2, %al
cmpb $0x2, %al
jne 0x79c7c
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movl 0x6c(%r14), %edx
leaq 0xaedac(%rip), %rsi     # 0x128a11
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq 0x18(%rbx), %rdi
movq %rsp, %r15
movq %r15, %rsi
callq 0xef14d
movzbl %al, %eax
movq %rax, 0x70(%r14)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef14d
movzbl %al, %ecx
movq %rcx, 0x78(%r14)
movl 0x70(%r14), %edx
leaq 0xaed6f(%rip), %rsi     # 0x128a1f
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movl $0x1, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq