// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/abk.c
// Function: do_picture_bank
static void do_picture_bank(deark *c, lctx *d, struct amosbank *bk, i64 pos1)
{
	i64 pos = pos1;
	UI segtype;
	int found_screen_header = 0;

	de_dbg(c, "picture bank");
	de_dbg_indent(c, 1);

	segtype = (UI)de_getu32be(pos);
	if(is_scr_hdr_id(segtype)) {
		found_screen_header = 1;
		picture_bank_screen_header(c, d, bk, pos);
		if(bk->errflag) goto done;
		pos += 90;
		segtype = (UI)de_getu32be(pos);
	}

	if(segtype!=AMOS_PIC_HDR_ID) {
		de_err(c, "Missing Picture Header");
		goto done;
	}

	if(!found_screen_header) {
		if(d->opt_allownopal<1) {
			de_warn(c, "No palette found. Can't decode this image.%s",
				(d->opt_allownopal<0 ?
					" (Use \"-opt abk:allownopal\" to try anyway.)" : ""));
			goto done;
		}
		de_warn(c, "No palette found. Using grayscale palette.");
		de_make_grayscale_palette(bk->pal, 32, 0);
	}

	// There's only room for 32 palette entries in the file, so it does no harm
	// to set the next 32 as if this were EHB format.
	picture_bank_make_ehb_pal(bk);

	picture_bank_read_picture(c, d, bk, pos);

done:
	de_dbg_indent(c, -1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rcx, %r13
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xea1d6(%rip), %rsi     # 0x103e57
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0xdeba7
movq 0x18(%r14), %rdi
movq %r13, %rsi
callq 0xe404f
cmpl $0x31990, %eax          # imm = 0x31990
je 0x19cc3
cmpl $0x6071963, %eax        # imm = 0x6071963
je 0x19e20
cmpl $0x12031990, %eax       # imm = 0x12031990
je 0x19cc3
cmpl $0x12030090, %eax       # imm = 0x12030090
jne 0x19ece
leaq 0xea235(%rip), %rsi     # 0x103eff
movq %r14, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rbx
movq %r14, %rdi
movl %ebx, %esi
callq 0xdeba7
movq 0x50(%r12), %rdi
leaq 0x4(%r13), %rsi
callq 0xe3f46
movq %rax, %r15
movq 0x50(%r12), %rdi
leaq 0x6(%r13), %rsi
callq 0xe3f46
leaq 0xea20a(%rip), %rsi     # 0x103f14
movq %r14, %rdi
movl %r15d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xde896
movq 0x50(%r12), %rdi
leaq 0x14(%r13), %rsi
callq 0xe3f46
movl %eax, 0x4b0(%r12)
movl %eax, %ecx
shrl $0xb, %ecx
andb $0x1, %cl
movb %cl, 0x4b4(%r12)
movl %eax, %ecx
shrb $0x7, %cl
movb %cl, 0x4b5(%r12)
leaq 0xea1db(%rip), %rsi     # 0x103f2e
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq %r14, %rdi
movl %ebx, %esi
callq 0xdeba7
movzbl 0x4b4(%r12), %edx
leaq 0xea1c9(%rip), %rsi     # 0x103f42
movq %r14, %rdi
xorl %eax, %eax
callq 0xde896
pushq $-0x1
popq %rsi
movq %r14, %rdi
callq 0xdeba7
movq 0x50(%r12), %rdi
leaq 0x16(%r13), %rsi
callq 0xe3f46
leaq 0xfe993(%rip), %rsi     # 0x118736
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x50(%r12), %rdi
leaq 0x18(%r13), %rsi
callq 0xe3f46
movq %rax, %rbx
leaq 0xea183(%rip), %rsi     # 0x103f4a
movq %r14, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0xde896
cmpb $0x0, 0x4b4(%r12)
je 0x19ded
cmpq $0x6, %rbx
jne 0x19e4c
movb $0x1, 0x4b6(%r12)
leaq 0x1a(%r13), %rax
movq %rax, 0x68(%r12)
movq $0x5, 0x488(%r12)
movq %r14, %rdi
movq %r12, %rsi
callq 0x1a504
andq $0x0, 0x488(%r12)
cmpb $0x0, 0x31(%r12)
jne 0x19e54
jmp 0x19e6b
cmpl $0x0, 0x4(%rbx)
jle 0x1a096
leaq 0xea0a3(%rip), %rsi     # 0x103ed4
movq %r14, %rdi
xorl %eax, %eax
callq 0xdf05a
leaq 0x70(%r12), %rdi
pushq $0x20
popq %rsi
xorl %edx, %edx
callq 0xe87a8
jmp 0x19e99
movw $0x101, 0x30(%r12)      # imm = 0x101
leaq 0xea0fa(%rip), %rsi     # 0x103f55
movq %r14, %rdi
xorl %eax, %eax
callq 0xdf2a5
movb $0x0, 0x31(%r12)
pushq $-0x1
popq %rsi
movq %r14, %rdi
callq 0xdeba7
cmpb $0x0, 0x30(%r12)
jne 0x1a4bc
addq $0x5a, %r13
movq 0x18(%r14), %rdi
movq %r13, %rsi
callq 0xe404f
cmpl $0x6071963, %eax        # imm = 0x6071963
jne 0x19ece
leaq 0x70(%r12), %rax
movq %rax, 0x38(%rsp)
pushq $-0x20
popq %rax
testq %rax, %rax
je 0x19ee4
movl 0xf0(%r12,%rax,4), %ecx
shrl %ecx
andl $0x7f7f7f, %ecx         # imm = 0x7F7F7F
orl $0xff000000, %ecx       # imm = 0xFF000000
movl %ecx, 0x170(%r12,%rax,4)
incq %rax
jmp 0x19ea6
leaq 0xe9f8f(%rip), %rsi     # 0x103e64
movq %r14, %rdi
xorl %eax, %eax
callq 0xdf2a5
jmp 0x1a4bc
leaq 0x4c(%rsp), %rsi
movq %r14, %rdi
callq 0xdebae
leaq 0xea09a(%rip), %rsi     # 0x103f92
movq %r14, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0xdeba7
movq 0x50(%r12), %rdi
leaq 0x8(%r13), %rsi
callq 0xe3f46
movq %rax, %rbx
leaq 0xea080(%rip), %rsi     # 0x103fa8
movq %r14, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0xde896
movq %rbx, 0x10(%rsp)
leaq (,%rbx,8), %rbp
movq 0x50(%r12), %rdi
leaq 0xa(%r13), %rsi
callq 0xe3f46
movq %rax, %r15
leaq 0xea06b(%rip), %rsi     # 0x103fc4
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xde896
movq 0x50(%r12), %rdi
leaq 0xc(%r13), %rsi
callq 0xe3f46
movq %rax, %rbx
leaq 0xea05a(%rip), %rsi     # 0x103fd8
movq %r14, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0xde896
movq %rbx, 0x40(%rsp)
movq %r15, 0x18(%rsp)
imulq %r15, %rbx
leaq 0xea04c(%rip), %rsi     # 0x103feb
movq %r14, %rdi
movl %ebp, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0xde896
movq 0x50(%r12), %rdi
leaq 0xe(%r13), %rsi
callq 0xe3f46
movq %rax, 0x480(%r12)
leaq 0xea03f(%rip), %rsi     # 0x104009
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x50(%r12), %rdi
leaq 0x10(%r13), %rsi
callq 0xe404f
movq %rax, 0x490(%r12)
leaq (%rax,%r13), %rcx
leaq 0xea02a(%rip), %rsi     # 0x104021
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
addq %r13, 0x490(%r12)
movq 0x50(%r12), %rdi
leaq 0x14(%r13), %rsi
callq 0xe404f
movq %rax, 0x498(%r12)
leaq (%rax,%r13), %rcx
leaq 0xea01b(%rip), %rsi     # 0x104048
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
addq %r13, 0x498(%r12)
movq %r14, 0x30(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0xe6be1
testl %eax, %eax
je 0x1a08a
movq 0x480(%r12), %rdx
leaq -0x7(%rdx), %rax
cmpq $-0x7, %rax
ja 0x1a0be
leaq 0xe9ffc(%rip), %rsi     # 0x10406e
xorl %r14d, %r14d
movq 0x30(%rsp), %rdi
xorl %eax, %eax
callq 0xdf2a5
xorl %edi, %edi
xorl %ebp, %ebp
jmp 0x1a493
xorl %edi, %edi
xorl %ebp, %ebp
xorl %r14d, %r14d
jmp 0x1a493
leaq 0x11dbc3(%rip), %rax    # 0x137c60
leaq 0xe9e04(%rip), %rdx     # 0x103ea8
cmoveq %rax, %rdx
leaq 0xe9dcc(%rip), %rsi     # 0x103e7b
movq %r14, %rdi
xorl %eax, %eax
callq 0xdf05a
jmp 0x1a4bc
pushq $-0x1
popq %rsi
movq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0xdeba7
addq $0x18, %r13
movq %r13, 0x4a0(%r12)
leaq 0xe9fae(%rip), %rsi     # 0x10408f
movq %r14, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x10(%rsp), %rsi
imulq %rbx, %rsi
imulq 0x480(%r12), %rsi
movq %rsi, 0x4a8(%r12)
movq %r14, %rdi
xorl %edx, %edx
callq 0xe59cd
movq %rax, %r13
movq 0x18(%r14), %rsi
movq 0x4a0(%r12), %rdx
movq 0x490(%r12), %rcx
movq 0x498(%r12), %r8
movq 0x4a8(%r12), %rax
movq %rax, (%rsp)
movq %r14, %rdi
movq %r13, %r9
callq 0xf0485
pushq $0x3
popq %rcx
movq %r14, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0xe7437
movq %rax, %r15
pushq $0x38
popq %rsi
movq %r14, %rdi
callq 0xdecaf
movq %rax, %rbp
movl 0x480(%r12), %eax
movl %eax, 0x4(%rbp)
movl %eax, 0x8(%rbp)
movq 0x10(%rsp), %rax
movq %rax, 0x10(%rbp)
movq 0x18(%rsp), %rax
movq %rax, 0x18(%rbp)
movq 0x40(%rsp), %rax
movq %rax, 0x20(%rbp)
movq %rbx, 0x28(%rbp)
movq %r13, 0x58(%rsp)
movq %r13, 0x30(%rbp)
movq 0x10(%r15), %rsi
movq %r15, 0x20(%rsp)
imulq 0x8(%r15), %rsi
pushq $0x1
popq %rbx
movq %r14, %rdi
movl %ebx, %edx
callq 0xe59cd
movq %rax, %r13
movl 0x4(%rbp), %eax
cmpl $0x8, %eax
ja 0x1a333
cmpl %eax, 0x8(%rbp)
jne 0x1a333
movq %r12, 0x50(%rsp)
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x70(%rsp)
andq $0x0, 0x28(%rsp)
movq 0x10(%rbp), %rcx
movq 0x28(%rbp), %r12
imulq %rcx, %r12
xorl %eax, %eax
cmpq 0x18(%rbp), %rax
jge 0x1a32a
movq %rax, %rdx
movq 0x20(%rbp), %rax
movq %rax, %rsi
movq %rdx, 0x60(%rsp)
imulq %rdx, %rsi
movq %rsi, 0x78(%rsp)
imulq %rcx, %rsi
movq %rsi, 0x68(%rsp)
xorl %edx, %edx
cmpq %rcx, %rdx
jge 0x1a31d
leaq (,%rdx,8), %rcx
movq %rcx, 0x80(%rsp)
movq %rax, %r15
imulq %rdx, %r15
addq 0x68(%rsp), %r15
xorl %ecx, %ecx
movq %rdx, 0x40(%rsp)
cmpq %rax, %rcx
jge 0x1a311
movq %rcx, 0x10(%rsp)
movq %r15, 0x18(%rsp)
xorl %r14d, %r14d
movl 0x4(%rbp), %eax
cmpq %rax, %r14
jae 0x1a28a
movq 0x30(%rbp), %rdi
movq %r15, %rsi
callq 0xe3eb4
movb %al, 0x28(%rsp,%r14)
incq %r14
addq %r12, %r15
jmp 0x1a269
movq 0x78(%rsp), %rax
movq 0x10(%rsp), %rcx
leaq (%rcx,%rax), %r15
imulq 0x70(%rsp), %r15
addq 0x80(%rsp), %r15
xorl %r14d, %r14d
cmpq $0x8, %r14
je 0x1a2f3
movb $0x7, %cl
subb %r14b, %cl
movl %ebx, %eax
shll %cl, %eax
movl 0x8(%rbp), %esi
xorl %ecx, %ecx
xorl %edx, %edx
cmpq %rcx, %rsi
je 0x1a2df
movzbl 0x28(%rsp,%rcx), %edi
andl %eax, %edi
movl %ebx, %r8d
shll %cl, %r8d
testl %edi, %edi
cmovel %edi, %r8d
orl %r8d, %edx
incq %rcx
jmp 0x1a2bf
leaq (%r15,%r14), %rsi
movzbl %dl, %edx
movq %r13, %rdi
callq 0xe5e13
incq %r14
jmp 0x1a2a9
movq 0x10(%rsp), %rcx
incq %rcx
movq 0x20(%rbp), %rax
movq 0x18(%rsp), %r15
incq %r15
movq 0x40(%rsp), %rdx
jmp 0x1a253
incq %rdx
movq 0x10(%rbp), %rcx
jmp 0x1a227
movq 0x60(%rsp), %rax
incq %rax
jmp 0x1a1fa
movb $0x1, (%rbp)
movq 0x50(%rsp), %r12
cmpb $0x0, 0x4b6(%r12)
je 0x1a457
leaq 0x28(%rsp), %rax
andq $0x0, (%rax)
xorl %eax, %eax
movq 0x20(%rsp), %r14
cmpq 0x10(%r14), %rax
jge 0x1a479
movq %rax, 0x18(%rsp)
movq 0x38(%rsp), %rax
movl (%rax), %eax
movl %eax, %r12d
shrl $0x14, %r12d
andb $0xf, %r12b
movl %eax, %ebx
shrl $0xc, %ebx
andb $0xf, %bl
shrb $0x4, %al
movl %eax, 0x10(%rsp)
xorl %r15d, %r15d
cmpq 0x8(%r14), %r15
jge 0x1a44a
movq %r13, %rdi
leaq 0x28(%rsp), %rsi
callq 0xe3f2a
movl %eax, %ecx
shrb $0x4, %cl
andb $0xf, %al
cmpb $0x1, %cl
je 0x1a3d0
movzbl %cl, %ecx
cmpl $0x3, %ecx
je 0x1a3c3
cmpl $0x2, %ecx
movq 0x18(%rsp), %rdx
movl 0x10(%rsp), %esi
jne 0x1a3d9
movl %eax, %r12d
jmp 0x1a3fb
movl %eax, %ebx
movq 0x18(%rsp), %rdx
movl 0x10(%rsp), %esi
jmp 0x1a3fb
movl %eax, %esi
movq 0x18(%rsp), %rdx
jmp 0x1a3fb
movzbl %al, %eax
movq 0x38(%rsp), %rcx
movl (%rcx,%rax,4), %esi
movl %esi, %r12d
shrl $0x14, %r12d
andb $0xf, %r12b
movl %esi, %ebx
shrl $0xc, %ebx
andb $0xf, %bl
shrb $0x4, %sil
movl %r12d, %eax
shlb $0x4, %al
orb %r12b, %al
movl %ebx, %ecx
shlb $0x4, %cl
orb %bl, %cl
movl %esi, %edi
shlb $0x4, %dil
movl %esi, 0x10(%rsp)
orb %sil, %dil
movzbl %al, %eax
shll $0x10, %eax
movzbl %cl, %esi
shll $0x8, %esi
orl %eax, %esi
movzbl %dil, %ecx
orl %esi, %ecx
orl $0xff000000, %ecx       # imm = 0xFF000000
movq 0x20(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0xe728c
incq %r15
jmp 0x1a385
movq 0x18(%rsp), %rax
incq %rax
jmp 0x1a352
movq 0x20(%rsp), %r14
movq 0x8(%r14), %rcx
andl $0x0, (%rsp)
pushq $0x8
popq %rdx
movq %r13, %rdi
xorl %esi, %esi
movq 0x38(%rsp), %r8
movq %r14, %r9
callq 0xe7cbc
movq %r13, %rdi
callq 0xe5591
pushq $0x2
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0xe70b7
movq 0x58(%rsp), %rdi
callq 0xe5591
movq %r14, %rdi
callq 0xe7084
movq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0xded32
movl 0x4c(%rsp), %esi
movq %r14, %rdi
callq 0xdebb7
pushq $-0x1
popq %rsi
movq %r14, %rdi
callq 0xdeba7
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq