// File: /workspace/github_c_makefile_star2_O1/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 $0x78, %rsp
movq %rcx, %r13
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
leaq 0xf70b7(%rip), %rsi     # 0x110e6b
xorl %ebp, %ebp
xorl %eax, %eax
callq 0xe9226
movq %r14, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%r14), %rdi
movq %r13, %rsi
callq 0xef32a
cmpl $0x31990, %eax          # imm = 0x31990
je 0x19dee
cmpl $0x12030090, %eax       # imm = 0x12030090
je 0x19dee
cmpl $0x12031990, %eax       # imm = 0x12031990
je 0x19dee
movb $0x1, %bpl
testb %bpl, %bpl
jne 0x19fa3
leaq 0xf7115(%rip), %rsi     # 0x110f13
movq %r14, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r14, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x50(%r12), %rdi
leaq 0x4(%r13), %rsi
callq 0xef169
movq %rax, %rbx
movq 0x50(%r12), %rdi
leaq 0x6(%r13), %rsi
callq 0xef169
leaq 0xf70ea(%rip), %rsi     # 0x110f28
movq %r14, %rdi
movl %ebx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe9226
movq 0x50(%r12), %rdi
leaq 0x14(%r13), %rsi
callq 0xef169
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 0xf70bc(%rip), %rsi     # 0x110f42
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq %r14, %rdi
movl $0x1, %esi
callq 0xe9585
movzbl 0x4b4(%r12), %edx
leaq 0xf70a7(%rip), %rsi     # 0x110f56
movq %r14, %rdi
xorl %eax, %eax
callq 0xe9226
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq 0x50(%r12), %rdi
leaq 0x16(%r13), %rsi
callq 0xef169
leaq 0x10b82b(%rip), %rsi    # 0x125706
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x50(%r12), %rdi
leaq 0x18(%r13), %rsi
callq 0xef169
movq %rax, %rbx
leaq 0xf705f(%rip), %rsi     # 0x110f5e
movq %r14, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0xe9226
cmpb $0x0, 0x4b4(%r12)
je 0x19f25
cmpq $0x6, %rbx
jne 0x19f53
movb $0x1, 0x4b6(%r12)
leaq 0x1a(%r13), %rax
movq %rax, 0x68(%r12)
movq $0x5, 0x488(%r12)
movq %r14, %rdi
movq %r12, %rsi
callq 0x1a6a1
movq $0x0, 0x488(%r12)
jmp 0x19f5b
movw $0x101, 0x30(%r12)      # imm = 0x101
cmpb $0x0, 0x31(%r12)
je 0x19f7a
leaq 0xf6fff(%rip), %rsi     # 0x110f69
movq %r14, %rdi
xorl %eax, %eax
callq 0xe9df7
movb $0x0, 0x31(%r12)
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
cmpb $0x0, 0x30(%r12)
jne 0x1a65a
addq $0x5a, %r13
movq 0x18(%r14), %rdi
movq %r13, %rsi
callq 0xef32a
cmpl $0x6071963, %eax        # imm = 0x6071963
jne 0x1a1c4
testb %bpl, %bpl
je 0x19fe0
cmpl $0x0, 0x4(%r15)
jle 0x1a5d5
leaq 0xf6f23(%rip), %rsi     # 0x110ee8
movq %r14, %rdi
xorl %eax, %eax
callq 0xe9b27
leaq 0x70(%r12), %rdi
movl $0x20, %esi
xorl %edx, %edx
callq 0xf41f4
leaq 0x70(%r12), %rax
movq %rax, 0x38(%rsp)
movq $-0x80, %rax
movl 0xf0(%r12,%rax), %ecx
shrl %ecx
andl $0x7f7f7f, %ecx         # imm = 0x7F7F7F
orl $0xff000000, %ecx       # imm = 0xFF000000
movl %ecx, 0x170(%r12,%rax)
addq $0x4, %rax
jne 0x19ff1
leaq 0x64(%rsp), %rsi
movq %r14, %rdi
callq 0xe958c
leaq 0xf6f7d(%rip), %rsi     # 0x110fa6
xorl %ebx, %ebx
movq %r14, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r14, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x50(%r12), %rdi
leaq 0x8(%r13), %rsi
callq 0xef169
movq %rax, %r15
leaq 0xf6f5f(%rip), %rsi     # 0x110fbc
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe9226
movq %r15, 0x8(%rsp)
leaq (,%r15,8), %rax
movq %rax, 0x10(%rsp)
movq 0x50(%r12), %rdi
leaq 0xa(%r13), %rsi
callq 0xef169
movq %rax, %rbp
leaq 0xf6f44(%rip), %rsi     # 0x110fd8
movq %r14, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x50(%r12), %rdi
leaq 0xc(%r13), %rsi
callq 0xef169
movq %rax, %r15
leaq 0xf6f34(%rip), %rsi     # 0x110fec
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe9226
movq %r15, 0x50(%rsp)
movq %rbp, 0x58(%rsp)
imulq %rbp, %r15
movq 0x10(%rsp), %rbp
leaq 0xf6f20(%rip), %rsi     # 0x110fff
movq %r14, %rdi
movl %ebp, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0xe9226
movq 0x50(%r12), %rdi
leaq 0xe(%r13), %rsi
callq 0xef169
movq %rax, 0x480(%r12)
leaq 0xf6f12(%rip), %rsi     # 0x11101d
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x50(%r12), %rdi
leaq 0x10(%r13), %rsi
callq 0xef32a
movq %rax, 0x490(%r12)
leaq (%rax,%r13), %rcx
leaq 0xf6efd(%rip), %rsi     # 0x111035
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
addq %r13, 0x490(%r12)
movq 0x50(%r12), %rdi
leaq 0x14(%r13), %rsi
callq 0xef32a
movq %rax, 0x498(%r12)
leaq (%rax,%r13), %rcx
leaq 0xf6eee(%rip), %rsi     # 0x11105c
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
addq %r13, 0x498(%r12)
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0xf241d
testl %eax, %eax
je 0x1a1ba
movq 0x480(%r12), %rdx
leaq -0x7(%rdx), %rax
cmpq $-0x7, %rax
ja 0x1a1da
leaq 0xf6ed4(%rip), %rsi     # 0x111082
xorl %ebx, %ebx
movq %r14, %rdi
xorl %eax, %eax
callq 0xe9df7
xorl %r15d, %r15d
xorl %ebp, %ebp
jmp 0x1a633
leaq 0xf6cad(%rip), %rsi     # 0x110e78
movq %r14, %rdi
xorl %eax, %eax
callq 0xe9df7
jmp 0x1a65a
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
addq $0x18, %r13
movq %r13, 0x4a0(%r12)
leaq 0xf6ea9(%rip), %rsi     # 0x1110a3
movq %r14, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x8(%rsp), %rsi
imulq %r15, %rsi
imulq 0x480(%r12), %rsi
movq %rsi, 0x4a8(%r12)
movq %r14, %rdi
xorl %edx, %edx
callq 0xf0faf
movq %r15, %r13
movq %rax, %r15
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 %r15, %r9
callq 0xfc703
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movl $0x3, %ecx
callq 0xf2cab
movq %rax, %rbx
movl $0x38, %esi
movq %r14, %rdi
callq 0xe969b
movq %rax, %rbp
movl 0x480(%r12), %eax
movl %eax, 0x4(%rbp)
movl %eax, 0x8(%rbp)
movq 0x8(%rsp), %rax
movq %rax, 0x10(%rbp)
movq 0x58(%rsp), %rax
movq %rax, 0x18(%rbp)
movq 0x50(%rsp), %rax
movq %rax, 0x20(%rbp)
movq %r13, 0x28(%rbp)
movq %r15, 0x30(%rbp)
movq 0x10(%rbx), %rsi
imulq 0x8(%rbx), %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0xf0faf
movq %rax, %r13
movl 0x4(%rbp), %eax
cmpl $0x8, %eax
movq %rbx, 0x40(%rsp)
ja 0x1a487
cmpl %eax, 0x8(%rbp)
jne 0x1a487
movq %r15, 0x20(%rsp)
movq %r12, 0x68(%rsp)
movq %r14, 0x28(%rsp)
movq 0x8(%rbx), %rax
movq %rax, 0x50(%rsp)
movq $0x0, 0x18(%rsp)
cmpq $0x0, 0x18(%rbp)
jle 0x1a46f
movq 0x28(%rbp), %r14
imulq 0x10(%rbp), %r14
movq $0x0, 0x30(%rsp)
movq 0x10(%rbp), %rax
testq %rax, %rax
jle 0x1a458
movq %rax, %rcx
movq 0x20(%rbp), %rax
imulq %rax, %rcx
movq %rax, %rdx
movq 0x30(%rsp), %rax
imulq %rax, %rdx
movq %rdx, 0x58(%rsp)
imulq %rax, %rcx
movq %rcx, 0x70(%rsp)
movq $0x0, 0x48(%rsp)
movq 0x20(%rbp), %rax
testq %rax, %rax
jle 0x1a441
movq %rax, %rcx
movq 0x48(%rsp), %rax
leaq (,%rax,8), %rdx
movq %rdx, 0x8(%rsp)
imulq %rax, %rcx
addq 0x70(%rsp), %rcx
movq %rcx, 0x10(%rsp)
xorl %r12d, %r12d
cmpl $0x0, 0x4(%rbp)
je 0x1a3c7
movq 0x10(%rsp), %rbx
xorl %r15d, %r15d
movq 0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0xef0d5
movb %al, 0x18(%rsp,%r15)
incq %r15
movl 0x4(%rbp), %eax
addq %r14, %rbx
cmpq %rax, %r15
jb 0x1a3a8
movq 0x58(%rsp), %rax
leaq (%r12,%rax), %rbx
imulq 0x50(%rsp), %rbx
addq 0x8(%rsp), %rbx
xorl %r15d, %r15d
movl 0x8(%rbp), %edx
xorl %eax, %eax
testq %rdx, %rdx
je 0x1a417
movb $0x7, %cl
subb %r15b, %cl
movl $0x1, %esi
shll %cl, %esi
xorl %ecx, %ecx
movzbl 0x18(%rsp,%rcx), %edi
movl $0x1, %r8d
shll %cl, %r8d
andl %esi, %edi
testl %edi, %edi
cmovel %edi, %r8d
orl %r8d, %eax
incq %rcx
cmpq %rcx, %rdx
jne 0x1a3f6
leaq (%rbx,%r15), %rsi
movzbl %al, %edx
movq %r13, %rdi
callq 0xf148e
incq %r15
cmpq $0x8, %r15
jne 0x1a3de
incq %r12
incq 0x10(%rsp)
cmpq 0x20(%rbp), %r12
jl 0x1a39a
movq 0x48(%rsp), %rcx
incq %rcx
movq %rcx, 0x48(%rsp)
cmpq 0x10(%rbp), %rcx
jl 0x1a367
movq 0x30(%rsp), %rcx
incq %rcx
movq %rcx, 0x30(%rsp)
cmpq 0x18(%rbp), %rcx
jl 0x1a32c
movb $0x1, (%rbp)
movq 0x28(%rsp), %r14
movq 0x68(%rsp), %r12
movq 0x40(%rsp), %rbx
movq 0x20(%rsp), %r15
cmpb $0x0, 0x4b6(%r12)
je 0x1a5fa
movq %r15, 0x20(%rsp)
movq %r14, 0x28(%rsp)
movq $0x0, 0x18(%rsp)
cmpq $0x0, 0x10(%rbx)
jle 0x1a5c9
movq $0x0, 0x8(%rsp)
movq 0x40(%rsp), %r14
cmpq $0x0, 0x8(%rbx)
jle 0x1a5ad
movq 0x38(%rsp), %rax
movl (%rax), %ecx
movl %ecx, %r12d
shrb $0x4, %r12b
movl %ecx, %r15d
shrl $0xc, %r15d
andb $0xf, %r15b
shrl $0x14, %ecx
andb $0xf, %cl
movl %ecx, 0x10(%rsp)
xorl %ebx, %ebx
movq %r13, %rdi
leaq 0x18(%rsp), %rsi
callq 0xef14d
movl %eax, %ecx
shrb $0x4, %cl
andb $0xf, %al
cmpb $0x1, %cl
je 0x1a52d
movzbl %cl, %ecx
cmpl $0x3, %ecx
je 0x1a522
cmpl $0x2, %ecx
jne 0x1a538
movl %r12d, %esi
movl %r15d, %edx
movl %eax, %ecx
jmp 0x1a557
movl %eax, %edx
movl %r12d, %esi
movl 0x10(%rsp), %ecx
jmp 0x1a557
movl %eax, %esi
movl 0x10(%rsp), %ecx
movl %r15d, %edx
jmp 0x1a557
movzbl %al, %eax
movq 0x38(%rsp), %rcx
movl (%rcx,%rax,4), %esi
movl %esi, %ecx
shrl $0x14, %ecx
andb $0xf, %cl
movl %esi, %edx
shrl $0xc, %edx
andb $0xf, %dl
shrb $0x4, %sil
movl %ecx, %eax
shlb $0x4, %al
movl %ecx, 0x10(%rsp)
orb %cl, %al
movl %edx, %ecx
shlb $0x4, %cl
movl %edx, %r15d
orb %dl, %cl
movl %esi, %edx
shlb $0x4, %dl
movl %esi, %r12d
orb %sil, %dl
movzbl %al, %eax
shll $0x10, %eax
movzbl %cl, %esi
shll $0x8, %esi
orl %eax, %esi
movzbl %dl, %ecx
orl %esi, %ecx
orl $0xff000000, %ecx       # imm = 0xFF000000
movq %r14, %rdi
movq %rbx, %rsi
movq 0x8(%rsp), %rdx
callq 0xf2b02
incq %rbx
cmpq 0x8(%r14), %rbx
jl 0x1a4f2
movq 0x8(%rsp), %rcx
incq %rcx
movq 0x40(%rsp), %rbx
movq %rcx, 0x8(%rsp)
cmpq 0x10(%rbx), %rcx
jl 0x1a4c2
movq 0x28(%rsp), %r14
movq 0x20(%rsp), %r15
jmp 0x1a61c
leaq 0x12a5f4(%rip), %rax    # 0x144bd0
leaq 0xf68d9(%rip), %rdx     # 0x110ebc
cmoveq %rax, %rdx
leaq 0xf68a1(%rip), %rsi     # 0x110e8f
movq %r14, %rdi
xorl %eax, %eax
callq 0xe9b27
jmp 0x1a65a
movq 0x8(%rbx), %rcx
movl $0x0, (%rsp)
movl $0x8, %edx
movq %r13, %rdi
xorl %esi, %esi
movq 0x38(%rsp), %r8
movq %rbx, %r9
callq 0xf35b8
movq %r13, %rdi
callq 0xf0b13
movq %rbx, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0xf2923
movq %r15, %rdi
callq 0xf0b13
movq %rbx, %rdi
callq 0xf28d4
movq %r14, %rdi
movq %rbp, %rsi
callq 0xe9752
movl 0x64(%rsp), %esi
movq %r14, %rdi
callq 0xe9595
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq