// File: /workspace/github_c_makefile_star2_O1/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 $0x98, %rsp
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
leaq 0x74(%rsp), %rsi
callq 0xe958c
movl $0x78, %esi
movq %r14, %rdi
callq 0xe969b
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 0x88(%rsp), %rsi
movq %rax, (%rsi)
movq 0x18(%r14), %rdi
callq 0xef193
movl %eax, (%r13)
leaq 0x9989c(%rip), %rsi     # 0x1301fb
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movl (%r13), %eax
cmpl $0x2, %eax
je 0x96990
cmpl $0x1, %eax
je 0x9699a
testl %eax, %eax
jne 0x969d9
movl 0x4(%r15), %eax
cmpl $0x63, %eax
jne 0x969e3
movl $0x64, 0x4(%r13)
jmp 0x969e7
movl $0x66, 0x4(%r13)
jmp 0x969e7
movl 0x8(%r15), %eax
cmpl $0x63, %eax
jne 0x969e3
xorl %eax, %eax
cmpb $0x0, (%r15)
sete %al
leal 0x65(%rax,%rax,8), %eax
leaq 0x99850(%rip), %rcx     # 0x130207
leaq 0x99845(%rip), %rdx     # 0x130203
cmoveq %rcx, %rdx
movl %eax, 0x4(%r13)
leaq 0x9983e(%rip), %rsi     # 0x13020b
movq %r14, %rdi
xorl %eax, %eax
callq 0xe9b27
jmp 0x969e7
movl $0x63, 0x4(%r13)
jmp 0x969e7
movl %eax, 0x4(%r13)
movl 0x4(%r13), %eax
movl $0x4, %ebx
cmpl $0x6d, %eax
jg 0x96a29
cmpl $0x64, %eax
je 0x96a4f
cmpl $0x65, %eax
je 0x96a62
cmpl $0x66, %eax
jne 0x97488
movl $0x1, %eax
movq %rax, 0x50(%rsp)
movb $0x1, %al
movl %eax, 0x8(%rsp)
movl $0x1, %ebx
leaq 0x9985a(%rip), %rdx     # 0x13027e
jmp 0x96ab6
cmpl $0x6e, %eax
je 0x96a7a
cmpl $0x70, %eax
je 0x96a9a
cmpl $0x78, %eax
jne 0x97488
movl $0x2, %eax
movq %rax, 0x50(%rsp)
leaq 0x9980d(%rip), %rdx     # 0x13025a
jmp 0x96a90
movl $0x4, %eax
movq %rax, 0x50(%rsp)
leaq 0x997ea(%rip), %rdx     # 0x13024a
jmp 0x96a90
movl $0x2, %eax
movq %rax, 0x50(%rsp)
movl $0x2, %ebx
leaq 0x997f6(%rip), %rdx     # 0x13026e
jmp 0x96a90
movl $0x4, %eax
movq %rax, 0x50(%rsp)
movl $0x2, %ebx
leaq 0x997ff(%rip), %rdx     # 0x13028f
movl $0x0, 0x8(%rsp)
jmp 0x96ab6
movl $0x1, %eax
movq %rax, 0x50(%rsp)
movb $0x1, %al
movl %eax, 0x8(%rsp)
movl $0x2, %ebx
leaq 0x997ed(%rip), %rdx     # 0x1302a3
leaq 0x9981e(%rip), %rsi     # 0x1302db
movq %r14, %rdi
xorl %eax, %eax
callq 0xe9226
leaq 0x88(%rsp), %rsi
addq $0x4, (%rsi)
movq 0x18(%r14), %rdi
callq 0xef193
movq %rax, 0x8(%r13)
movq %rax, %rcx
shlq $0x4, %rcx
movq %rcx, 0x20(%r13)
movl 0x4(%r13), %edx
cmpl $0x78, %edx
movq %rbx, 0x20(%rsp)
je 0x96b07
cmpl $0x6e, %edx
jne 0x96b0e
movq %rax, %rcx
shlq $0x3, %rcx
jmp 0x96b0e
movq %rax, %rcx
shlq $0x5, %rcx
movq %rcx, 0x30(%r13)
leaq 0x997dd(%rip), %rsi     # 0x1302f6
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%r14), %rdi
movq %r14, 0x10(%rsp)
movq %r13, %r14
leaq 0x88(%rsp), %r13
movq %r13, %rsi
callq 0xef193
movq %rax, 0x10(%r14)
leaq 0x997bd(%rip), %rsi     # 0x13030a
movq 0x10(%rsp), %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
addq $0x2, (%r13)
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
movq %r13, %rsi
callq 0xef193
movq %rax, 0x18(%r14)
leaq 0x997a2(%rip), %rsi     # 0x13031f
movq 0x10(%rsp), %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
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 0x10(%rsp), %rdi
callq 0xe9b05
addq $0x2, (%r13)
movq $0x46, 0x40(%r14)
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
movq %r13, %rsi
callq 0xef34e
movq %rax, 0x50(%r14)
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
movq %r13, %rsi
callq 0xef34e
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 0x99722(%rip), %rsi     # 0x130333
movq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0xe9226
movq 0x58(%r14), %rdx
leaq 0x99718(%rip), %rsi     # 0x130340
movq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0xe9226
movq %r14, 0x80(%rsp)
movq 0x68(%r14), %rdx
leaq 0x99706(%rip), %rsi     # 0x13034d
movq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0xe9226
addq $0x26, %r12
movq %r12, (%r13)
leaq 0x9f546(%rip), %rsi     # 0x1361a8
movq 0x10(%rsp), %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x10(%rsp), %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rsi
movq (%r13), %rdx
movq 0x10(%rsp), %r14
movl $0x0, (%rsp)
movl $0x10, %r8d
movl $0x10, %r9d
movq %r14, %rdi
movq %rbp, 0x38(%rsp)
movq %rbp, %rcx
callq 0xf8c62
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movl $0x3, %r12d
cmpb $0x0, 0x8(%rsp)
je 0x96cfc
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 0x20(%rsp), %rbx
leal (%rbx,%rbx), %eax
movq 0x80(%rsp), %r15
imulq 0x8(%r15), %rax
imulq 0x38(%r15), %rax
movq %rax, 0x70(%r15)
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf0faf
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 0xfc703
movq 0x30(%r15), %rsi
movq 0x38(%r15), %rdx
movq %r14, %rdi
movl %r12d, %ecx
callq 0xf2cab
movq %rax, %r12
movl $0x48, %esi
movq %r14, %rdi
callq 0xe969b
movq %rax, %r13
movl %ebx, 0x4(%rax)
movl %ebx, 0x8(%rax)
movq 0x8(%r15), %rax
movq %rax, 0x30(%rsp)
addq %rax, %rax
movq %rax, 0x10(%r13)
movq 0x10(%r15), %rcx
movq %rcx, 0x18(%r13)
movq 0x18(%r15), %rdx
movq %rdx, 0x20(%r13)
movq 0x28(%r15), %rdx
movq %rdx, 0x8(%rsp)
movq %rdx, 0x28(%r13)
movq %rbp, 0x78(%rsp)
movq %rbp, 0x30(%r13)
movq %r12, 0x90(%rsp)
movq %r12, 0x38(%r13)
movq 0x38(%rsp), %rdx
movq %rdx, 0x40(%r13)
movl 0x4(%r15), %edx
cmpl $0x78, %edx
je 0x96f51
cmpl $0x70, %edx
je 0x970ec
cmpl $0x6e, %edx
movq 0x8(%rsp), %r12
jne 0x9726a
testq %rcx, %rcx
jle 0x973d5
imulq %rax, %r12
movq $0x0, 0x28(%rsp)
movq %r12, 0x8(%rsp)
movq 0x8(%rsp), %r14
movq 0x10(%r13), %rax
testq %rax, %rax
jle 0x96f35
movq %rax, %rcx
movq 0x20(%r13), %rax
imulq %rax, %rcx
movq %rax, %rdx
movq 0x28(%rsp), %rax
imulq %rax, %rdx
movq %rdx, 0x38(%rsp)
imulq %rax, %rcx
movq %rcx, 0x58(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
testb $0x2, %al
jne 0x96f25
movq 0x20(%r13), %r15
testq %r15, %r15
jle 0x96f28
movq %rax, %r12
movq %rcx, 0x18(%rsp)
subq %rcx, %r12
shlq $0x3, %r12
movq %rax, 0x30(%rsp)
imulq %rax, %r15
addq 0x58(%rsp), %r15
xorl %ebp, %ebp
movq $-0x1, %rbx
movq %r15, 0x20(%rsp)
movq 0x30(%r13), %rdi
movq %r15, %rsi
callq 0xef0d5
movb %al, 0x49(%rsp,%rbx)
movq 0x20(%r13), %rax
movq 0x30(%r13), %rdi
leaq (%r15,%rax,2), %rsi
callq 0xef0d5
movb %al, 0x4b(%rsp,%rbx)
addq %r14, %r15
incq %rbx
je 0x96e7d
movq 0x38(%rsp), %rax
leaq (%rax,%rbp), %r15
xorl %ebx, %ebx
movb $0x7, %cl
subb %bl, %cl
movl $0x1, %eax
shll %cl, %eax
xorl %ecx, %ecx
xorl %edx, %edx
movzbl 0x48(%rsp,%rcx), %esi
movl $0x1, %edi
shll %cl, %edi
andl %eax, %esi
testl %esi, %esi
cmovel %esi, %edi
orl %edi, %edx
incq %rcx
cmpq $0x4, %rcx
jne 0x96ec4
leaq (%rbx,%r12), %rsi
movq 0x38(%r13), %rdi
movq 0x40(%r13), %rax
movl %edx, %ecx
movl (%rax,%rcx,4), %ecx
movq %r15, %rdx
callq 0xf2afd
incq %rbx
cmpq $0x8, %rbx
jne 0x96eb5
incq %rbp
movq 0x20(%rsp), %r15
incq %r15
cmpq 0x20(%r13), %rbp
jl 0x96e71
movq 0x30(%rsp), %rax
movq 0x18(%rsp), %rcx
jmp 0x96f28
incq %rcx
incq %rax
cmpq 0x10(%r13), %rax
jl 0x96e3d
movq 0x28(%rsp), %rcx
incq %rcx
movq %rcx, 0x28(%rsp)
cmpq 0x18(%r13), %rcx
jl 0x96e07
jmp 0x973d5
testq %rcx, %rcx
movq 0x8(%rsp), %r14
jle 0x973d5
imulq %rax, %r14
movq $0x0, 0x40(%rsp)
movq %r14, 0x8(%rsp)
movq 0x10(%r13), %rax
testq %rax, %rax
jle 0x970d0
movq %rax, %rcx
movq 0x20(%r13), %rax
imulq %rax, %rcx
movq %rax, %rdx
movq 0x40(%rsp), %rax
imulq %rax, %rdx
movq %rdx, 0x58(%rsp)
imulq %rax, %rcx
movq %rcx, 0x68(%rsp)
movq $0x0, 0x28(%rsp)
movq 0x20(%r13), %r15
testq %r15, %r15
jle 0x970b9
movq 0x28(%rsp), %rcx
movq %rcx, %rax
shlq $0x4, %rax
leaq -0x8(%rax), %rdx
testb $0x1, %cl
cmoveq %rax, %rdx
movq %rdx, 0x38(%rsp)
imulq %rcx, %r15
addq 0x68(%rsp), %r15
xorl %r12d, %r12d
movq %r15, 0x30(%rsp)
xorl %ebx, %ebx
movq 0x30(%r13), %rdi
movq %r15, %rsi
callq 0xef0d5
movb %al, 0x48(%rsp,%rbx)
incq %rbx
addq %r14, %r15
cmpq $0x4, %rbx
jne 0x96fe8
movq 0x58(%rsp), %rax
movq %r12, 0x18(%rsp)
leaq (%r12,%rax), %r15
xorl %edx, %edx
movb $0x7, %cl
subb %dl, %cl
movl $0x1, %r12d
shll %cl, %r12d
movq 0x38(%rsp), %rax
movq %rdx, 0x20(%rsp)
leaq (%rdx,%rax), %rbx
leaq 0x48(%rsp), %r14
xorl %ebp, %ebp
xorl %ecx, %ecx
xorl %eax, %eax
movzbl (%r14,%rcx), %edx
movl $0x1, %esi
shll %cl, %esi
andl %r12d, %edx
testl %edx, %edx
cmovel %edx, %esi
orl %esi, %eax
incq %rcx
cmpq $0x1, %rcx
je 0x9703a
movq %rbp, %rsi
shlq $0x4, %rsi
addq %rbx, %rsi
movq 0x38(%r13), %rdi
movq 0x40(%r13), %rcx
movl %eax, %eax
movl (%rcx,%rax,4), %ecx
movq %r15, %rdx
callq 0xf2afd
leaq 0x1(%rbp), %rax
addq $0x2, %r14
testq %rbp, %rbp
movq %rax, %rbp
je 0x97036
movq 0x20(%rsp), %rdx
incq %rdx
cmpq $0x8, %rdx
jne 0x97014
movq 0x18(%rsp), %r12
incq %r12
movq 0x30(%rsp), %r15
incq %r15
cmpq 0x20(%r13), %r12
movq 0x8(%rsp), %r14
jl 0x96fe1
movq 0x28(%rsp), %rcx
incq %rcx
movq %rcx, 0x28(%rsp)
cmpq 0x10(%r13), %rcx
jl 0x96fac
movq 0x40(%rsp), %rcx
incq %rcx
movq %rcx, 0x40(%rsp)
cmpq 0x18(%r13), %rcx
jl 0x96f71
jmp 0x973d5
testq %rcx, %rcx
jle 0x973d5
movq 0x8(%rsp), %rcx
imulq %rax, %rcx
movq %rcx, 0x8(%rsp)
movq $0x0, 0x60(%rsp)
movq 0x10(%r13), %rax
movq %rax, 0x40(%rsp)
testq %rax, %rax
jle 0x9724e
movq 0x20(%r13), %rdx
imulq 0x60(%rsp), %rdx
movq 0x40(%rsp), %rax
movq %rdx, 0x68(%rsp)
imulq %rdx, %rax
movq %rax, 0x40(%rsp)
xorl %ecx, %ecx
testb $0x1, %cl
jne 0x97241
movq $0x0, 0x18(%rsp)
cmpq 0x30(%rsp), %rcx
setge %al
movq 0x20(%r13), %rdx
testq %rdx, %rdx
jle 0x97241
movq %rdx, %rsi
movq 0x18(%rsp), %rdx
movb %al, %dl
movq %rdx, 0x18(%rsp)
imulq %rcx, %rsi
addq 0x40(%rsp), %rsi
movq %rsi, 0x28(%rsp)
xorl %esi, %esi
movq %rcx, 0x58(%rsp)
movq %rcx, %rbp
cmpq 0x30(%rsp), %rcx
jl 0x9719f
movq %rcx, %rax
cqto
idivq 0x30(%rsp)
movq %rdx, %rbp
movq 0x68(%rsp), %rax
addq %rsi, %rax
movq 0x18(%rsp), %rcx
leaq (%rcx,%rax,2), %r12
shlq $0x4, %rbp
movq 0x28(%rsp), %rax
movq %rsi, 0x38(%rsp)
addq %rsi, %rax
movq %rax, 0x20(%rsp)
xorl %r14d, %r14d
movq 0x30(%r13), %rdi
movl %r14d, %eax
shrl %eax
imulq 0x8(%rsp), %rax
addq 0x20(%rsp), %rax
movl %r14d, %esi
andl $0x1, %esi
imulq 0x20(%r13), %rsi
addq %rax, %rsi
callq 0xef0d5
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 0xf2afd
incq %rbp
addl $-0x1, %r15d
jb 0x971f9
incl %r14d
cmpl $0x4, %r14d
jne 0x971c9
movq 0x38(%rsp), %rsi
incq %rsi
cmpq 0x20(%r13), %rsi
movq 0x58(%rsp), %rcx
jl 0x97188
incq %rcx
cmpq 0x10(%r13), %rcx
jl 0x9713d
movq 0x60(%rsp), %rcx
incq %rcx
movq %rcx, 0x60(%rsp)
cmpq 0x18(%r13), %rcx
jl 0x9710c
jmp 0x973d5
movq $0x0, 0x48(%rsp)
testq %rcx, %rcx
jle 0x973d0
imulq %rax, %r12
movq $0x0, 0x18(%rsp)
movq 0x10(%r13), %rax
testq %rax, %rax
jle 0x973b9
movq %rax, %rcx
movq 0x20(%r13), %rax
imulq %rax, %rcx
movq %rax, %rdx
movq 0x18(%rsp), %rax
imulq %rax, %rdx
movq %rdx, 0x38(%rsp)
imulq %rax, %rcx
movq %rcx, 0x30(%rsp)
movq $0x0, 0x8(%rsp)
movq 0x20(%r13), %rax
testq %rax, %rax
jle 0x973a2
movq %rax, %rcx
movq 0x8(%rsp), %rax
leaq (,%rax,8), %r14
imulq %rax, %rcx
addq 0x30(%rsp), %rcx
movq %rcx, 0x20(%rsp)
xorl %ebp, %ebp
cmpl $0x0, 0x4(%r13)
je 0x9731e
movq 0x20(%rsp), %r15
xorl %ebx, %ebx
movq 0x30(%r13), %rdi
movq %r15, %rsi
callq 0xef0d5
movb %al, 0x48(%rsp,%rbx)
incq %rbx
movl 0x4(%r13), %eax
addq %r12, %r15
cmpq %rax, %rbx
jb 0x972ff
movq %r12, %rbx
movq 0x38(%rsp), %rax
leaq (%rax,%rbp), %r15
xorl %r12d, %r12d
movl 0x8(%r13), %eax
testq %rax, %rax
je 0x9736b
movb $0x7, %cl
subb %r12b, %cl
movl $0x1, %edx
shll %cl, %edx
xorl %ecx, %ecx
xorl %esi, %esi
movzbl 0x48(%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 0x97346
movl %esi, %eax
jmp 0x9736d
xorl %eax, %eax
leaq (%r12,%r14), %rsi
movq 0x38(%r13), %rdi
movq 0x40(%r13), %rcx
movl (%rcx,%rax,4), %ecx
movq %r15, %rdx
callq 0xf2afd
incq %r12
cmpq $0x8, %r12
jne 0x9732d
incq %rbp
incq 0x20(%rsp)
cmpq 0x20(%r13), %rbp
movq %rbx, %r12
jl 0x972f1
movq 0x8(%rsp), %rcx
incq %rcx
movq %rcx, 0x8(%rsp)
cmpq 0x10(%r13), %rcx
jl 0x972c4
movq 0x18(%rsp), %rcx
incq %rcx
movq %rcx, 0x18(%rsp)
cmpq 0x18(%r13), %rcx
jl 0x97289
movb $0x1, (%r13)
movq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0xe9752
movq %r14, %rdi
callq 0xea9a9
movq %rax, %r15
movl $0x40, %esi
movq %r14, %rdi
callq 0xe969b
movq %rax, %r12
movq 0x50(%rsp), %rax
movq %rax, (%r12)
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0xf9323
movq 0x90(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movl $0x2, %edx
callq 0xf2917
movq %rbx, %rdi
movq 0x80(%rsp), %r13
callq 0xf28d4
movq 0x78(%rsp), %rdi
callq 0xf0b13
movq %r14, %rdi
movq %r13, %rsi
callq 0xe9752
movq %r14, %rdi
movq %r12, %rsi
callq 0xe9752
movq %r14, %rdi
movq %r15, %rsi
callq 0xea9b3
movl 0x74(%rsp), %esi
movq %r14, %rdi
callq 0xe9595
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl (%r13), %edx
leaq 0x98e25(%rip), %rsi     # 0x1302b8
movq $0x0, 0x78(%rsp)
movq %r14, %rdi
xorl %eax, %eax
callq 0xe9df7
xorl %edi, %edi
xorl %r12d, %r12d
xorl %r15d, %r15d
jmp 0x9743a