// File: /workspace/github_c_makefile_star2_O3/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, %r15
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xf701d(%rip), %rsi     # 0x110e7a
xorl %eax, %eax
callq 0xe8617
movq %r14, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%r14), %rdi
movq %r13, %rsi
callq 0xeed0d
cmpl $0x1203008f, %eax       # imm = 0x1203008F
jg 0x19ec6
cmpl $0x31990, %eax          # imm = 0x31990
je 0x19ed8
cmpl $0x6071963, %eax        # imm = 0x6071963
jne 0x1a25b
cmpl $0x0, 0x4(%rbx)
jle 0x1a27c
leaq 0xf7050(%rip), %rsi     # 0x110ef7
movq %r14, %rdi
xorl %eax, %eax
callq 0xe8faa
leaq 0x70(%r15), %rdi
movl $0x20, %esi
xorl %edx, %edx
callq 0xf3bdb
jmp 0x1a07d
cmpl $0x12031990, %eax       # imm = 0x12031990
je 0x19ed8
cmpl $0x12030090, %eax       # imm = 0x12030090
jne 0x1a25b
leaq 0xf7043(%rip), %rsi     # 0x110f22
movq %r14, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xe8617
movq %r14, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x50(%r15), %rdi
leaq 0x4(%r13), %rsi
callq 0xeeb67
movq %rax, %rbx
movq 0x50(%r15), %rdi
leaq 0x6(%r13), %rsi
callq 0xeeb67
leaq 0xf701a(%rip), %rsi     # 0x110f37
movq %r14, %rdi
movl %ebx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe8617
movq 0x50(%r15), %rdi
leaq 0x14(%r13), %rsi
callq 0xeeb67
movl %eax, 0x4b0(%r15)
movl %eax, %ecx
shrl $0xb, %ecx
andb $0x1, %cl
movb %cl, 0x4b4(%r15)
movl %eax, %ecx
shrb $0x7, %cl
movb %cl, 0x4b5(%r15)
leaq 0xf6ff0(%rip), %rsi     # 0x110f51
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq %r14, %rdi
movl $0x1, %esi
callq 0xe8a15
movzbl 0x4b4(%r15), %edx
leaq 0xf6fdc(%rip), %rsi     # 0x110f65
movq %r14, %rdi
xorl %eax, %eax
callq 0xe8617
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq 0x50(%r15), %rdi
leaq 0x16(%r13), %rsi
callq 0xeeb67
leaq 0x10b982(%rip), %rsi    # 0x125936
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x50(%r15), %rdi
leaq 0x18(%r13), %rsi
callq 0xeeb67
movq %rax, %rbx
leaq 0xf6f96(%rip), %rsi     # 0x110f6d
movq %r14, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0xe8617
cmpb $0x0, 0x4b4(%r15)
je 0x19ffb
cmpq $0x6, %rbx
jne 0x1a02d
movb $0x1, 0x4b6(%r15)
leaq 0x1a(%r13), %rax
movq %rax, 0x68(%r15)
movq $0x5, 0x488(%r15)
movq %r14, %rdi
movq %r15, %rsi
callq 0x1a745
movq $0x0, 0x488(%r15)
cmpb $0x0, 0x31(%r15)
jne 0x1a034
jmp 0x1a04a
movw $0x101, 0x30(%r15)      # imm = 0x101
leaq 0xf6f3d(%rip), %rsi     # 0x110f78
movq %r14, %rdi
xorl %eax, %eax
callq 0xe9295
movb $0x0, 0x31(%r15)
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
cmpb $0x0, 0x30(%r15)
jne 0x1a6fe
addq $0x5a, %r13
movq 0x18(%r14), %rdi
movq %r13, %rsi
callq 0xeed0d
cmpl $0x6071963, %eax        # imm = 0x6071963
jne 0x1a25b
leaq 0x70(%r15), %rax
movq %rax, 0x30(%rsp)
movq $-0x20, %rax
movdqa 0xf6cdb(%rip), %xmm0    # 0x110d70
movdqa 0xf6ce3(%rip), %xmm1    # 0x110d80
movdqu 0xf0(%r15,%rax,4), %xmm2
psrld $0x1, %xmm2
pand %xmm0, %xmm2
por %xmm1, %xmm2
movdqu %xmm2, 0x170(%r15,%rax,4)
addq $0x4, %rax
jne 0x1a09d
leaq 0x44(%rsp), %rsi
movq %r14, %rdi
callq 0xe8a1c
leaq 0xf6edd(%rip), %rsi     # 0x110fb5
movq %r14, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xe8617
movq %r14, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x50(%r15), %rdi
leaq 0x8(%r13), %rsi
callq 0xeeb67
movq %rax, %rbx
leaq 0xf6ec2(%rip), %rsi     # 0x110fcb
movq %r14, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, 0x8(%rsp)
leaq (,%rbx,8), %rbx
movq 0x50(%r15), %rdi
leaq 0xa(%r13), %rsi
callq 0xeeb67
movq %rax, %r12
leaq 0xf6eae(%rip), %rsi     # 0x110fe7
movq %r14, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x50(%r15), %rdi
leaq 0xc(%r13), %rsi
callq 0xeeb67
movq %rax, %rbp
leaq 0xf6e9e(%rip), %rsi     # 0x110ffb
movq %r14, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbp, 0x18(%rsp)
movq %r12, 0x38(%rsp)
imulq %r12, %rbp
leaq 0xf6e90(%rip), %rsi     # 0x11100e
movq %r14, %rdi
movl %ebx, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0xe8617
movq 0x50(%r15), %rdi
leaq 0xe(%r13), %rsi
callq 0xeeb67
movq %rax, 0x480(%r15)
leaq 0xf6e85(%rip), %rsi     # 0x11102c
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x50(%r15), %rdi
leaq 0x10(%r13), %rsi
callq 0xeed0d
movq %rax, 0x490(%r15)
leaq (%rax,%r13), %rcx
leaq 0xf6e72(%rip), %rsi     # 0x111044
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
addq %r13, 0x490(%r15)
movq 0x50(%r15), %rdi
leaq 0x14(%r13), %rsi
callq 0xeed0d
movq %rax, 0x498(%r15)
leaq (%rax,%r13), %rcx
leaq 0xf6e66(%rip), %rsi     # 0x11106b
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
addq %r13, 0x498(%r15)
movq %r14, %rdi
movq %rbx, %rsi
movq %rbp, %r12
movq %rbp, %rdx
callq 0xf1db1
testl %eax, %eax
je 0x1a271
movq 0x480(%r15), %rdx
leaq -0x7(%rdx), %rax
cmpq $-0x7, %rax
ja 0x1a2a4
leaq 0xf6e4b(%rip), %rsi     # 0x111091
xorl %ebx, %ebx
movq %r14, %rdi
xorl %eax, %eax
callq 0xe9295
xorl %edi, %edi
xorl %ebp, %ebp
jmp 0x1a6da
leaq 0xf6c25(%rip), %rsi     # 0x110e87
movq %r14, %rdi
xorl %eax, %eax
callq 0xe9295
jmp 0x1a6fe
xorl %edi, %edi
xorl %ebp, %ebp
xorl %ebx, %ebx
jmp 0x1a6da
leaq 0x12ae2d(%rip), %rax    # 0x1450b0
leaq 0xf6c41(%rip), %rdx     # 0x110ecb
cmoveq %rax, %rdx
leaq 0xf6c09(%rip), %rsi     # 0x110e9e
movq %r14, %rdi
xorl %eax, %eax
callq 0xe8faa
jmp 0x1a6fe
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
addq $0x18, %r13
movq %r13, 0x4a0(%r15)
leaq 0xf6def(%rip), %rsi     # 0x1110b2
movq %r14, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x8(%rsp), %rsi
movq %r12, %r13
imulq %r12, %rsi
imulq 0x480(%r15), %rsi
movq %rsi, 0x4a8(%r15)
movq %r14, %rdi
xorl %edx, %edx
callq 0xf09c5
movq %rax, %r12
movq 0x18(%r14), %rsi
movq 0x4a0(%r15), %rdx
movq 0x490(%r15), %rcx
movq 0x498(%r15), %r8
movq 0x4a8(%r15), %rax
movq %rax, (%rsp)
movq %r14, %rdi
movq %r12, %r9
callq 0xfc144
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movl $0x3, %ecx
callq 0xf266a
movq %rax, %rbx
movl $0x38, %esi
movq %r14, %rdi
callq 0xe8b2b
movq %rax, %rbp
movq %r15, 0x58(%rsp)
movl 0x480(%r15), %eax
movl %eax, 0x4(%rbp)
movl %eax, 0x8(%rbp)
movq 0x8(%rsp), %rax
movq %rax, 0x10(%rbp)
movq 0x38(%rsp), %rax
movq %rax, 0x18(%rbp)
movq 0x18(%rsp), %rax
movq %rax, 0x20(%rbp)
movq %r13, 0x28(%rbp)
movq %r12, 0x50(%rsp)
movq %r12, 0x30(%rbp)
movq 0x10(%rbx), %rsi
movq %rbx, 0x10(%rsp)
imulq 0x8(%rbx), %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0xf09c5
movq %rax, %r13
movl 0x4(%rbp), %eax
cmpl $0x8, %eax
movq %r14, 0x48(%rsp)
ja 0x1a53c
cmpl %eax, 0x8(%rbp)
jne 0x1a53c
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x70(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x18(%rbp), %rdx
testq %rdx, %rdx
jle 0x1a533
movq 0x10(%rbp), %rcx
movq 0x28(%rbp), %r14
imulq %rcx, %r14
movq 0x20(%rbp), %rax
movq $0x0, 0x28(%rsp)
movq %rcx, %r8
testq %r8, %r8
jle 0x1a51d
movq 0x28(%rsp), %rdx
movq %rdx, %rsi
imulq %rax, %rsi
movq %rsi, 0x38(%rsp)
imulq %rax, %r8
imulq %rdx, %r8
xorl %edx, %edx
movq %r8, 0x60(%rsp)
testq %rax, %rax
jle 0x1a50a
leaq (,%rdx,8), %rcx
movq %rcx, 0x18(%rsp)
movq %rdx, 0x68(%rsp)
imulq %rdx, %rax
addq %r8, %rax
movq %rax, 0x8(%rsp)
xorl %r15d, %r15d
cmpl $0x0, 0x4(%rbp)
je 0x1a47f
movq 0x8(%rsp), %rbx
xorl %r12d, %r12d
movq 0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0xeead3
movb %al, 0x20(%rsp,%r12)
incq %r12
movl 0x4(%rbp), %eax
addq %r14, %rbx
cmpq %rax, %r12
jb 0x1a460
movq 0x38(%rsp), %rax
leaq (%r15,%rax), %rbx
imulq 0x70(%rsp), %rbx
addq 0x18(%rsp), %rbx
xorl %r12d, %r12d
movl 0x8(%rbp), %edx
xorl %eax, %eax
testq %rdx, %rdx
je 0x1a4cf
movb $0x7, %cl
subb %r12b, %cl
movl $0x1, %esi
shll %cl, %esi
xorl %ecx, %ecx
movzbl 0x20(%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 0x1a4ae
leaq (%rbx,%r12), %rsi
movzbl %al, %edx
movq %r13, %rdi
callq 0xf0e8b
incq %r12
cmpq $0x8, %r12
jne 0x1a496
incq %r15
movq 0x20(%rbp), %rax
incq 0x8(%rsp)
cmpq %rax, %r15
jl 0x1a452
movq 0x10(%rbp), %rcx
movq 0x60(%rsp), %r8
movq 0x68(%rsp), %rdx
incq %rdx
cmpq %rcx, %rdx
jl 0x1a428
movq 0x18(%rbp), %rdx
movq %rcx, %r8
movq 0x28(%rsp), %rdi
incq %rdi
movq %rdi, 0x28(%rsp)
cmpq %rdx, %rdi
jl 0x1a3ff
movb $0x1, (%rbp)
movq 0x48(%rsp), %r14
movq 0x58(%rsp), %rax
cmpb $0x0, 0x4b6(%rax)
je 0x1a697
movq $0x0, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rcx
testq %rcx, %rcx
jle 0x1a690
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movq $0x0, 0x18(%rsp)
testq %rax, %rax
jle 0x1a67a
movq 0x30(%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, 0x8(%rsp)
xorl %ebx, %ebx
movq %r13, %rdi
leaq 0x20(%rsp), %rsi
callq 0xeeb4b
movl %eax, %ecx
shrb $0x4, %cl
andb $0xf, %al
cmpb $0x1, %cl
je 0x1a5e4
movzbl %cl, %ecx
cmpl $0x3, %ecx
je 0x1a5d9
cmpl $0x2, %ecx
jne 0x1a5ef
movl %r12d, %esi
movl %r15d, %edx
movl %eax, %ecx
jmp 0x1a60e
movl %eax, %edx
movl %r12d, %esi
movl 0x8(%rsp), %ecx
jmp 0x1a60e
movl %eax, %esi
movl 0x8(%rsp), %ecx
movl %r15d, %edx
jmp 0x1a60e
movzbl %al, %eax
movq 0x30(%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, 0x8(%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 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq 0x18(%rsp), %rdx
callq 0xf24bf
incq %rbx
movq 0x8(%r14), %rax
cmpq %rax, %rbx
jl 0x1a5a9
movq 0x10(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0x48(%rsp), %r14
movq 0x18(%rsp), %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
cmpq %rcx, %rsi
jl 0x1a57b
movq 0x10(%rsp), %rbx
jmp 0x1a6be
movq 0x10(%rsp), %rbx
movq 0x8(%rbx), %rcx
movl $0x0, (%rsp)
movl $0x8, %edx
movq %r13, %rdi
xorl %esi, %esi
movq 0x30(%rsp), %r8
movq %rbx, %r9
callq 0xf2f79
movq %r13, %rdi
callq 0xf052b
movq %rbx, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0xf22dc
movq 0x50(%rsp), %rdi
callq 0xf052b
movq %rbx, %rdi
callq 0xf228d
movq %r14, %rdi
movq %rbp, %rsi
callq 0xe8be2
movl 0x44(%rsp), %esi
movq %r14, %rdi
callq 0xe8a25
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq