// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/mbk.c
// Function: do_pkscreen_bank
static void do_pkscreen_bank(deark *c, lctx *d, i64 pos1)
{
	struct pkpic_ctx *pp = NULL;
	dbuf *unc_pixels = NULL;
	de_bitmap *img = NULL;
	struct atari_img_decode_data *adata = NULL;
	de_finfo *fi = NULL;
	const char *tname = NULL;
	i64 pos;
	UI num_planes;
	UI bits_per_pixel;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);
	pp = de_malloc(c, sizeof(struct pkpic_ctx));
	de_zeromem(d->pal, sizeof(d->pal));

	pos = pos1+4;
	pp->res_code = (UI)de_getu16be_p(&pos);
	de_dbg(c, "res: %u", pp->res_code);

	switch(pp->res_code) {
	case 0:
		if(d->imgtype_of_res0==PKPIC_IMGTYPE_UNKNOWN) {
			pp->imgtype = PKPIC_IMGTYPE_LOW;
		}
		else {
			pp->imgtype = d->imgtype_of_res0;
		}
		break;
	case 1:
		if(d->imgtype_of_res1==PKPIC_IMGTYPE_UNKNOWN) {
			const char *tmps;

			if(d->is_container_fmt) {
				pp->imgtype = PKPIC_IMGTYPE_MED;
				tmps = "l|h";
			}
			else {
				// Unfortunately, a file with res=1 (that couldn't be identified by
				// its extension) seems to be more likely to be the oddball PP1
				// format than the nice standard STOS medium-resolution format.
				pp->imgtype = PKPIC_IMGTYPE_PP1;
				tmps = "m|h";
			}
			de_warn(c, "Ambiguous image. If it looks wrong, try \"-opt stos:res1=<%s>\".", tmps);
		}
		else {
			pp->imgtype = d->imgtype_of_res1;
		}
		break;
	case 2: pp->imgtype = PKPIC_IMGTYPE_HIGH; break;
	default: pp->imgtype = PKPIC_IMGTYPE_UNKNOWN; break;
	}

	switch(pp->imgtype) {
	case PKPIC_IMGTYPE_LOW:
		num_planes = 4;
		bits_per_pixel = 4;
		tname = "4-plane low res";
		break;
	case PKPIC_IMGTYPE_M4P:
		num_planes = 4;
		bits_per_pixel = 2;
		tname = "DAJ 4-plane med res";
		break;
	case PKPIC_IMGTYPE_MED:
		num_planes = 2;
		bits_per_pixel = 2;
		tname = "2-plane med res";
		break;
	case PKPIC_IMGTYPE_HIGH:
		num_planes = 1;
		bits_per_pixel = 1;
		tname = "1-plane high res";
		break;
	case PKPIC_IMGTYPE_PP1:
		num_planes = 2;
		bits_per_pixel = 4;
		tname = "PP1 2-plane low res";
		break;
	case PKPIC_IMGTYPE_PP3:
		num_planes = 2;
		bits_per_pixel = 1;
		tname = "PP3 2-plane high res";
		break;
	default:
		de_err(c, "Unsupported picture resolution: %u", pp->res_code);
		goto done;
	}
	if(tname) {
		de_dbg(c, "interpreted image type: %s", tname);
	}

	pos += 4;
	pp->width_in_words = de_getu16be_p(&pos);
	pp->pseudowidth = pp->width_in_words * 16;
	if(pp->imgtype==PKPIC_IMGTYPE_PP1) {
		pp->w = pp->width_in_words * 8;
	}
	else if(pp->imgtype==PKPIC_IMGTYPE_M4P) {
		pp->w = pp->width_in_words * 32;
	}
	else {
		pp->w = pp->pseudowidth;
	}
	de_dbg(c, "width in words: %"I64_FMT, pp->width_in_words);
	pp->height_in_lumps = de_getu16be_p(&pos);
	de_dbg(c, "height in lumps: %"I64_FMT, pp->height_in_lumps);
	pos += 2; // unknown
	pp->lines_per_lump = de_getu16be_p(&pos);
	de_dbg(c, "lines per lump: %"I64_FMT, pp->lines_per_lump);
	pp->pseudoheight = pp->height_in_lumps * pp->lines_per_lump;
	if(pp->imgtype==PKPIC_IMGTYPE_PP3) {
		pp->h = pp->pseudoheight * 2;
	}
	else {
		pp->h = pp->pseudoheight;
	}
	de_dbg_dimensions(c, pp->w, pp->h);
	pos += 2; // flags
	pp->picdata_rel = 70;
	pp->rledata_rel = de_getu32be_p(&pos);
	pp->pointdata_rel = de_getu32be_p(&pos);
	pp->picdata_abs = pos1 + pp->picdata_rel;
	pp->rledata_abs = pos1 + pp->rledata_rel;
	pp->pointdata_abs = pos1 + pp->pointdata_rel;
	de_dbg(c, "picdata: %"I64_FMT, pp->picdata_abs);
	de_dbg(c, "rledata: %"I64_FMT, pp->rledata_abs);
	de_dbg(c, "pointdata: %"I64_FMT, pp->pointdata_abs);

	pos = pos1+38;
	de_dbg(c, "palette at %"I64_FMT, pos);
	de_dbg_indent(c, 1);
	fmtutil_read_atari_palette(c, c->infile, pos, d->pal, 16, 16, 0);
	de_dbg_indent(c, -1);

	if(bits_per_pixel==1) {
		if((d->pal[0] & 0xffffff)==0) {
			d->pal[0] = DE_STOCKCOLOR_BLACK;
			d->pal[1] = DE_STOCKCOLOR_WHITE;
		}
		else {
			d->pal[0] = DE_STOCKCOLOR_WHITE;
			d->pal[1] = DE_STOCKCOLOR_BLACK;
		}
	}

	pp->unc_image_size = pp->width_in_words*2 * (i64)num_planes * pp->h;

	unc_pixels = dbuf_create_membuf(c, 0, 0);

	fmtutil_decompress_stos_pictbank(c, c->infile, pp->picdata_abs, pp->rledata_abs,
		pp->pointdata_abs, unc_pixels, pp->unc_image_size);

	img = de_bitmap_create(c, pp->w, pp->h, ((bits_per_pixel==1)?1:3));
	render_stos_pictbank1(c, d, pp, unc_pixels, img, num_planes);

	fi = de_finfo_create(c);
	adata = de_malloc(c, sizeof(struct atari_img_decode_data));
	adata->bpp = (i64)bits_per_pixel;
	fmtutil_atari_set_standard_density(c, adata, fi);
	de_bitmap_write_to_file_finfo(img, fi, DE_CREATEFLAG_OPT_IMAGE);

done:
	de_bitmap_destroy(img);
	dbuf_close(unc_pixels);
	if(pp) {
		de_free(c, pp);
	}
	de_free(c, adata);
	de_finfo_destroy(c, fi);
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
leaq 0x94(%rsp), %rsi
callq 0xe8a1c
movl $0x78, %esi
movq %r14, %rdi
callq 0xe8b2b
movq %rax, %r13
leaq 0x2c(%r15), %rbp
movl $0x400, %edx            # imm = 0x400
movq %rbp, %rdi
xorl %esi, %esi
callq 0x18140
leaq 0x4(%r12), %rax
leaq 0xa8(%rsp), %rsi
movq %rax, (%rsi)
movq 0x18(%r14), %rdi
callq 0xeeb91
movl %eax, (%r13)
leaq 0x9a4e9(%rip), %rsi     # 0x1304f4
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movl (%r13), %eax
cmpl $0x2, %eax
je 0x96099
cmpl $0x1, %eax
je 0x96056
testl %eax, %eax
jne 0x960e5
movl 0x4(%r15), %eax
cmpl $0x63, %eax
jne 0x960c2
movl $0x64, 0x4(%r13)
movl $0x4, %eax
movq %rax, 0x38(%rsp)
movl $0x4, %ebx
jmp 0x9614b
movl 0x8(%r15), %eax
cmpl $0x63, %eax
jne 0x960c2
xorl %eax, %eax
cmpb $0x0, (%r15)
sete %al
leal 0x65(%rax,%rax,8), %eax
leaq 0x9a48d(%rip), %rcx     # 0x130500
leaq 0x9a482(%rip), %rdx     # 0x1304fc
cmoveq %rcx, %rdx
movl %eax, 0x4(%r13)
leaq 0x9a47b(%rip), %rsi     # 0x130504
movq %r14, %rdi
xorl %eax, %eax
callq 0xe8faa
movl 0x4(%r13), %eax
jmp 0x960c6
movl $0x66, 0x4(%r13)
movl $0x1, %eax
movq %rax, 0x38(%rsp)
movb $0x1, %al
movl %eax, 0x10(%rsp)
movl $0x1, %ebx
leaq 0x9a4ba(%rip), %rdx     # 0x130577
jmp 0x9618a
movl %eax, 0x4(%r13)
movl $0x4, %ebx
cmpl $0x6d, %eax
jg 0x9611b
cmpl $0x64, %eax
je 0x96141
cmpl $0x65, %eax
je 0x9616c
cmpl $0x66, %eax
je 0x960a1
jmp 0x960ed
movl $0x63, 0x4(%r13)
movl (%r13), %edx
leaq 0x9a4b9(%rip), %rsi     # 0x1305b1
movq $0x0, 0x98(%rsp)
movq %r14, %rdi
xorl %eax, %eax
callq 0xe9295
xorl %edi, %edi
xorl %r12d, %r12d
xorl %r15d, %r15d
jmp 0x96b43
cmpl $0x6e, %eax
je 0x96154
cmpl $0x70, %eax
je 0x96b97
cmpl $0x78, %eax
jne 0x960ed
movl $0x2, %eax
movq %rax, 0x38(%rsp)
leaq 0x9a414(%rip), %rdx     # 0x130553
jmp 0x96182
movl $0x4, %eax
movq %rax, 0x38(%rsp)
leaq 0x9a3f1(%rip), %rdx     # 0x130543
jmp 0x96182
movl $0x4, %eax
movq %rax, 0x38(%rsp)
movl $0x2, %ebx
leaq 0x9a41e(%rip), %rdx     # 0x130588
jmp 0x96182
movl $0x2, %eax
movq %rax, 0x38(%rsp)
movl $0x2, %ebx
leaq 0x9a3e5(%rip), %rdx     # 0x130567
movl $0x0, 0x10(%rsp)
leaq 0x9a443(%rip), %rsi     # 0x1305d4
movq %r14, %rdi
xorl %eax, %eax
callq 0xe8617
leaq 0xa8(%rsp), %rsi
addq $0x4, (%rsi)
movq 0x18(%r14), %rdi
callq 0xeeb91
movq %rax, 0x8(%r13)
movq %rax, %rcx
shlq $0x4, %rcx
movq %rcx, 0x20(%r13)
movl 0x4(%r13), %edx
cmpl $0x78, %edx
movq %rbx, 0x70(%rsp)
je 0x961db
cmpl $0x6e, %edx
jne 0x961e2
movq %rax, %rcx
shlq $0x3, %rcx
jmp 0x961e2
movq %rax, %rcx
shlq $0x5, %rcx
movq %rcx, 0x30(%r13)
leaq 0x9a402(%rip), %rsi     # 0x1305ef
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r14), %rdi
movq %r14, 0x18(%rsp)
movq %r13, %r14
leaq 0xa8(%rsp), %r13
movq %r13, %rsi
callq 0xeeb91
movq %rax, 0x10(%r14)
leaq 0x9a3e2(%rip), %rsi     # 0x130603
movq 0x18(%rsp), %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
addq $0x2, (%r13)
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
movq %r13, %rsi
callq 0xeeb91
movq %rax, 0x18(%r14)
leaq 0x9a3c7(%rip), %rsi     # 0x130618
movq 0x18(%rsp), %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r14), %rdx
imulq 0x10(%r14), %rdx
movq %rdx, 0x28(%r14)
cmpl $0x70, 0x4(%r14)
sete %cl
shlq %cl, %rdx
movq %rdx, 0x38(%r14)
movq 0x30(%r14), %rsi
movq 0x18(%rsp), %rdi
callq 0xe8f88
addq $0x2, (%r13)
movq $0x46, 0x40(%r14)
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
movq %r13, %rsi
callq 0xeed31
movq %rax, 0x50(%r14)
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
movq %r13, %rsi
callq 0xeed31
movq %rax, 0x60(%r14)
movq 0x40(%r14), %rdx
addq %r12, %rdx
movq %rdx, 0x48(%r14)
movq 0x50(%r14), %rcx
addq %r12, %rcx
movq %rcx, 0x58(%r14)
addq %r12, %rax
movq %rax, 0x68(%r14)
leaq 0x9a347(%rip), %rsi     # 0x13062c
movq 0x18(%rsp), %rdi
xorl %eax, %eax
callq 0xe8617
movq 0x58(%r14), %rdx
leaq 0x9a33d(%rip), %rsi     # 0x130639
movq 0x18(%rsp), %rdi
xorl %eax, %eax
callq 0xe8617
movq %r14, 0xa0(%rsp)
movq 0x68(%r14), %rdx
leaq 0x9a32b(%rip), %rsi     # 0x130646
movq 0x18(%rsp), %rdi
xorl %eax, %eax
callq 0xe8617
addq $0x26, %r12
movq %r12, (%r13)
leaq 0xa02b5(%rip), %rsi     # 0x1365eb
movq 0x18(%rsp), %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rsp), %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rsi
movq (%r13), %rdx
movq 0x18(%rsp), %r14
movl $0x0, (%rsp)
movl $0x10, %r8d
movl $0x10, %r9d
movq %r14, %rdi
movq %rbp, 0x30(%rsp)
movq %rbp, %rcx
callq 0xf876e
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movl $0x3, %r12d
cmpb $0x0, 0x10(%rsp)
je 0x963d0
xorl %eax, %eax
xorl %ecx, %ecx
testl $0xffffff, 0x2c(%r15)   # imm = 0xFFFFFF
sete %al
setne %cl
negl %ecx
movl $0xff000000, %edx       # imm = 0xFF000000
orl %edx, %ecx
negl %eax
orl %edx, %eax
movl %ecx, 0x2c(%r15)
movl %eax, 0x30(%r15)
movl $0x1, %r12d
movq 0x70(%rsp), %rbx
leal (%rbx,%rbx), %eax
movq 0xa0(%rsp), %r15
imulq 0x8(%r15), %rax
imulq 0x38(%r15), %rax
movq %rax, 0x70(%r15)
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf09c5
movq %rax, %rbp
movq 0x18(%r14), %rsi
movq 0x48(%r15), %rdx
movq 0x58(%r15), %rcx
movq 0x68(%r15), %r8
movq 0x70(%r15), %rax
movq %rax, (%rsp)
movq %r14, %rdi
movq %rbp, %r9
callq 0xfc144
movq 0x30(%r15), %rsi
movq 0x38(%r15), %rdx
movq %r14, %rdi
movl %r12d, %ecx
callq 0xf266a
movq %rax, %r12
movl $0x48, %esi
movq %r14, %rdi
callq 0xe8b2b
movq %rax, %r13
movl %ebx, 0x4(%rax)
movl %ebx, 0x8(%rax)
movq 0x8(%r15), %rax
movq %rax, 0x28(%rsp)
leaq (%rax,%rax), %rcx
movq %rcx, 0x10(%r13)
movq 0x10(%r15), %rdx
movq %rdx, 0x18(%r13)
movq 0x18(%r15), %rax
movq %rax, 0x20(%r13)
movq 0x28(%r15), %r14
movq %r14, 0x28(%r13)
movq %rbp, 0x98(%rsp)
movq %rbp, 0x30(%r13)
movq %r12, 0xb0(%rsp)
movq %r12, 0x38(%r13)
movq 0x30(%rsp), %rsi
movq %rsi, 0x40(%r13)
movl 0x4(%r15), %esi
cmpl $0x78, %esi
je 0x967fa
cmpl $0x70, %esi
je 0x9668f
cmpl $0x6e, %esi
jne 0x9697f
testq %rdx, %rdx
jle 0x96ade
imulq %rcx, %r14
movq $0x0, 0x88(%rsp)
movq %rcx, %r8
movq %r14, 0x10(%rsp)
movq 0x10(%rsp), %r14
testq %r8, %r8
jle 0x9666e
movq 0x88(%rsp), %rsi
imulq %rax, %rsi
movq %rsi, 0x68(%rsp)
imulq %rsi, %r8
xorl %edx, %edx
xorl %esi, %esi
xorl %edi, %edi
movq %r8, 0x50(%rsp)
testb $0x2, %sil
jne 0x96654
testq %rax, %rax
jle 0x96657
movq %rsi, 0x58(%rsp)
imulq %rsi, %rax
addq %r8, %rax
movq %rax, 0x28(%rsp)
movq %rdi, 0x48(%rsp)
leaq (,%rdi,8), %rax
movq %rdx, 0x60(%rsp)
subq %rax, %rdx
movq %rdx, 0x20(%rsp)
xorl %ebx, %ebx
movq 0x28(%rsp), %rax
movq %rbx, 0x30(%rsp)
addq %rax, %rbx
movb $0x1, %bpl
xorl %r12d, %r12d
movq 0x30(%r13), %rdi
movq %r14, %r15
imulq %r12, %r15
addq %rbx, %r15
movq %r15, %rsi
callq 0xeead3
movb %al, 0x40(%rsp,%r12)
movq 0x20(%r13), %rax
movq 0x30(%r13), %rdi
leaq (%r15,%rax,2), %rsi
callq 0xeead3
movb %al, 0x42(%rsp,%r12)
movl $0x1, %r12d
testb $0x1, %bpl
movl $0x0, %ebp
jne 0x96557
movq 0x68(%rsp), %rax
movq 0x30(%rsp), %rbx
leaq (%rbx,%rax), %r15
movd 0x40(%rsp), %xmm0
pxor %xmm1, %xmm1
punpcklbw %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3],xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
punpcklwd %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
movdqa %xmm0, 0x70(%rsp)
movl $0x8, %r12d
movq 0x20(%rsp), %rbp
decq %r12
movl $0x1, %eax
movl %r12d, %ecx
shll %cl, %eax
movd %eax, %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
pand 0x70(%rsp), %xmm0
pcmpgtd %xmm1, %xmm0
pand 0x99bae(%rip), %xmm0    # 0x1301a0
pshufd $0xee, %xmm0, %xmm1     # xmm1 = xmm0[2,3,2,3]
por %xmm0, %xmm1
pshufd $0x55, %xmm1, %xmm0     # xmm0 = xmm1[1,1,1,1]
por %xmm1, %xmm0
movd %xmm0, %eax
movq 0x38(%r13), %rdi
movq 0x40(%r13), %rcx
movl (%rcx,%rax,4), %ecx
movq %rbp, %rsi
movq %r15, %rdx
callq 0xf24ba
pxor %xmm1, %xmm1
incq %rbp
testq %r12, %r12
jne 0x965ca
incq %rbx
movq 0x20(%r13), %rax
cmpq %rax, %rbx
jl 0x96544
movq 0x10(%r13), %rcx
movq 0x50(%rsp), %r8
movq 0x60(%rsp), %rdx
movq 0x58(%rsp), %rsi
movq 0x48(%rsp), %rdi
jmp 0x96657
incq %rdi
incq %rsi
addq $0x8, %rdx
cmpq %rcx, %rsi
jl 0x96504
movq 0x18(%r13), %rdx
movq %rcx, %r8
movq 0x88(%rsp), %rdi
incq %rdi
movq %rdi, 0x88(%rsp)
cmpq %rdx, %rdi
jl 0x964db
jmp 0x96ade
testq %rdx, %rdx
jle 0x96ade
imulq %rcx, %r14
movq $0x0, 0x50(%rsp)
movq %rcx, %r8
movq %r14, 0x10(%rsp)
testq %r8, %r8
jle 0x967df
movq 0x50(%rsp), %rsi
imulq %rax, %rsi
movq %rsi, 0x58(%rsp)
imulq %rsi, %r8
xorl %esi, %esi
movq %r8, 0x48(%rsp)
testb $0x1, %sil
jne 0x967cc
xorl %edi, %edi
cmpq 0x28(%rsp), %rsi
setge %dl
testq %rax, %rax
jle 0x967cc
movb %dl, %dil
imulq %rsi, %rax
addq %r8, %rax
movq %rax, 0x60(%rsp)
xorl %ecx, %ecx
movq %rsi, 0x20(%rsp)
movq %rdi, 0x68(%rsp)
movq %rsi, %rbp
cmpq 0x28(%rsp), %rsi
jl 0x9671e
movq %rsi, %rax
cqto
idivq 0x28(%rsp)
movq %rdx, %rbp
movq 0x58(%rsp), %rax
addq %rcx, %rax
leaq (%rdi,%rax,2), %r12
shlq $0x4, %rbp
movq 0x60(%rsp), %rax
movq %rcx, 0x30(%rsp)
addq %rcx, %rax
movq %rax, 0x70(%rsp)
xorl %r14d, %r14d
movq 0x30(%r13), %rdi
movl %r14d, %eax
shrl %eax
imulq 0x10(%rsp), %rax
addq 0x70(%rsp), %rax
movl %r14d, %esi
andl $0x1, %esi
imulq 0x20(%r13), %rsi
addq %rax, %rsi
callq 0xeead3
movzbl %al, %ebx
movl $0x7, %r15d
xorl %eax, %eax
btl %r15d, %ebx
setb %al
movq 0x38(%r13), %rdi
movq 0x40(%r13), %rcx
movl (%rcx,%rax,4), %ecx
movq %rbp, %rsi
movq %r12, %rdx
callq 0xf24ba
incq %rbp
addl $-0x1, %r15d
jb 0x96773
incl %r14d
cmpl $0x4, %r14d
jne 0x96743
movq 0x30(%rsp), %rcx
incq %rcx
movq 0x20(%r13), %rax
cmpq %rax, %rcx
movq 0x20(%rsp), %rsi
movq 0x68(%rsp), %rdi
jl 0x96707
movq 0x10(%r13), %rcx
movq 0x48(%rsp), %r8
incq %rsi
cmpq %rcx, %rsi
jl 0x966cf
movq 0x18(%r13), %rdx
movq %rcx, %r8
movq 0x50(%rsp), %rdi
incq %rdi
movq %rdi, 0x50(%rsp)
cmpq %rdx, %rdi
jl 0x966ad
jmp 0x96ade
testq %rdx, %rdx
jle 0x96ade
imulq %rcx, %r14
movq $0x0, 0x48(%rsp)
movq %rcx, %r8
movq %r14, 0x10(%rsp)
testq %r8, %r8
jle 0x96964
movq 0x48(%rsp), %rdx
movq %rdx, %rsi
imulq %rax, %rsi
movq %rsi, 0x68(%rsp)
imulq %rax, %r8
imulq %rdx, %r8
xorl %edx, %edx
movq %r8, 0x58(%rsp)
testq %rax, %rax
jle 0x96951
movq %rdx, %rcx
shlq $0x4, %rcx
leaq -0x8(%rcx), %rsi
testb $0x1, %dl
cmoveq %rcx, %rsi
movq %rsi, 0x30(%rsp)
movq %rdx, 0x60(%rsp)
imulq %rdx, %rax
addq %r8, %rax
movq %rax, %r15
xorl %r12d, %r12d
movq %r15, 0x28(%rsp)
xorl %ebx, %ebx
movq 0x30(%r13), %rdi
movq %r15, %rsi
callq 0xeead3
movb %al, 0x40(%rsp,%rbx)
incq %rbx
addq %r14, %r15
cmpq $0x4, %rbx
jne 0x9687a
movq 0x68(%rsp), %rax
movq %r12, 0x20(%rsp)
leaq (%r12,%rax), %r15
xorl %edx, %edx
movl $0x7, %ebp
subl %edx, %ebp
movl $0x1, %ebx
movl %ebp, %ecx
shll %cl, %ebx
movq 0x30(%rsp), %rax
movq %rdx, 0x70(%rsp)
leaq (%rdx,%rax), %r12
movb $0x1, %r14b
xorl %esi, %esi
movzbl 0x40(%rsp,%rsi,2), %eax
xorl %ecx, %ecx
btl %ebp, %eax
setb %cl
movzbl 0x41(%rsp,%rsi,2), %eax
xorl %edx, %edx
testl %eax, %ebx
setne %dl
shlq $0x4, %rsi
addq %r12, %rsi
movq 0x38(%r13), %rdi
movq 0x40(%r13), %rax
shll $0x2, %ecx
leal (%rcx,%rdx,8), %ecx
movl (%rax,%rcx), %ecx
movq %r15, %rdx
callq 0xf24ba
movl $0x1, %esi
testb $0x1, %r14b
movl $0x0, %r14d
jne 0x968c9
movq 0x70(%rsp), %rdx
incq %rdx
cmpq $0x8, %rdx
jne 0x968a6
movq 0x20(%rsp), %r12
incq %r12
movq 0x20(%r13), %rax
movq 0x28(%rsp), %r15
incq %r15
cmpq %rax, %r12
movq 0x10(%rsp), %r14
jl 0x96873
movq 0x10(%r13), %rcx
movq 0x58(%rsp), %r8
movq 0x60(%rsp), %rdx
incq %rdx
cmpq %rcx, %rdx
jl 0x96841
movq 0x18(%r13), %rdx
movq %rcx, %r8
movq 0x48(%rsp), %rdi
incq %rdi
movq %rdi, 0x48(%rsp)
cmpq %rdx, %rdi
jl 0x96818
jmp 0x96ade
movq $0x0, 0x40(%rsp)
testq %rdx, %rdx
jle 0x96ad9
imulq %rcx, %r14
movq $0x0, 0x20(%rsp)
movq %rcx, %r8
testq %r8, %r8
jle 0x96ac3
movq 0x20(%rsp), %rdx
movq %rdx, %rsi
imulq %rax, %rsi
movq %rsi, 0x30(%rsp)
imulq %rax, %r8
imulq %rdx, %r8
xorl %edx, %edx
movq %r8, 0x28(%rsp)
testq %rax, %rax
jle 0x96ab0
leaq (,%rdx,8), %r12
movq %rdx, 0x10(%rsp)
imulq %rdx, %rax
addq %r8, %rax
movq %rax, 0x70(%rsp)
xorl %ebp, %ebp
cmpl $0x0, 0x4(%r13)
je 0x96a1b
movq 0x70(%rsp), %r15
xorl %ebx, %ebx
movq 0x30(%r13), %rdi
movq %r15, %rsi
callq 0xeead3
movb %al, 0x40(%rsp,%rbx)
incq %rbx
movl 0x4(%r13), %eax
addq %r14, %r15
cmpq %rax, %rbx
jb 0x969fc
movq %r14, %rbx
movq 0x30(%rsp), %rax
leaq (%rax,%rbp), %r15
xorl %r14d, %r14d
movl 0x8(%r13), %eax
testq %rax, %rax
je 0x96a68
movb $0x7, %cl
subb %r14b, %cl
movl $0x1, %edx
shll %cl, %edx
xorl %ecx, %ecx
xorl %esi, %esi
movzbl 0x40(%rsp,%rcx), %edi
movl $0x1, %r8d
shll %cl, %r8d
andl %edx, %edi
testl %edi, %edi
cmovel %edi, %r8d
orl %r8d, %esi
incq %rcx
cmpq %rcx, %rax
jne 0x96a43
movl %esi, %eax
jmp 0x96a6a
xorl %eax, %eax
leaq (%r14,%r12), %rsi
movq 0x38(%r13), %rdi
movq 0x40(%r13), %rcx
movl (%rcx,%rax,4), %ecx
movq %r15, %rdx
callq 0xf24ba
incq %r14
cmpq $0x8, %r14
jne 0x96a2a
incq %rbp
movq 0x20(%r13), %rax
incq 0x70(%rsp)
cmpq %rax, %rbp
movq %rbx, %r14
jl 0x969ee
movq 0x10(%r13), %rcx
movq 0x28(%rsp), %r8
movq 0x10(%rsp), %rdx
incq %rdx
cmpq %rcx, %rdx
jl 0x969ca
movq 0x18(%r13), %rdx
movq %rcx, %r8
movq 0x20(%rsp), %rdi
incq %rdi
movq %rdi, 0x20(%rsp)
cmpq %rdx, %rdi
jl 0x969a1
movb $0x1, (%r13)
movq 0x18(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0xe8be2
movq %r14, %rdi
callq 0xea504
movq %rax, %r15
movl $0x40, %esi
movq %r14, %rdi
callq 0xe8b2b
movq %rax, %r12
movq 0x38(%rsp), %rax
movq %rax, (%r12)
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0xf8e1c
movq 0xb0(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movl $0x2, %edx
callq 0xf22d0
movq %rbx, %rdi
movq 0xa0(%rsp), %r13
callq 0xf228d
movq 0x98(%rsp), %rdi
callq 0xf052b
movq %r14, %rdi
movq %r13, %rsi
callq 0xe8be2
movq %r14, %rdi
movq %r12, %rsi
callq 0xe8be2
movq %r14, %rdi
movq %r15, %rsi
callq 0xea50e
movl 0x94(%rsp), %esi
movq %r14, %rdi
callq 0xe8a25
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %eax
movq %rax, 0x38(%rsp)
movb $0x1, %al
movl %eax, 0x10(%rsp)
movl $0x2, %ebx
leaq 0x999e9(%rip), %rdx     # 0x13059c
jmp 0x9618a