// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x78
popq %rsi
callq 0xdecaf
movq %rax, %r13
movq $0x9600, 0x60(%rax)     # imm = 0x9600
leaq 0x60(%rsp), %r14
andq $0x0, (%r14)
leaq 0x78aa4(%rip), %rsi     # 0x1161bf
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
leaq 0x882c5(%rip), %r15     # 0x1259fe
movq %r13, (%rsp)
xorl %r12d, %r12d
cmpq $0x4, %r12
je 0x9d786
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xe40bf
movq %rax, (%r13)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xe40bf
movq %rax, 0x8(%r13)
movq (%r13), %rcx
movq %rbx, %rdi
movq %r15, %rsi
movl %r12d, %edx
movq %rax, %r8
xorl %eax, %eax
callq 0xde896
incq %r12
addq $0x18, %r13
jmp 0x9d740
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq (%rsp), %r14
movq 0x60(%r14), %rsi
shlq $0x2, %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0xe59cd
movq %rax, 0x70(%r14)
movq %rax, %rdi
callq 0xe589c
xorl %r12d, %r12d
cmpq $0x4, %r12
je 0x9dbe6
imulq $0x18, %r12, %r14
movq (%rsp), %r15
leaq (%r15,%r14), %rax
movq %rax, 0x40(%rsp)
movq (%r15,%r14), %rcx
movq %rbx, %rdi
leaq 0x88239(%rip), %rsi     # 0x125a19
movl %r12d, %edx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x70(%r15), %rdi
movq 0x60(%r15), %rsi
movq %r12, 0x10(%rsp)
imulq %r12, %rsi
callq 0xe5eb2
movq 0x70(%r15), %rdi
callq 0xe58e8
movq %rbx, %rdi
leaq 0x18(%rsp), %r12
movq %r12, %rsi
leaq 0x48(%rsp), %r13
movq %r13, %rdx
leaq 0x60(%rsp), %rcx
callq 0xee7ee
movq 0x18(%rbx), %rax
movq %rax, 0x18(%rsp)
movups (%r15,%r14), %xmm0
movups %xmm0, 0x20(%rsp)
movq 0x70(%r15), %rax
movq %rax, 0x48(%rsp)
movq 0x60(%r15), %rcx
movq %rcx, 0x58(%rsp)
movb $0x1, 0x50(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x38(%rsp)
movq %rbx, %rdi
pushq $0x30
popq %rsi
callq 0xdecaf
movq %rax, %rbp
movq %r12, (%rax)
movq %r13, 0x8(%rax)
movq 0x20(%rsp), %rax
leaq 0x18(%rbp), %r15
movq %rax, 0x18(%rbp)
addq 0x28(%rsp), %rax
movq %rax, 0x20(%rbp)
movq %rbx, %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0xef27c
movq %rax, 0x10(%rbp)
leaq 0x4b3(%rip), %rcx       # 0x9dd5a
movq %rcx, 0x8(%rax)
movq %rbp, (%rax)
movq 0x18(%rbp), %r14
cmpq 0x20(%rbp), %r14
jge 0x9dae3
movq 0x28(%rbp), %rax
cmpq 0x58(%rsp), %rax
jge 0x9dae3
movq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0xe3f2a
testb %al, %al
je 0x9d94a
movl %eax, %r13d
movzbl %al, %r12d
andb $0x3, %r13b
je 0x9d9a9
movq (%rsp), %rax
movb $0x1, 0x68(%rax)
movq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0xe3f2a
movzbl %al, %ecx
cmpb $0x1, %r13b
je 0x9d9c1
movzbl %r13b, %eax
cmpl $0x2, %eax
jne 0x9d9f1
movl %r12d, %r14d
shrl $0x2, %r14d
andl $0x3, %r14d
addl $0x3, %r14d
shll $0x4, %ecx
shrl $0x4, %r12d
movl %r12d, %eax
orl %ecx, %eax
movl %eax, 0xc(%rsp)
xorl %r12d, %r12d
leaq 0x75e1f(%rip), %rdx     # 0x113764
jmp 0x9da34
movq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0xe3f2a
testb %al, %al
je 0x9dacf
movzbl %al, %r14d
movq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0xe3f2a
cmpl $0x4, (%rbx)
movzbl %al, %r12d
jl 0x9d99e
movq %rbx, %rdi
leaq 0x880fd(%rip), %rsi     # 0x125a80
movl %r12d, %edx
movl %r14d, %ecx
xorl %eax, %eax
callq 0xde896
jmp 0x9d99e
movq 0x10(%rbp), %rdi
movl %r12d, %esi
callq 0xef336
subl $0x1, %r14d
jae 0x9d992
jmp 0x9d8ae
shrl $0x2, %r12d
xorl %r14d, %r14d
movl $0x0, 0xc(%rsp)
leaq 0x72840(%rip), %rdx     # 0x1101ff
jmp 0x9da34
movl %r12d, %eax
shrl $0x2, %eax
andl $0x3, %eax
movl %r12d, %r14d
shrl $0x4, %r14d
andl $0x7, %r14d
addl $0x3, %r14d
shrl $0x7, %r12d
leal (%r12,%rcx,2), %ecx
movl %ecx, 0xc(%rsp)
movl %eax, %r12d
leaq 0x95c37(%rip), %rdx     # 0x133626
jmp 0x9da34
movq 0x18(%rsp), %rdi
movq %r15, %rsi
movq %rcx, %r13
callq 0xe3f2a
movl %r12d, %ecx
shrl $0x2, %ecx
andl $0xf, %ecx
movl %r13d, %edx
andl $0xf, %edx
shrl $0x6, %r12d
leal (%r12,%rdx,4), %r14d
movzbl %al, %eax
shll $0x4, %eax
shrl $0x4, %r13d
orl %eax, %r13d
movl %ecx, %r12d
movl %r13d, 0xc(%rsp)
leaq 0x9426a(%rip), %rdx     # 0x131c9e
cmpl $0x4, (%rbx)
jl 0x9da98
movq %rbx, %rdi
leaq 0x88052(%rip), %rsi     # 0x125a95
movl %r12d, %ecx
movl 0xc(%rsp), %r8d
movl %r14d, %r9d
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
jmp 0x9da98
movq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0xe3f2a
cmpl $0x4, (%rbx)
movzbl %al, %r13d
jl 0x9da8c
movq %rbx, %rdi
leaq 0x9fbaa(%rip), %rsi     # 0x13d62c
movl %r13d, %edx
xorl %eax, %eax
callq 0xde896
movq 0x10(%rbp), %rdi
movl %r13d, %esi
callq 0xef336
subl $0x1, %r12d
jae 0x9da62
cmpl $0x4, (%rbx)
jl 0x9daae
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
testl %r14d, %r14d
je 0x9d8ae
movq 0x10(%rbp), %rdi
movl 0x10(%rdi), %esi
subl 0xc(%rsp), %esi
movl %r14d, %edx
callq 0xef363
jmp 0x9d8ae
movq %rbx, %rdi
leaq 0x87f96(%rip), %rsi     # 0x125a6f
movq %r14, %rdx
xorl %eax, %eax
callq 0xde9f1
movq 0x48(%rsp), %rdi
callq 0xe58e8
movb $0x1, 0x64(%rsp)
movq 0x18(%rbp), %rax
subq 0x20(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x10(%rbp), %rsi
movq %rbx, %rdi
callq 0xef395
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xded32
cmpl $0x0, 0x60(%rsp)
je 0x9db72
movq %rbx, %rdi
leaq 0x60(%rsp), %rsi
callq 0xee7bc
movq %rbx, %rdi
leaq 0x87f02(%rip), %rsi     # 0x125a37
movq 0x10(%rsp), %r12
movl %r12d, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0xde896
movq (%rsp), %rax
movw $0x101, 0x69(%rax)      # imm = 0x101
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
incq %r12
movq (%rsp), %rax
cmpb $0x0, 0x69(%rax)
je 0x9d7b7
jmp 0x9dca4
movq (%rsp), %rax
movq 0x70(%rax), %rax
movq 0x18(%rax), %rcx
subq 0x38(%rsp), %rcx
movq 0x40(%rsp), %r15
movq %rcx, 0x10(%r15)
movq 0x68(%rsp), %rdx
movq %rbx, %rdi
leaq 0x768c4(%rip), %rsi     # 0x11445f
xorl %eax, %eax
callq 0xde896
movq 0x8(%r15), %r14
subq 0x68(%rsp), %r14
movq 0x10(%rsp), %r12
je 0x9dbd3
movq %rbx, %rdi
leaq 0x87e9f(%rip), %rsi     # 0x125a5b
movq %r14, %rdx
xorl %eax, %eax
callq 0xde896
cmpq $0x400, %r14            # imm = 0x400
jg 0x9db47
cmpq $0x270f, 0x10(%r15)     # imm = 0x270F
jle 0x9db47
jmp 0x9db51
movq (%rsp), %rax
movzbl 0x68(%rax), %edx
leaq 0x87db8(%rip), %rsi     # 0x1259ad
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
movq (%rsp), %rcx
leaq 0x18(%r14), %rax
cmpq $0x78, %rax
je 0x9dc26
cmpq $0x7d01, 0x10(%rcx,%r14) # imm = 0x7D01
movq %rax, %r14
jl 0x9dc06
movl $0x1e0, %r14d           # imm = 0x1E0
jmp 0x9dc2c
movl $0x190, %r14d           # imm = 0x190
movl $0x280, %esi            # imm = 0x280
movq %rbx, %rdi
movq %r14, %rdx
callq 0xdf038
pushq $0x3
popq %rcx
movl $0x280, %esi            # imm = 0x280
movq %rbx, %rdi
movq %r14, %rdx
callq 0xe7437
movq %rax, %r14
pushq $0x32
popq %rdi
pushq $0x2
popq %rsi
leaq 0x60(%rsp), %r15
pushq $0x10
popq %r8
xorl %edx, %edx
movq %r15, %rcx
xorl %r9d, %r9d
callq 0xe1b11
movq (%rsp), %rax
movq 0x60(%rax), %r8
movq 0x70(%rax), %rdi
pushq $0x4
popq %rdx
pushq $0x50
popq %rcx
xorl %esi, %esi
movq %r15, %r9
pushq $0x2
pushq %r14
callq 0xe7de1
popq %rax
popq %rcx
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xe70b7
movq %r14, %rdi
callq 0xe7084
movq (%rsp), %rax
cmpb $0x0, 0x6a(%rax)
je 0x9dcbf
leaq 0x87d0b(%rip), %rsi     # 0x1259c0
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
movq (%rsp), %r14
movq 0x70(%r14), %rdi
callq 0xe5591
movq %rbx, %rdi
movq %r14, %rsi
callq 0xded32
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq