// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/os2bootlogo.c
// Function: de_run_os2bootlogo
static void de_run_os2bootlogo(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	int k;

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

	d->max_bytes_per_plane = IMG_WIDTH*IMG_MAX_HEIGHT/8;
	do_read_header(c, d, 0);

	d->unc_pixels = dbuf_create_membuf(c, d->max_bytes_per_plane*NUM_PLANES, 0x1);
	dbuf_enable_wbuffer(d->unc_pixels);
	for(k=0; k<NUM_PLANES; k++) {
		do_decompress_plane(c, d, k);
		if(d->fatal_errflag) goto done;
	}

	// There's a program that makes files that only use RLE compression.
	// Out of curiosity, I want to identify such files.
	de_dbg(c, "cmpr uses lzss: %u", (UI)d->uses_lzss);

	do_write_image(c, d);

done:
	if(d) {
		if(d->need_dcmpr_errmsg) {
			de_err(c, "Decompression failed. This is probably not "
				"an OS/2 Boot Logo.");
		}
		dbuf_close(d->unc_pixels);
		de_free(c, d);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdi, %rbx
movl $0x78, %esi
callq 0xe969b
movq %rax, %r13
movq $0x9600, 0x60(%rax)     # imm = 0x9600
leaq 0x60(%rsp), %r14
movq $0x0, (%r14)
leaq 0x7f2f3(%rip), %rsi     # 0x12319f
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
leaq 0x8ea9a(%rip), %r15     # 0x132966
movq %r13, (%rsp)
xorl %r12d, %r12d
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef3a0
movq %rax, (%r13)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef3a0
movq %rax, 0x8(%r13)
movq (%r13), %rcx
movq %rbx, %rdi
movq %r15, %rsi
movl %r12d, %edx
movq %rax, %r8
xorl %eax, %eax
callq 0xe9226
incq %r12
addq $0x18, %r13
cmpq $0x4, %r12
jne 0xa3ed3
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq (%rsp), %r12
movq 0x60(%r12), %rsi
shlq $0x2, %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0xf0faf
movq %rax, 0x70(%r12)
movq %rax, %rdi
callq 0xf0e3f
xorl %r13d, %r13d
leaq (,%r13,2), %rbp
addq %r13, %rbp
movq (%r12,%rbp,8), %rcx
movq %rbx, %rdi
leaq 0x8ea1a(%rip), %rsi     # 0x132981
movl %r13d, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x70(%r12), %rdi
movq 0x60(%r12), %rsi
movq %r13, 0x30(%rsp)
imulq %r13, %rsi
callq 0xf152a
movq 0x70(%r12), %rdi
callq 0xf0ea4
movq %rbx, %rdi
leaq 0x10(%rsp), %r14
movq %r14, %rsi
leaq 0x48(%rsp), %r15
movq %r15, %rdx
leaq 0x60(%rsp), %rcx
callq 0xfa6e0
movq 0x18(%rbx), %rax
movq %rax, 0x10(%rsp)
movq (%r12,%rbp,8), %rax
movq %rax, 0x18(%rsp)
movq %rbp, 0x40(%rsp)
movq 0x8(%r12,%rbp,8), %rax
movq %rax, 0x20(%rsp)
movq 0x70(%r12), %rax
movq %rax, 0x48(%rsp)
movq 0x60(%r12), %rcx
movq %rcx, 0x58(%rsp)
movb $0x1, 0x50(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x38(%rsp)
movl $0x30, %esi
movq %rbx, %rdi
callq 0xe969b
movq %rax, %r13
movq %r14, (%rax)
movq %r15, 0x8(%rax)
movq 0x18(%rsp), %rax
movq %rax, 0x18(%r13)
addq 0x20(%rsp), %rax
movq %rax, 0x20(%r13)
movq %rbx, %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0xfb2c3
movq %rax, 0x10(%r13)
leaq 0x4d8(%rip), %rcx       # 0xa4519
movq %rcx, 0x8(%rax)
movq %r13, (%rax)
movq 0x18(%r13), %r14
cmpq 0x20(%r13), %r14
jge 0xa4284
movq %r13, %r15
addq $0x18, %r15
movq 0x28(%r13), %rax
cmpq 0x58(%rsp), %rax
jge 0xa4284
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0xef14d
testb %al, %al
je 0xa40ea
movl %eax, %r12d
movzbl %al, %r14d
andb $0x3, %r12b
je 0xa4149
movq (%rsp), %rax
movb $0x1, 0x68(%rax)
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0xef14d
movl %eax, %ebp
cmpb $0x1, %r12b
je 0xa415b
movzbl %r12b, %eax
cmpl $0x2, %eax
jne 0xa418b
movl %r14d, %r12d
shrl $0x2, %r12d
andl $0x3, %r12d
addl $0x3, %r12d
movzbl %bpl, %eax
shll $0x4, %eax
shrl $0x4, %r14d
movl %r14d, %ebp
orl %eax, %ebp
xorl %r14d, %r14d
leaq 0x7c649(%rip), %rdx     # 0x12072e
jmp 0xa41c7
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0xef14d
testb %al, %al
je 0xa4270
movzbl %al, %ebp
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0xef14d
cmpl $0x4, (%rbx)
movzbl %al, %r14d
jl 0xa412e
movq %rbx, %rdi
leaq 0x8e8c6(%rip), %rsi     # 0x1329e8
movl %r14d, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0xe9226
cmpl $0x1, %ebp
adcl $0x0, %ebp
movq 0x10(%r13), %rdi
movl %r14d, %esi
callq 0xfb382
decl %ebp
jne 0xa4134
jmp 0xa4260
shrl $0x2, %r14d
xorl %r12d, %r12d
xorl %ebp, %ebp
leaq 0x79086(%rip), %rdx     # 0x11d1df
jmp 0xa41c7
movl %r14d, %eax
shrl $0x2, %eax
andl $0x3, %eax
movl %r14d, %r12d
shrl $0x4, %r12d
andl $0x7, %r12d
addl $0x3, %r12d
movzbl %bpl, %ecx
shrl $0x7, %r14d
leal (%r14,%rcx,2), %ebp
movl %eax, %r14d
leaq 0x9c40d(%rip), %rdx     # 0x140596
jmp 0xa41c7
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0xef14d
movl %r14d, %ecx
shrl $0x2, %ecx
andl $0xf, %ecx
movzbl %bpl, %ebp
movl %ebp, %edx
andl $0xf, %edx
shrl $0x6, %r14d
leal (%r14,%rdx,4), %r12d
movzbl %al, %eax
shll $0x4, %eax
shrl $0x4, %ebp
orl %eax, %ebp
movl %ecx, %r14d
leaq 0x9aa07(%rip), %rdx     # 0x13ebce
cmpl $0x4, (%rbx)
jl 0xa41f3
movq %rbx, %rdi
leaq 0x8e827(%rip), %rsi     # 0x1329fd
movl %r14d, %ecx
movl %ebp, %r8d
movl %r12d, %r9d
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movl %ebp, 0xc(%rsp)
testl %r14d, %r14d
je 0xa4234
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0xef14d
cmpl $0x4, (%rbx)
movzbl %al, %ebp
jl 0xa4224
movq %rbx, %rdi
leaq 0xa6331(%rip), %rsi     # 0x14a54c
movl %ebp, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x10(%r13), %rdi
movl %ebp, %esi
callq 0xfb382
decl %r14d
jne 0xa41fc
cmpl $0x4, (%rbx)
jl 0xa4246
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
testl %r12d, %r12d
movl 0xc(%rsp), %eax
je 0xa4260
movq 0x10(%r13), %rdi
movl 0x10(%rdi), %esi
subl %eax, %esi
movl %r12d, %edx
callq 0xfb3af
movq 0x18(%r13), %r14
cmpq 0x20(%r13), %r14
jl 0xa405d
jmp 0xa4284
movq %rbx, %rdi
leaq 0x8e75d(%rip), %rsi     # 0x1329d7
movq %r14, %rdx
xorl %eax, %eax
callq 0xe93cf
movq 0x48(%rsp), %rdi
callq 0xf0ea4
movb $0x1, 0x64(%rsp)
movq 0x18(%r13), %rax
subq 0x18(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x10(%r13), %rsi
movq %rbx, %rdi
callq 0xfb408
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe9752
cmpl $0x0, 0x60(%rsp)
je 0xa431c
movq %rbx, %rdi
leaq 0x60(%rsp), %rsi
callq 0xfa6a8
movq %rbx, %rdi
leaq 0x8e6c9(%rip), %rsi     # 0x13299f
movq 0x30(%rsp), %r13
movl %r13d, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0xe9226
movq (%rsp), %r12
movw $0x101, 0x69(%r12)      # imm = 0x101
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
cmpb $0x0, 0x69(%r12)
jne 0xa4457
incq %r13
cmpq $0x4, %r13
jne 0xa3f4e
jmp 0xa4395
movq (%rsp), %r12
movq 0x40(%rsp), %rax
leaq (%r12,%rax,8), %r15
movq 0x70(%r12), %rax
movq 0x18(%rax), %rcx
subq 0x38(%rsp), %rcx
movq %rcx, 0x10(%r15)
movq 0x68(%rsp), %rdx
movq %rbx, %rdi
leaq 0x7d0f9(%rip), %rsi     # 0x121443
xorl %eax, %eax
callq 0xe9226
movq 0x8(%r15), %r14
subq 0x68(%rsp), %r14
movq 0x30(%rsp), %r13
je 0xa4382
movq %rbx, %rdi
leaq 0x8e658(%rip), %rsi     # 0x1329c3
movq %r14, %rdx
xorl %eax, %eax
callq 0xe9226
cmpq $0x400, %r14            # imm = 0x400
jg 0xa42ec
cmpq $0x270f, 0x10(%r15)     # imm = 0x270F
jle 0xa42ec
jmp 0xa42f4
movzbl 0x68(%r12), %edx
leaq 0x8e573(%rip), %rsi     # 0x132915
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movl $0x10, %eax
cmpq $0x7d01, (%r12,%rax)    # imm = 0x7D01
jge 0xa43cd
addq $0x18, %rax
cmpq $0x70, %rax
jne 0xa43b1
movl $0x190, %r14d           # imm = 0x190
jmp 0xa43d3
movl $0x1e0, %r14d           # imm = 0x1E0
movl $0x280, %esi            # imm = 0x280
movq %rbx, %rdi
movq %r14, %rdx
callq 0xe9b05
movl $0x280, %esi            # imm = 0x280
movq %rbx, %rdi
movq %r14, %rdx
movl $0x3, %ecx
callq 0xf2cab
movq %rax, %r14
leaq 0x60(%rsp), %r15
movl $0x10, %r8d
movl $0x32, %edi
movl $0x2, %esi
xorl %edx, %edx
movq %r15, %rcx
xorl %r9d, %r9d
callq 0xecbbc
movq 0x60(%r12), %r8
movq 0x70(%r12), %rdi
movl $0x4, %edx
movl $0x50, %ecx
xorl %esi, %esi
movq %r15, %r9
pushq $0x2
pushq %r14
callq 0xf36f9
addq $0x10, %rsp
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf2923
movq %r14, %rdi
callq 0xf28d4
testq %r12, %r12
je 0xa448a
cmpb $0x0, 0x6a(%r12)
je 0xa4475
leaq 0x8e4bd(%rip), %rsi     # 0x132928
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
movq 0x70(%r12), %rdi
callq 0xf0b13
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe9752
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq