// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmi.c
// Function: de_run_bmi
static void de_run_bmi(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	i64 pos = 0;

	d = de_malloc(c, sizeof(lctx));

	d->input_encoding = de_get_input_encoding(c, NULL, DE_ENCODING_WINDOWS1252);

	if(!do_header(c, d, pos)) goto done;
	pos += d->fixed_header_size;

	if(d->globalimg.num_pal_entries>0) {
		read_palette(c, d, &d->globalimg, pos);
		pos += 4*d->globalimg.num_pal_entries;
	}

	if(!do_read_table(c, d, pos)) goto done;
	do_comments(c, d);
	do_bitmaps(c, d);

done:
	if(d) {
		de_free(c, d->table);
		de_free(c, d);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x478, %rsp            # imm = 0x478
movq %rdi, %rbx
movl $0x448, %esi            # imm = 0x448
callq 0xdecaf
movq %rax, %r14
pushq $0x9
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe08d2
movl %eax, (%r14)
leaq 0xfb1a2(%rip), %rsi     # 0x12c3ee
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
leaq 0x50(%rsp), %r15
movq $0x9, (%r15)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3fc4
movq %rax, 0x20(%r14)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3fc4
movq %rax, 0x28(%r14)
movq 0x20(%r14), %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0xdf038
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3fc4
movl %eax, 0x30(%r14)
leaq 0xd92e8(%rip), %rsi     # 0x10a59d
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3fc4
movq %rax, 0x38(%r14)
leaq 0x107a06(%rip), %rsi    # 0x138cde
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
cmpl $0x0, 0x30(%r14)
je 0x31302
movq 0x38(%r14), %rdi
leaq -0x1(%rdi), %rax
cmpq $0x7, %rax
ja 0x31302
callq 0xdfba1
movq %rax, 0x40(%r14)
leaq 0x50(%rsp), %rsi
addq $0x2, (%rsi)
movq 0x18(%rbx), %rdi
callq 0xe3fc4
movq %rax, %r15
movq %rax, 0x10(%r14)
cmpq $0x64, %rax
jle 0x31334
leaq 0xd9286(%rip), %rsi     # 0x10a5ae
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
jmp 0x3133d
movq 0x50(%rsp), %rax
movq %rax, 0x8(%r14)
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
cmpq $0x64, %r15
jle 0x31377
movq 0x18(%r14), %rsi
movq %rbx, %rdi
callq 0xded32
movq %rbx, %rdi
movq %r14, %rsi
callq 0xded32
addq $0x478, %rsp            # imm = 0x478
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%r14), %r15
cmpq $0x0, 0x40(%r14)
jle 0x31399
leaq 0x20(%r14), %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x31938
movq 0x40(%r14), %rax
leaq (%r15,%rax,4), %r15
leaq 0x50(%rsp), %rbp
movq %r15, (%rbp)
movl 0x10(%r14), %ecx
leaq 0xd9231(%rip), %rsi     # 0x10a5de
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xde896
movq 0x10(%r14), %rsi
pushq $0x10
popq %rdx
movq %rbx, %rdi
callq 0xdf66f
movq %rax, 0x18(%r14)
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
leaq 0xd9215(%rip), %rax     # 0x10a5f4
movq %r14, %r15
movq %rax, %r14
xorl %r13d, %r13d
xorl %r12d, %r12d
cmpq 0x10(%r15), %r12
jge 0x3143a
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xe3fc4
movq 0x18(%r15), %rcx
movl %eax, (%rcx,%r13)
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xe40bf
movq 0x18(%r15), %rcx
movq %rax, 0x8(%rcx,%r13)
movl (%rcx,%r13), %ecx
movq %rbx, %rdi
movq %r14, %rsi
movl %r12d, %edx
movq %rax, %r8
xorl %eax, %eax
callq 0xde896
incq %r12
addq $0x10, %r13
jmp 0x313eb
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
pushq $0x8
popq %rbp
leaq 0x50(%rsp), %rax
xorl %r12d, %r12d
movq %r15, %r14
movq %rax, %r15
movq %r14, 0x8(%rsp)
movq 0x10(%r14), %rax
cmpq %rax, %r12
jge 0x31503
movq 0x18(%r14), %rax
cmpl $0x3, -0x8(%rax,%rbp)
jne 0x314f7
movq (%rax,%rbp), %rax
addq $0x2, %rax
movq %rax, 0x50(%rsp)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe40bf
movq %rax, %r14
addq $0x2, 0x50(%rsp)
movq %rbx, %rdi
callq 0xeac74
movq %rax, %r13
movq 0x18(%rbx), %rdi
movq 0x50(%rsp), %rsi
movq 0x8(%rsp), %rax
movl (%rax), %eax
movl %eax, (%rsp)
movl $0x1f4, %ecx            # imm = 0x1F4
movq %r14, %rdx
movq %r13, %r8
pushq $0x1
popq %r9
callq 0xe4ced
movq %r13, %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0xd9136(%rip), %rsi     # 0x10a613
movl %r12d, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0xde896
movq %r13, %rdi
movq 0x8(%rsp), %r14
callq 0xeaf3c
incq %r12
addq $0x10, %rbp
jmp 0x3145b
movq %r14, %rcx
addq $0x48, %rcx
movq %rcx, 0x38(%rsp)
leaq 0x10(%rsp), %rbp
xorl %esi, %esi
cmpq %rax, %rsi
jge 0x3134e
movq 0x18(%r14), %rcx
movq %rsi, %rdx
shlq $0x4, %rdx
cmpl $0x1, (%rcx,%rdx)
jne 0x318d2
movq %rsi, 0x40(%rsp)
addq %rdx, %rcx
movq 0x8(%rcx), %r14
movq %r14, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
movl $0x418, %edx            # imm = 0x418
leaq 0x60(%rsp), %rdi
xorl %esi, %esi
callq 0x18140
movq %rbx, %rdi
leaq 0x1c(%rsp), %rsi
callq 0xdebae
movq %rbx, %rdi
leaq 0xf7d90(%rip), %rsi     # 0x129305
movq %r14, %rdx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xe3fc4
movq %rax, %r15
movq %rax, 0x50(%rsp)
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xe3fc4
movq %rax, %r14
movq %rax, 0x58(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0xdf038
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xe3fc4
movq %rax, %r12
movq %rax, 0x68(%rsp)
movq %rbx, %rdi
leaq 0x107700(%rip), %rsi    # 0x138cde
movl %r12d, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xe3fc4
movq %rax, %r13
movl %r13d, 0x60(%rsp)
movq %rbx, %rdi
leaq 0xd8f97(%rip), %rsi     # 0x10a59d
movl %r13d, %edx
xorl %eax, %eax
callq 0xde896
testl %r13d, %r13d
sete %al
leaq 0x78(%rsp), %rcx
cmoveq 0x38(%rsp), %rcx
movq %rcx, 0x30(%rsp)
leaq -0x1(%r12), %rcx
cmpq $0x8, %rcx
setae %cl
orb %al, %cl
jne 0x3164d
movq %r12, %rdi
callq 0xdfba1
movq %rax, 0x70(%rsp)
testq %rax, %rax
setg %al
movl %eax, 0x18(%rsp)
addq $0x2, 0x10(%rsp)
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xe40bf
movq %rax, %r13
movq %rbx, %rdi
leaq 0xd8fc0(%rip), %rsi     # 0x10a62c
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
imulq %r15, %r12
movq %r12, %rdi
pushq $0x20
popq %rsi
callq 0xdfbb6
cqto
pushq $0x8
popq %rcx
idivq %rcx
movq %rax, %r12
movq %rax, 0x20(%rsp)
imulq %r14, %r12
movq %rbx, %rdi
leaq 0xd8faa(%rip), %rsi     # 0x10a64d
movq %r12, %rdx
xorl %eax, %eax
callq 0xde896
movq %r13, 0x48(%rsp)
cmpq $0x5f5e100, %r13        # imm = 0x5F5E100
jg 0x318a2
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xe3fc4
movq %rax, %r13
movq %rbx, %rdi
leaq 0xd8f98(%rip), %rsi     # 0x10a670
movl %r13d, %edx
xorl %eax, %eax
callq 0xde896
cmpq %r12, %r13
cmovgeq %r12, %r13
movq %r13, 0x28(%rsp)
cmpb $0x0, 0x18(%rsp)
je 0x3171f
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
leaq 0x50(%rsp), %rsi
callq 0x31938
movq 0x70(%rsp), %rax
shlq $0x2, %rax
addq %rax, 0x10(%rsp)
movq 0x50(%rsp), %r15
movq 0x58(%rsp), %r14
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xe6be1
testl %eax, %eax
je 0x318a2
movq 0x68(%rsp), %rax
cmpq $0x18, %rax
ja 0x31891
movl $0x1000112, %ecx        # imm = 0x1000112
btq %rax, %rcx
jae 0x31891
movq %rbx, %rdi
movq %r12, %rsi
pushq $0x1
popq %rdx
callq 0xe59cd
movq %rax, %r15
movq 0x48(%rsp), %rax
cmpq %rax, 0x18(%r15)
jge 0x31853
movq 0x10(%rsp), %rdx
movq 0x18(%rbx), %rax
cmpq 0x18(%rax), %rdx
jge 0x318a5
movq %rbx, %rdi
leaq 0x101411(%rip), %rsi    # 0x132ba1
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xe3fc4
movq %rax, %r14
movq %rbx, %rdi
leaq 0xd8ee6(%rip), %rsi     # 0x10a6a1
movl %r14d, %edx
xorl %eax, %eax
callq 0xde896
movq 0x10(%rsp), %rax
leaq 0x1(%rax), %rsi
movq %rsi, 0x10(%rsp)
cmpq 0x28(%rsp), %r14
jg 0x318a5
addq %r14, %rax
incq %rax
movq 0x18(%rbx), %rdi
cmpq 0x18(%rdi), %rax
jg 0x318a5
movq %rbp, %r13
movq 0x18(%r15), %rbp
cmpq %r12, %rbp
jge 0x3183b
movl $0x3, (%rsp)
movq %r14, %rdx
movq %r15, %rcx
movq 0x28(%rsp), %r8
xorl %r9d, %r9d
callq 0xf4638
testl %eax, %eax
je 0x31909
movq 0x18(%r15), %rcx
movq %rcx, %rdx
subq %rbp, %rdx
movq %rbx, %rdi
leaq 0xd8e7b(%rip), %rsi     # 0x10a6af
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
addq %r14, 0x10(%rsp)
movq %r13, %rbp
jmp 0x31764
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq %rbx, %rdi
pushq $0x3
popq %rcx
callq 0xe7437
movq %rax, %r12
movq 0x68(%rsp), %rdx
cmpq $0x18, %rdx
jne 0x318da
movq %r15, %rdi
xorl %esi, %esi
movq 0x20(%rsp), %rdx
pushq $0x3
popq %rcx
movq %r12, %r8
pushq $0x1
popq %r9
callq 0xe7f67
jmp 0x318f5
movq %rbx, %rdi
leaq 0xd8def(%rip), %rsi     # 0x10a68a
xorl %eax, %eax
callq 0xdf2a5
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x8(%rsp), %r14
movq %r12, %rdi
callq 0xe7084
movq %r15, %rdi
callq 0xe5591
movl 0x1c(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
movq 0x10(%r14), %rax
movq 0x40(%rsp), %rsi
incq %rsi
jmp 0x31516
andl $0x0, (%rsp)
movq %r15, %rdi
xorl %esi, %esi
movq 0x20(%rsp), %rcx
movq 0x30(%rsp), %r8
movq %r12, %r9
callq 0xe7cbc
movq 0x8(%rsp), %r14
movq %r12, %rdi
xorl %esi, %esi
pushq $0x2
popq %rdx
callq 0xe70b7
jmp 0x318ad
xorl %r12d, %r12d
movq 0x8(%rsp), %r14
movq %r13, %rbp
jmp 0x318ad