// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/palmbitmap.c
// Function: do_palm_BitmapType_internal
static void do_palm_BitmapType_internal(deark *c, lctx *d, i64 pos1, i64 len,
	i64 *pnextbitmapoffset)
{
	i64 x;
	i64 pos;
	u32 bitmapflags;
	u8 pixelsize_raw;
	u8 pixelformat = 0; // V3 only
	i64 headersize;
	i64 needed_rowbytes;
	i64 bytes_consumed;
	i64 nextbitmapoffs_in_bytes = 0;
	const char *cmpr_type_src_name = "";
	const char *bpp_src_name = "";
	struct page_ctx *pg = NULL;
	int saved_indent_level;
	de_ucstring *flagsdescr;
	char tmps[80];

	de_dbg_indent_save(c, &saved_indent_level);
	pg = de_malloc(c, sizeof(struct page_ctx));

	de_dbg(c, "BitmapType at %"I64_FMT, pos1);
	de_dbg_indent(c, 1);
	de_dbg(c, "bitmap header at %"I64_FMT, pos1);
	de_dbg_indent(c, 1);

	// Look ahead to get the version
	pg->bitmapversion = de_getbyte(pos1+9);
	de_dbg(c, "bitmap version: %d", (int)pg->bitmapversion);

	if(pg->bitmapversion>3) {
		// Note that V3 allows the high bit of the version field to
		// be set (to mean little-endian), but we don't support that.
		de_err(c, "Unsupported bitmap version: %d", (int)pg->bitmapversion);
		goto done;
	}

	pg->w = dbuf_geti16x(c->infile, pos1, d->is_le);
	pg->h =  dbuf_geti16x(c->infile, pos1+2, d->is_le);
	de_dbg_dimensions(c, pg->w, pg->h);

	pg->rowbytes = dbuf_getu16x(c->infile, pos1+4, d->is_le);
	de_dbg(c, "rowBytes: %d", (int)pg->rowbytes);

	bitmapflags = (u32)dbuf_getu16x(c->infile, pos1+6, d->is_le);
	flagsdescr = ucstring_create(c);
	if(bitmapflags&PALMBMPFLAG_COMPRESSED) ucstring_append_flags_item(flagsdescr, "compressed");
	if(bitmapflags&PALMBMPFLAG_HASCOLORTABLE) ucstring_append_flags_item(flagsdescr, "hasColorTable");
	if(bitmapflags&PALMBMPFLAG_HASTRNS) ucstring_append_flags_item(flagsdescr, "hasTransparency");
	if(bitmapflags&PALMBMPFLAG_DIRECTCOLOR) ucstring_append_flags_item(flagsdescr, "directColor");
	if(bitmapflags==0) ucstring_append_flags_item(flagsdescr, "none");
	de_dbg(c, "bitmap flags: 0x%04x (%s)", (unsigned int)bitmapflags,
		ucstring_getpsz(flagsdescr));
	ucstring_destroy(flagsdescr);
	if((bitmapflags&PALMBMPFLAG_HASCOLORTABLE) && d->ignore_color_table_flag) {
		bitmapflags -= PALMBMPFLAG_HASCOLORTABLE;
	}
	if((bitmapflags&PALMBMPFLAG_HASCOLORTABLE) && pg->bitmapversion<1) {
		de_warn(c, "BitmapTypeV%d with a color table is not standard", (int)pg->bitmapversion);
	}

	if(pg->bitmapversion>=1) {
		pixelsize_raw = de_getbyte(pos1+8);
		de_dbg(c, "pixelSize: %d", (int)pixelsize_raw);
		bpp_src_name = "based on pixelSize field";
		if(pg->bitmapversion<2 && pixelsize_raw==8) {
			de_warn(c, "BitmapTypeV%d with pixelSize=%d is not standard",
				(int)pg->bitmapversion, (int)pixelsize_raw);
		}
	}
	else {
		pixelsize_raw = 0;
	}
	if(pixelsize_raw==0) {
		pg->bitsperpixel = 1;
		bpp_src_name = "default";
	}
	else pg->bitsperpixel = (i64)pixelsize_raw;
	de_dbg(c, "bits/pixel: %d (%s)", (int)pg->bitsperpixel, bpp_src_name);

	if(pg->bitmapversion==1 || pg->bitmapversion==2) {
		x = dbuf_getu16x(c->infile, pos1+10, d->is_le);
		nextbitmapoffs_in_bytes = 4*x;
		if(x==0) {
			de_snprintf(tmps, sizeof(tmps), "none");
		}
		else {
			de_snprintf(tmps, sizeof(tmps), "%d + 4"DE_CHAR_TIMES"%d = %d", (int)pos1, (int)x, (int)(pos1+nextbitmapoffs_in_bytes));
		}
		de_dbg(c, "nextDepthOffset: %d (%s)", (int)x, tmps);
	}

	if(pg->bitmapversion<3) {
		headersize = 16;
	}
	else {
		headersize = (i64)de_getbyte(pos1+10);
		de_dbg(c, "header size: %d", (int)headersize);
	}

	if(pg->bitmapversion==3) {
		pixelformat = de_getbyte(pos1+11);
		de_dbg(c, "pixel format: %d", (int)pixelformat);
	}

	if(pg->bitmapversion==2 && (bitmapflags&PALMBMPFLAG_HASTRNS)) {
		pg->has_trns = 1;
		pg->trns_value = (u32)de_getbyte(pos1+12);
		de_dbg(c, "transparent color: %u", (unsigned int)pg->trns_value);
	}

	cmpr_type_src_name = "flags";
	if(bitmapflags&PALMBMPFLAG_COMPRESSED) {
		if(pg->bitmapversion>=2) {
			pg->cmpr_type_field = (unsigned int)de_getbyte(pos1+13);
			cmpr_type_src_name = "flags + compression type field";
			de_dbg(c, "compression type field: 0x%02x", pg->cmpr_type_field);
			switch(pg->cmpr_type_field) {
			case CMPR_FIELD_SCANLINE:
				pg->cmpr_type = PCMPR_SCANLINE;
				break;
			case CMPR_FIELD_RLE:
				pg->cmpr_type = PCMPR_RLE;
				break;
			case CMPR_FIELD_PACKBITS:
				cmpr_type_src_name = "flags + compression type field + pixelSize";
				if(pg->bitsperpixel==16) {
					pg->cmpr_type = PCMPR_PACKBITS16;
				}
				else {
					pg->cmpr_type = PCMPR_PACKBITS8;
				}
				break;
			default:
				pg->cmpr_type = PCMPR_UNKNOWN;
			}
		}
		else {
			// V1 & V2 have no cmpr_type field, but can still be compressed.
			pg->cmpr_type = PCMPR_SCANLINE;
		}
	}
	else {
		pg->cmpr_type = PCMPR_NONE;
	}

	de_dbg(c, "compression type: %s (based on %s)", get_cmpr_type_name(pg->cmpr_type), cmpr_type_src_name);

	if(pg->bitmapversion==3) {
		i64 densitycode;
		densitycode = dbuf_getu16x(c->infile, pos1+14, d->is_le);
		de_dbg(c, "density: %d", (int)densitycode);
		// The density is an indication of the target screen density.
		// It's tempting to interpret it as pixels per inch, and copy it to the
		// output image -- though the documentation says it "should not be
		// interpreted as representing pixels per inch".
	}

	if(pg->bitmapversion==3 && (bitmapflags&PALMBMPFLAG_HASTRNS) && headersize>=20) {
		// I'm assuming the flag affects this field. The spec is ambiguous.
		pg->has_trns = 1;
		pg->trns_value = (u32)dbuf_getu32x(c->infile, pos1+16, d->is_le);
		de_dbg(c, "transparent color: 0x%08x", (unsigned int)pg->trns_value);
	}

	if(pg->bitmapversion==3 && headersize>=24) {
		// Documented as the "number of bytes to the next bitmap", but it doesn't
		// say where it is measured *from*. I'll assume it's the same logic as
		// the "nextDepthOffset" field.
		nextbitmapoffs_in_bytes = dbuf_getu32x(c->infile, pos1+20, d->is_le);
		if(nextbitmapoffs_in_bytes==0) {
			de_snprintf(tmps, sizeof(tmps), "none");
		}
		else {
			de_snprintf(tmps, sizeof(tmps), "%u + %u = %u", (unsigned int)pos1,
				(unsigned int)nextbitmapoffs_in_bytes, (unsigned int)(pos1+nextbitmapoffs_in_bytes));
		}
		de_dbg(c, "nextBitmapOffset: %u (%s)", (unsigned int)nextbitmapoffs_in_bytes, tmps);
	}

	// Now that we've read the nextBitmapOffset fields, we can stop processing this
	// image if it's invalid or unsupported.

	needed_rowbytes = (pg->w * pg->bitsperpixel +7)/8;
	if(pg->rowbytes < needed_rowbytes) {
		de_err(c, "Bad rowBytes value (is %d, need at least %d) or unsupported format version",
			(int)pg->rowbytes, (int)needed_rowbytes);
		goto done;
	}

	if(!de_good_image_dimensions(c, pg->w, pg->h)) goto done;

	de_dbg_indent(c, -1);

	if(bitmapflags&PALMBMPFLAG_DIRECTCOLOR) {
		pg->is_rgb = 1;
		if(pg->bitmapversion<2) {
			de_warn(c, "BitmapTypeV%d with RGB color is not standard", (int)pg->bitmapversion);
		}
	}

	if(pg->bitmapversion>=3) {
		if(pixelformat>1 ||
			(pixelformat==0 && pg->bitsperpixel>8) ||
			(pixelformat==1 && pg->bitsperpixel!=16))
		{
			de_err(c, "Unsupported pixelFormat (%d) for this image", (int)pixelformat);
			goto done;
		}

		if(pixelformat==1 && pg->bitsperpixel==16) {
			// This should have already been set, by PALMBMPFLAG_DIRECTCOLOR,
			// but that flag seems kind of obsolete in V3.
			pg->is_rgb = 1;
		}
	}

	if(pg->bitmapversion==2 && pg->bitsperpixel==16 &&
		!(bitmapflags&PALMBMPFLAG_DIRECTCOLOR) && !(bitmapflags&PALMBMPFLAG_HASCOLORTABLE))
	{
		// I have some images like this. I guess they are standard RGB565, with no
		// BitmapDirectInfoType header.
		pg->is_rgb = 1;
		de_warn(c, "This type of image (16-bit, without directColor flag) might "
			"not be decoded correctly");
	}

	if(pg->bitsperpixel!=1 && pg->bitsperpixel!=2 && pg->bitsperpixel!=4 &&
		pg->bitsperpixel!=8 && pg->bitsperpixel!=16)
	{
		de_err(c, "Unsupported bits/pixel: %d", (int)pg->bitsperpixel);
		goto done;
	}

	if((pg->is_rgb && pg->bitsperpixel!=16) ||
		(!pg->is_rgb && pg->bitsperpixel>8))
	{
		de_err(c, "This type of image is not supported");
		goto done;
	}

	pos = pos1;
	pos += headersize;
	if(pos >= pos1+len) goto done;

	if(bitmapflags&PALMBMPFLAG_HASCOLORTABLE) {
		if(!read_BitmapType_colortable(c, d, pg, pos, &bytes_consumed)) goto done;
		pos += bytes_consumed;
	}

	// If there is both a color table and a DirectInfo struct, I don't know which
	// one appears first. But that shouldn't happen.
	if((bitmapflags&PALMBMPFLAG_DIRECTCOLOR) && (pg->bitmapversion<=2)) {
		do_BitmapDirectInfoType(c, d, pg, pos);
		pos += 8;
	}

	if(pos >= pos1+len) {
		de_err(c, "Unexpected end of file");
		goto done;
	}

	if(nextbitmapoffs_in_bytes>0) {
		pg->endpos = pos1 + nextbitmapoffs_in_bytes;
	}
	else {
		pg->endpos = c->infile->len;
	}

	de_dbg(c, "image data at %d", (int)pos);
	de_dbg_indent(c, 1);
	do_generate_image(c, d, pg, c->infile, pos, pg->endpos-pos);
	de_dbg_indent(c, -1);

done:
	*pnextbitmapoffset = nextbitmapoffs_in_bytes;
	de_dbg_indent_restore(c, saved_indent_level);
	if(pg) {
		de_free(c, pg);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movb $0x0, -0x3e(%rbp)
movq $0x0, -0x60(%rbp)
leaq 0xd40ee(%rip), %rax     # 0x1d0bd0
movq %rax, -0x68(%rbp)
leaq 0xd40e3(%rip), %rax     # 0x1d0bd0
movq %rax, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x7c(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
movl $0x450, %esi            # imm = 0x450
callq 0x15b780
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0xc3e09(%rip), %rsi     # 0x1c0930
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0xc07a8(%rip), %rsi     # 0x1bd2f3
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x9, %rsi
callq 0x165060
movb %al, %cl
movq -0x78(%rbp), %rax
movb %cl, 0x2c(%rax)
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %edx
leaq 0xc3dbd(%rip), %rsi     # 0x1c094e
movb $0x0, %al
callq 0x15b0d0
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x3, %eax
jle 0xfcbc4
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %edx
leaq 0xc3d8a(%rip), %rsi     # 0x1c0942
movb $0x0, %al
callq 0x15bfb0
jmp 0xfd65a
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rax
movl (%rax), %edx
callq 0x165870
movq %rax, %rcx
movq -0x78(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x2, %rsi
movq -0x10(%rbp), %rax
movl (%rax), %edx
callq 0x165870
movq %rax, %rcx
movq -0x78(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rax
movq (%rax), %rsi
movq -0x78(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x15bba0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x4, %rsi
movq -0x10(%rbp), %rax
movl (%rax), %edx
callq 0x165820
movq %rax, %rcx
movq -0x78(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %edx
leaq 0xc3d03(%rip), %rsi     # 0x1c0961
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x6, %rsi
movq -0x10(%rbp), %rax
movl (%rax), %edx
callq 0x165820
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, -0x88(%rbp)
movl -0x3c(%rbp), %eax
andl $0x8000, %eax           # imm = 0x8000
cmpl $0x0, %eax
je 0xfccb3
movq -0x88(%rbp), %rdi
leaq 0xb1880(%rip), %rsi     # 0x1ae52e
callq 0x172680
movl -0x3c(%rbp), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0xfccd3
movq -0x88(%rbp), %rdi
leaq 0xc3ca0(%rip), %rsi     # 0x1c096e
callq 0x172680
movl -0x3c(%rbp), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0xfccf3
movq -0x88(%rbp), %rdi
leaq 0xc3c8e(%rip), %rsi     # 0x1c097c
callq 0x172680
movl -0x3c(%rbp), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0xfcd13
movq -0x88(%rbp), %rdi
leaq 0xc3c7e(%rip), %rsi     # 0x1c098c
callq 0x172680
cmpl $0x0, -0x3c(%rbp)
jne 0xfcd2c
movq -0x88(%rbp), %rdi
leaq 0x9f9e6(%rip), %rsi     # 0x19c70d
callq 0x172680
movq -0x8(%rbp), %rax
movq %rax, -0xf8(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0xec(%rbp)
movq -0x88(%rbp), %rdi
callq 0x172500
movq -0xf8(%rbp), %rdi
movl -0xec(%rbp), %edx
movq %rax, %rcx
leaq 0xc3c35(%rip), %rsi     # 0x1c0998
movb $0x0, %al
callq 0x15b0d0
movq -0x88(%rbp), %rdi
callq 0x171750
movl -0x3c(%rbp), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0xfcd98
movq -0x10(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0xfcd98
movl -0x3c(%rbp), %eax
subl $0x4000, %eax           # imm = 0x4000
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0xfcdcc
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x1, %eax
jge 0xfcdcc
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %edx
leaq 0xc3bed(%rip), %rsi     # 0x1c09b2
movb $0x0, %al
callq 0x15bc10
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x1, %eax
jl 0xfce48
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x8, %rsi
callq 0x165060
movb %al, -0x3d(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x3d(%rbp), %edx
leaq 0xc3be3(%rip), %rsi     # 0x1c09e3
movb $0x0, %al
callq 0x15b0d0
leaq 0xc3be3(%rip), %rax     # 0x1c09f1
movq %rax, -0x70(%rbp)
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x2, %eax
jge 0xfce46
movzbl -0x3d(%rbp), %eax
cmpl $0x8, %eax
jne 0xfce46
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %edx
movzbl -0x3d(%rbp), %ecx
leaq 0xc3bcb(%rip), %rsi     # 0x1c0a0a
movb $0x0, %al
callq 0x15bc10
jmp 0xfce4c
movb $0x0, -0x3d(%rbp)
movzbl -0x3d(%rbp), %eax
cmpl $0x0, %eax
jne 0xfce6e
movq -0x78(%rbp), %rax
movq $0x1, 0x10(%rax)
leaq 0xbb41c(%rip), %rax     # 0x1b8284
movq %rax, -0x70(%rbp)
jmp 0xfce7c
movzbl -0x3d(%rbp), %eax
movl %eax, %ecx
movq -0x78(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, %edx
movq -0x70(%rbp), %rcx
leaq 0xc3ba5(%rip), %rsi     # 0x1c0a3a
movb $0x0, %al
callq 0x15b0d0
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x1, %eax
je 0xfceba
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x2, %eax
jne 0xfcf59
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0xa, %rsi
movq -0x10(%rbp), %rax
movl (%rax), %edx
callq 0x165820
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
shlq $0x2, %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0xfcf08
leaq -0xe0(%rbp), %rdi
movl $0x50, %esi
leaq 0x9f80e(%rip), %rdx     # 0x19c70d
movb $0x0, %al
callq 0x15a980
jmp 0xfcf3a
leaq -0xe0(%rbp), %rdi
movq -0x18(%rbp), %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %eax, %r8d
movq -0x18(%rbp), %rax
addq -0x60(%rbp), %rax
movl %eax, %r9d
movl $0x50, %esi
leaq 0xc3b1b(%rip), %rdx     # 0x1c0a4e
movb $0x0, %al
callq 0x15a980
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %eax, %edx
leaq -0xe0(%rbp), %rcx
leaq 0xc3b0c(%rip), %rsi     # 0x1c0a5e
movb $0x0, %al
callq 0x15b0d0
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x3, %eax
jge 0xfcf70
movq $0x10, -0x48(%rbp)
jmp 0xfcfa4
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0xa, %rsi
callq 0x165060
movzbl %al, %eax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rax
movl %eax, %edx
leaq 0xb6171(%rip), %rsi     # 0x1b310e
movb $0x0, %al
callq 0x15b0d0
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x3, %eax
jne 0xfcfdf
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0xb, %rsi
callq 0x165060
movb %al, -0x3e(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x3e(%rbp), %edx
leaq 0xa759f(%rip), %rsi     # 0x1a4577
movb $0x0, %al
callq 0x15b0d0
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x2, %eax
jne 0xfd03c
movl -0x3c(%rbp), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0xfd03c
movq -0x78(%rbp), %rax
movl $0x1, 0x20(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0xc, %rsi
callq 0x165060
movzbl %al, %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x24(%rax)
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rax
movl 0x24(%rax), %edx
leaq 0xc3a42(%rip), %rsi     # 0x1c0a77
movb $0x0, %al
callq 0x15b0d0
leaq 0xc1b17(%rip), %rax     # 0x1beb5a
movq %rax, -0x68(%rbp)
movl -0x3c(%rbp), %eax
andl $0x8000, %eax           # imm = 0x8000
cmpl $0x0, %eax
je 0xfd13d
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x2, %eax
jl 0xfd130
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0xd, %rsi
callq 0x165060
movzbl %al, %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x34(%rax)
leaq 0xc39fe(%rip), %rax     # 0x1c0a8d
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rax
movl 0x34(%rax), %edx
leaq 0xc3a07(%rip), %rsi     # 0x1c0aac
xorl %eax, %eax
callq 0x15b0d0
movq -0x78(%rbp), %rax
movl 0x34(%rax), %eax
movl %eax, -0xfc(%rbp)
testl %eax, %eax
je 0xfd0d9
jmp 0xfd0bf
movl -0xfc(%rbp), %eax
subl $0x1, %eax
je 0xfd0e6
jmp 0xfd0cc
movl -0xfc(%rbp), %eax
subl $0x2, %eax
je 0xfd0f3
jmp 0xfd123
movq -0x78(%rbp), %rax
movl $0x2, 0x38(%rax)
jmp 0xfd12e
movq -0x78(%rbp), %rax
movl $0x3, 0x38(%rax)
jmp 0xfd12e
leaq 0xc39d1(%rip), %rax     # 0x1c0acb
movq %rax, -0x68(%rbp)
movq -0x78(%rbp), %rax
cmpq $0x10, 0x10(%rax)
jne 0xfd116
movq -0x78(%rbp), %rax
movl $0x5, 0x38(%rax)
jmp 0xfd121
movq -0x78(%rbp), %rax
movl $0x4, 0x38(%rax)
jmp 0xfd12e
movq -0x78(%rbp), %rax
movl $0x0, 0x38(%rax)
jmp 0xfd13b
movq -0x78(%rbp), %rax
movl $0x2, 0x38(%rax)
jmp 0xfd148
movq -0x78(%rbp), %rax
movl $0x1, 0x38(%rax)
movq -0x8(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x78(%rbp), %rax
movl 0x38(%rax), %edi
callq 0xfd690
movq -0x108(%rbp), %rdi
movq %rax, %rdx
movq -0x68(%rbp), %rcx
leaq 0xc3982(%rip), %rsi     # 0x1c0af6
movb $0x0, %al
callq 0x15b0d0
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x3, %eax
jne 0xfd1c5
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0xe, %rsi
movq -0x10(%rbp), %rax
movl (%rax), %edx
callq 0x165820
movq %rax, -0xe8(%rbp)
movq -0x8(%rbp), %rdi
movq -0xe8(%rbp), %rax
movl %eax, %edx
leaq 0xc395b(%rip), %rsi     # 0x1c0b19
movb $0x0, %al
callq 0x15b0d0
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x3, %eax
jne 0xfd22e
movl -0x3c(%rbp), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0xfd22e
cmpq $0x14, -0x48(%rbp)
jl 0xfd22e
movq -0x78(%rbp), %rax
movl $0x1, 0x20(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x10, %rsi
movq -0x10(%rbp), %rax
movl (%rax), %edx
callq 0x1658c0
movl %eax, %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x24(%rax)
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rax
movl 0x24(%rax), %edx
leaq 0xc38fe(%rip), %rsi     # 0x1c0b25
movb $0x0, %al
callq 0x15b0d0
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x3, %eax
jne 0xfd2dd
cmpq $0x18, -0x48(%rbp)
jl 0xfd2dd
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x14, %rsi
movq -0x10(%rbp), %rax
movl (%rax), %edx
callq 0x1658c0
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0xfd28c
leaq -0xe0(%rbp), %rdi
movl $0x50, %esi
leaq 0x9f48a(%rip), %rdx     # 0x19c70d
movb $0x0, %al
callq 0x15a980
jmp 0xfd2be
leaq -0xe0(%rbp), %rdi
movq -0x18(%rbp), %rax
movl %eax, %ecx
movq -0x60(%rbp), %rax
movl %eax, %r8d
movq -0x18(%rbp), %rax
addq -0x60(%rbp), %rax
movl %eax, %r9d
movl $0x50, %esi
leaq 0xc3888(%rip), %rdx     # 0x1c0b3f
movb $0x0, %al
callq 0x15a980
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rax
movl %eax, %edx
leaq -0xe0(%rbp), %rcx
leaq 0xc3876(%rip), %rsi     # 0x1c0b4c
movb $0x0, %al
callq 0x15b0d0
movq -0x78(%rbp), %rax
movq (%rax), %rax
movq -0x78(%rbp), %rcx
imulq 0x10(%rcx), %rax
addq $0x7, %rax
movl $0x8, %ecx
cqto
idivq %rcx
movq %rax, -0x50(%rbp)
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
cmpq -0x50(%rbp), %rax
jge 0xfd334
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %edx
movq -0x50(%rbp), %rax
movl %eax, %ecx
leaq 0xc383e(%rip), %rsi     # 0x1c0b66
movb $0x0, %al
callq 0x15bfb0
jmp 0xfd65a
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rax
movq (%rax), %rsi
movq -0x78(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x16a850
cmpl $0x0, %eax
jne 0xfd356
jmp 0xfd65a
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movl -0x3c(%rbp), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0xfd3a5
movq -0x78(%rbp), %rax
movl $0x1, 0x28(%rax)
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x2, %eax
jge 0xfd3a3
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %edx
leaq 0xc3815(%rip), %rsi     # 0x1c0bb1
movb $0x0, %al
callq 0x15bc10
jmp 0xfd3a5
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x3, %eax
jl 0xfd41f
movzbl -0x3e(%rbp), %eax
cmpl $0x1, %eax
jg 0xfd3e3
movzbl -0x3e(%rbp), %eax
cmpl $0x0, %eax
jne 0xfd3cf
movq -0x78(%rbp), %rax
cmpq $0x8, 0x10(%rax)
jg 0xfd3e3
movzbl -0x3e(%rbp), %eax
cmpl $0x1, %eax
jne 0xfd3fe
movq -0x78(%rbp), %rax
cmpq $0x10, 0x10(%rax)
je 0xfd3fe
movq -0x8(%rbp), %rdi
movzbl -0x3e(%rbp), %edx
leaq 0xc37ec(%rip), %rsi     # 0x1c0bde
movb $0x0, %al
callq 0x15bfb0
jmp 0xfd65a
movzbl -0x3e(%rbp), %eax
cmpl $0x1, %eax
jne 0xfd41d
movq -0x78(%rbp), %rax
cmpq $0x10, 0x10(%rax)
jne 0xfd41d
movq -0x78(%rbp), %rax
movl $0x1, 0x28(%rax)
jmp 0xfd41f
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x2, %eax
jne 0xfd46e
movq -0x78(%rbp), %rax
cmpq $0x10, 0x10(%rax)
jne 0xfd46e
movl -0x3c(%rbp), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
jne 0xfd46e
movl -0x3c(%rbp), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
jne 0xfd46e
movq -0x78(%rbp), %rax
movl $0x1, 0x28(%rax)
movq -0x8(%rbp), %rdi
leaq 0xc37a3(%rip), %rsi     # 0x1c0c0a
movb $0x0, %al
callq 0x15bc10
movq -0x78(%rbp), %rax
cmpq $0x1, 0x10(%rax)
je 0xfd4c6
movq -0x78(%rbp), %rax
cmpq $0x2, 0x10(%rax)
je 0xfd4c6
movq -0x78(%rbp), %rax
cmpq $0x4, 0x10(%rax)
je 0xfd4c6
movq -0x78(%rbp), %rax
cmpq $0x8, 0x10(%rax)
je 0xfd4c6
movq -0x78(%rbp), %rax
cmpq $0x10, 0x10(%rax)
je 0xfd4c6
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, %edx
leaq 0xa22ad(%rip), %rsi     # 0x19f767
movb $0x0, %al
callq 0x15bfb0
jmp 0xfd65a
movq -0x78(%rbp), %rax
cmpl $0x0, 0x28(%rax)
je 0xfd4db
movq -0x78(%rbp), %rax
cmpq $0x10, 0x10(%rax)
jne 0xfd4f0
movq -0x78(%rbp), %rax
cmpl $0x0, 0x28(%rax)
jne 0xfd507
movq -0x78(%rbp), %rax
cmpq $0x8, 0x10(%rax)
jle 0xfd507
movq -0x8(%rbp), %rdi
leaq 0xc3764(%rip), %rsi     # 0x1c0c5f
movb $0x0, %al
callq 0x15bfb0
jmp 0xfd65a
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x48(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
addq -0x20(%rbp), %rcx
cmpq %rcx, %rax
jl 0xfd531
jmp 0xfd65a
movl -0x3c(%rbp), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0xfd56d
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x78(%rbp), %rdx
movq -0x38(%rbp), %rcx
leaq -0x58(%rbp), %r8
callq 0xfd710
cmpl $0x0, %eax
jne 0xfd561
jmp 0xfd65a
movq -0x58(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x3c(%rbp), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0xfd5a8
movq -0x78(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x2, %eax
jg 0xfd5a8
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x78(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0xfd910
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
addq -0x20(%rbp), %rcx
cmpq %rcx, %rax
jl 0xfd5d0
movq -0x8(%rbp), %rdi
leaq 0xa17fb(%rip), %rsi     # 0x19edbf
movb $0x0, %al
callq 0x15bfb0
jmp 0xfd65a
cmpq $0x0, -0x60(%rbp)
jle 0xfd5e9
movq -0x18(%rbp), %rcx
addq -0x60(%rbp), %rcx
movq -0x78(%rbp), %rax
movq %rcx, 0x40(%rax)
jmp 0xfd5fd
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rcx
movq -0x78(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
movl %eax, %edx
leaq 0xae4fb(%rip), %rsi     # 0x1abb09
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x78(%rbp), %rdx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x38(%rbp), %r8
movq -0x78(%rbp), %rax
movq 0x40(%rax), %r9
subq -0x38(%rbp), %r9
callq 0xfda90
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x60(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
movl -0x7c(%rbp), %esi
callq 0x15b5a0
cmpq $0x0, -0x78(%rbp)
je 0xfd685
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x15b820
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nop