// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/tiff.c
// Function: do_process_ifd_image
static void do_process_ifd_image(deark *c, lctx *d, struct page_ctx *pg)
{
	de_bitmap *img = NULL;
	de_bitmap *img_lo = NULL;
	struct decode_page_ctx *dctx = NULL;
	de_finfo *fi = NULL;
	int need_errmsg = 0;
	int saved_indent_level;
	int saved_indent_level2;
	i64 i;
	i64 striles_across;
	int output_bypp; // bytes/pixel for the output de_bitmap object(s)
	int ok_bps = 0;
	UI createflags = 0;
	// (Multiple dbufs are needed for PlanarConfig=separated.)
	dbuf *tmp_membuf[DE_TIFF_MAX_SAMPLES];

	de_dbg_indent_save(c, &saved_indent_level);
	dctx = de_malloc(c, sizeof(struct decode_page_ctx));
	de_zeromem(tmp_membuf, sizeof(tmp_membuf));

	// TODO: Should we check pg->compression?
	if(pg->jpegoffset>0) {
		do_oldjpeg(c, d, pg);
		goto done;
	}

	if(pg->compression==CMPR_NEWJPEG && pg->strile_count==1 && !pg->have_jpegtables) {
		// FIXME: This should really happen *after* some of the processing below,
		// but it's complicated.
		do_newjpeg(c, d, pg);
		goto done;
	}

	if(!is_image_ifd(c, d, pg)) {
		de_dbg(c, "[non-image IFD]");
		goto done;
	}

	if(pg->have_jxr_imageoffset) {
		goto done; // JPEG XR images are not supported
	}

	if(!d->opt_decode) goto done;
	de_dbg(c, "decoding ifd image");
	de_dbg_indent(c, 1);

	detect_and_setup_dexxa(c, d, pg);

	if(pg->compression<1) {
		pg->compression = CMPR_NONE;
	}
	pg->cmi = find_cmpr_meth_info(pg->compression);

	if(pg->samples_per_pixel<1) {
		pg->samples_per_pixel = 1;
	}
	if(pg->bits_per_sample<1) {
		pg->bits_per_sample = 1;
	}
	if(pg->predictor<1) {
		pg->predictor = 1;
	}
	if(pg->sample_format<1) {
		pg->sample_format = 1;
	}
	if(pg->resolution_unit<1) {
		pg->resolution_unit = 2;
	}
	if(pg->rows_per_strip<1 || pg->rows_per_strip>pg->imagelength) {
		pg->rows_per_strip = pg->imagelength;
	}

	if(pg->planarconfig<=1 || pg->samples_per_pixel==1) {
		dctx->is_separated = 0;
	}
	else if(pg->planarconfig==2) {
		dctx->is_separated = 1;
	}
	else {
		need_errmsg = 1; goto done;
	}

	dctx->width = pg->imagewidth; // tentative dimensions
	dctx->height = pg->imagelength;
	if(!de_good_image_dimensions(c, dctx->width, dctx->height)) goto done;

	if(!pg->cmi || !pg->cmi->decompressor) {
		detiff_err(c, d, pg, "Unsupported compression method: %d (%s)", (int)pg->compression,
			((pg->cmi && pg->cmi->name)?pg->cmi->name:"?"));
		goto done;
	}

	if(pg->have_tile_tags) {
		if(pg->have_strip_tags) {
			detiff_warn(c, d, pg, "Image seems to have both strips and tiles");
		}
		dctx->is_tiled = 1;
	}

	if(pg->strile_count<1) {
		detiff_err(c, d, pg, "No image data found");
		goto done;
	}
	if((pg->strile_count==1 && pg->strile_data[0].len==0) ||
		(pg->strile_count>1 && !pg->have_strilebytecounts))
	{
		i64 k;

		// Tolerate missing StripByteCounts tag in some cases
		for(k=0; k<pg->strile_count; k++) {
			if(k<pg->strile_count-1) {
				pg->strile_data[k].len = pg->strile_data[k+1].pos - pg->strile_data[k].pos;
			}
			else {
				pg->strile_data[k].len = c->infile->len - pg->strile_data[k].pos;
			}
			if(pg->strile_data[k].len<0) pg->strile_data[k].len = 0;
		}
	}

	if(pg->sample_format!=1) {
		detiff_err(c, d, pg, "Unsupported sample format (%d)", (int)pg->sample_format);
		goto done;
	}

	if(pg->is_dexxa && pg->dexxa_ncolors==16) {
		dctx->base_samples_per_pixel = 4;
		ok_bps = 1;
		if(!pg->have_colormap) {
			de_copy_std_palette(DE_PALID_PC16, 0, 0, pg->pal, 16, 0);
		}
		dctx->use_pal = 1;
	}
	else if(pg->is_dexxa && pg->dexxa_ncolors==4) {
		dctx->base_samples_per_pixel = 1;
		ok_bps = 1;
		if(!pg->have_colormap) {
			de_copy_std_palette(DE_PALID_CGA, 3, 0, pg->pal, 4, 0);
		}
		dctx->use_pal = 1;
	}
	else if(pg->photometric==0 || pg->photometric==1) {
		dctx->is_grayscale = 1;
		dctx->grayscale_reverse_polarity = (pg->photometric==0);
		dctx->base_samples_per_pixel = 1;
		if(pg->bits_per_sample==1 || pg->bits_per_sample==2 || pg->bits_per_sample==4 ||
			pg->bits_per_sample==8 || pg->bits_per_sample==16)
		{
			ok_bps = 1;
		}
	}
	else if(pg->photometric==2) { // RGB
		dctx->base_samples_per_pixel = 3;
		if(pg->bits_per_sample==1 || pg->bits_per_sample==2 || pg->bits_per_sample==4 ||
			pg->bits_per_sample==8 || pg->bits_per_sample==16)
		{
			ok_bps = 1;
		}
	}
	else if(pg->photometric==3) { // paletted
		dctx->base_samples_per_pixel = 1;
		dctx->use_pal = 1;
		if(pg->bits_per_sample==1 || pg->bits_per_sample==2 || pg->bits_per_sample==4 ||
			pg->bits_per_sample==8)
		{
			ok_bps = 1;
		}
	}
	else {
		detiff_err(c, d, pg, "Unsupported color type: %d (%s)", (int)pg->photometric,
			lookup_str(photometric_name_map, DE_ARRAYCOUNT(photometric_name_map), (i64)pg->photometric));
		goto done;
	}

	if(!ok_bps) {
		detiff_err(c, d, pg, "Unsupported bits/sample (%d) for this color type", (int)pg->bits_per_sample);
		goto done;
	}

	if(pg->samples_per_pixel<1) {
		pg->samples_per_pixel = dctx->base_samples_per_pixel;
	}
	if(pg->samples_per_pixel < dctx->base_samples_per_pixel) {
		detiff_err(c, d, pg, "Bad samples/pixel (%d) for this color type", (int)pg->samples_per_pixel);
		goto done;
	}
	dctx->samples_per_pixel_to_decode = pg->samples_per_pixel;
	if(dctx->samples_per_pixel_to_decode>DE_TIFF_MAX_SAMPLES) {
		dctx->samples_per_pixel_to_decode = DE_TIFF_MAX_SAMPLES;
	}

	if(pg->predictor!=1 && pg->predictor!=2) {
		detiff_err(c, d, pg, "Unsupported prediction method (%d)", (int)pg->predictor);
		goto done;
	}

	if(pg->compression==CMPR_LZW) {
		// Looking ahead to detect this may help to decipher the FillOrder tag.
		detect_lzw_version(c, d, pg);
	}

	if(pg->fill_order==2) {
		preprocess_fillorder_lsb(c, d, pg, dctx);
	}

	// TODO: Support -padpix in more situations
	if(c->padpix && !dctx->is_tiled && !dctx->is_separated && pg->compression==CMPR_NONE) {
		if(pg->samples_per_pixel==1 && pg->bits_per_sample<8) {
			dctx->width = de_pad_to_n(dctx->width * pg->samples_per_pixel * pg->bits_per_sample, 8) /
				((i64)pg->samples_per_pixel * pg->bits_per_sample);
		}
	}

	// Look for an alpha sample
	for(i=0; i<(i64)pg->extrasamples_count; i++) {
		if((i64)dctx->base_samples_per_pixel + i >= (i64)dctx->samples_per_pixel_to_decode) break;
		if(pg->extrasample_type[i]==1) { // Assoc. alpha
			dctx->has_alpha = 1;
			dctx->is_assoc_alpha = 1;
			dctx->alpha_sample_idx = (UI)dctx->base_samples_per_pixel + (UI)i;
			break;
		}
		else if(pg->extrasample_type[i]==2) { // Unassoc. alpha
			dctx->has_alpha = 1;
			dctx->is_assoc_alpha = 0;
			dctx->alpha_sample_idx = (UI)dctx->base_samples_per_pixel + (UI)i;
			break;
		}
	}

	if(dctx->has_alpha) {
		// We will read and low-level decode all samples up to and including the
		// first alpha sample, though some may end up being ignored.
		dctx->samples_per_pixel_to_decode = (UI)dctx->alpha_sample_idx+1;
	}
	else {
		dctx->samples_per_pixel_to_decode = dctx->base_samples_per_pixel;
	}

	{
		UI num_samples_respected;

		num_samples_respected = dctx->base_samples_per_pixel +
			(dctx->has_alpha ? 1 : 0);
		if(num_samples_respected < pg->samples_per_pixel) {
			detiff_warn(c, d, pg, "Only using %u of %u samples. This image "
				"may not be fully supported.",
				(UI)num_samples_respected, (UI)pg->samples_per_pixel);
		}
	}

	if(dctx->is_separated) {
		dctx->striles_per_plane = pg->strile_count / pg->samples_per_pixel;
		dctx->num_planes_to_decode = dctx->samples_per_pixel_to_decode;
		dctx->samples_per_pixel_per_plane = 1;
	}
	else {
		dctx->striles_per_plane = pg->strile_count;
		dctx->num_planes_to_decode = 1;
		dctx->samples_per_pixel_per_plane = pg->samples_per_pixel;
	}

	if(dctx->is_tiled) {
		i64 striles_down;

		if(pg->tile_width<1 || pg->tile_height<1 || pg->tile_width>c->max_image_dimension ||
			pg->tile_height>c->max_image_dimension)
		{
			need_errmsg = 1; goto done;
		}
		dctx->strile_max_w = pg->tile_width;
		dctx->strile_max_h = pg->tile_height;
		striles_across = (dctx->width + pg->tile_width - 1) / pg->tile_width;
		striles_down = (dctx->height + pg->tile_height - 1) / pg->tile_height;

		if(c->padpix) {
			dctx->width = striles_across * pg->tile_width;
			dctx->height = striles_down * pg->tile_height;
		}
	}
	else {
		dctx->strile_max_w = dctx->width;
		dctx->strile_max_h = pg->rows_per_strip;
		striles_across = 1;
	}
	dctx->strile_max_rowspan = (dctx->strile_max_w * (i64)dctx->samples_per_pixel_per_plane *
		pg->bits_per_sample + 7)/8;

	de_dfilter_init_objects(c, &dctx->dcmpri, &dctx->dcmpro, NULL);
	dctx->dcmpri.f = c->infile;

	if(dctx->is_grayscale) output_bypp = 1;
	else output_bypp = 3;
	if(dctx->has_alpha) output_bypp++;

	if(dctx->is_grayscale && output_bypp==1 && pg->bits_per_sample==16) {
		// In some limited cases, we fully support depth=16bit.
		dctx->dst_flag_16bit = 1;
	}

	img = de_bitmap_create(c, dctx->width, dctx->height, output_bypp);
	if(dctx->dst_flag_16bit) {
		img_lo = de_bitmap_create(c, dctx->width, dctx->height, output_bypp);
	}

	de_dbg_indent_save(c, &saved_indent_level2);

	for(dctx->strileset_idx=0; dctx->strileset_idx<dctx->striles_per_plane; dctx->strileset_idx++) {
		int ret;
		i64 first_strile_idx;

		first_strile_idx = dctx->strileset_idx;
		dctx->strileset_xpos = (dctx->strileset_idx % striles_across) * dctx->strile_max_w;
		dctx->strileset_ypos = (dctx->strileset_idx / striles_across) * dctx->strile_max_h;
		if(dctx->strileset_ypos >= dctx->height) goto after_paint;

		de_dbg2(c, "strip #%d (%d,%d) at %"I64_FMT"%s, dlen=%"I64_FMT,
			(int)dctx->strileset_idx, (int)dctx->strileset_xpos, (int)dctx->strileset_ypos,
			pg->strile_data[first_strile_idx].pos, (dctx->is_separated?"...":""),
			pg->strile_data[first_strile_idx].len);

		dctx->strileset_width = dctx->strile_max_w;
		if(dctx->is_tiled) { // Tiles are all the same width and height.
			dctx->strileset_height = dctx->strile_max_h;
		}
		else { // The last strip may have a smaller height.
			dctx->strileset_height = de_min_int(dctx->strile_max_h, dctx->height - dctx->strileset_ypos);
		}
		dctx->strileset_rowspan = (dctx->strileset_width * (i64)dctx->samples_per_pixel_per_plane *
			pg->bits_per_sample + 7)/8;
		if(dctx->strileset_height<1) goto after_paint;

		{
			UI k;

			for(k=0; k<dctx->num_planes_to_decode; k++) {
				if(tmp_membuf[k]) {
					dbuf_empty(tmp_membuf[k]);
				}
				else {
					tmp_membuf[k] = dbuf_create_membuf(c, 0, 0);
					dbuf_enable_wbuffer(tmp_membuf[k]);
					dbuf_set_length_limit(tmp_membuf[k], dctx->strile_max_h * dctx->strile_max_rowspan);
				}
				dctx->unc_strile_dbuf[k] = tmp_membuf[k];
			}

			ret = decompress_strileset(c, d, pg, dctx);
			if(!ret) {
				// TODO?: Better handling of partial failure
				if(dctx->strileset_idx>0) goto after_paint;
				goto done;
			}
		}

		paint_decompressed_strile_to_image(c, d, pg, dctx, img, img_lo);
	}

after_paint:
	de_dbg_indent_restore(c, saved_indent_level2);
	fi = de_finfo_create(c);

	if(pg->orientation>=5 && pg->orientation<=8) {
		de_bitmap_transpose(img);
		if(img_lo) de_bitmap_transpose(img_lo);
	}
	if(pg->orientation==2 || pg->orientation==3 || pg->orientation==6 || pg->orientation==7) {
		de_bitmap_mirror(img);
		if(img_lo) de_bitmap_mirror(img_lo);
	}
	if(pg->orientation==3 || pg->orientation==4 || pg->orientation==7 || pg->orientation==8) {
		// More efficient than de_bitmap_flip(). We can do this if flipping is the last step.
		createflags |= DE_CREATEFLAG_FLIP_IMAGE;
	}

	if(pg->is_thumb) {
		createflags |= DE_CREATEFLAG_IS_AUX;
		de_finfo_set_name_from_sz(c, fi, "thumb", 0, DE_ENCODING_LATIN1);
	}

	set_image_density(c, d, pg, fi);
	fi->internal_mod_time = pg->internal_mod_time;

	createflags |= DE_CREATEFLAG_OPT_IMAGE;
	de_bitmap16_write_to_file_finfo(img, img_lo, fi, createflags);

done:
	for(i=0; i<DE_TIFF_MAX_SAMPLES; i++) {
		if(tmp_membuf[i]) dbuf_close(tmp_membuf[i]);
	}
	de_bitmap_destroy(img);
	de_bitmap_destroy(img_lo);
	de_finfo_destroy(c, fi);
	if(need_errmsg) {
		detiff_err(c, d, pg, "Unsupported image type or bad image");
	}
	if(dctx) {
		if(dctx->dfctx) de_dfilter_destroy(dctx->dfctx);
		de_free(c, dctx);
	}
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
movl $0x180, %esi            # imm = 0x180
callq 0x15b780
movq %rax, -0x30(%rbp)
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
movl $0x50, %edx
callq 0x19140
movq -0x18(%rbp), %rax
cmpq $0x0, 0x70(%rax)
jle 0x12f50f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x134bf0
jmp 0x1306eb
movq -0x18(%rbp), %rax
cmpl $0x7, 0x1c(%rax)
jne 0x12f547
movq -0x18(%rbp), %rax
cmpq $0x1, 0xb0(%rax)
jne 0x12f547
movq -0x18(%rbp), %rax
cmpb $0x0, 0x18(%rax)
jne 0x12f547
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x134d20
jmp 0x1306eb
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x134db0
cmpl $0x0, %eax
jne 0x12f574
movq -0x8(%rbp), %rdi
leaq 0x9c0e9(%rip), %rsi     # 0x1cb651
movb $0x0, %al
callq 0x15b0d0
jmp 0x1306eb
movq -0x18(%rbp), %rax
cmpb $0x0, 0x1b(%rax)
je 0x12f583
jmp 0x1306eb
movq -0x10(%rbp), %rax
cmpb $0x0, 0x14(%rax)
jne 0x12f592
jmp 0x1306eb
movq -0x8(%rbp), %rdi
leaq 0x9c0c4(%rip), %rsi     # 0x1cb661
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x134e50
movq -0x18(%rbp), %rax
cmpl $0x1, 0x1c(%rax)
jae 0x12f5d8
movq -0x18(%rbp), %rax
movl $0x1, 0x1c(%rax)
movq -0x18(%rbp), %rax
movl 0x1c(%rax), %edi
callq 0x133560
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0xa8(%rax)
movq -0x18(%rbp), %rax
cmpl $0x1, 0x2c(%rax)
jae 0x12f607
movq -0x18(%rbp), %rax
movl $0x1, 0x2c(%rax)
movq -0x18(%rbp), %rax
cmpl $0x1, 0x28(%rax)
jae 0x12f61c
movq -0x18(%rbp), %rax
movl $0x1, 0x28(%rax)
movq -0x18(%rbp), %rax
cmpl $0x1, 0x3c(%rax)
jae 0x12f631
movq -0x18(%rbp), %rax
movl $0x1, 0x3c(%rax)
movq -0x18(%rbp), %rax
cmpl $0x1, 0x40(%rax)
jae 0x12f646
movq -0x18(%rbp), %rax
movl $0x1, 0x40(%rax)
movq -0x18(%rbp), %rax
cmpl $0x1, 0x44(%rax)
jae 0x12f65b
movq -0x18(%rbp), %rax
movl $0x2, 0x44(%rax)
movq -0x18(%rbp), %rax
cmpq $0x1, 0x80(%rax)
jl 0x12f67e
movq -0x18(%rbp), %rax
movq 0x80(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x68(%rcx), %rax
jle 0x12f691
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x18(%rbp), %rax
cmpl $0x1, 0x38(%rax)
jbe 0x12f6a5
movq -0x18(%rbp), %rax
cmpl $0x1, 0x2c(%rax)
jne 0x12f6b2
movq -0x30(%rbp), %rax
movb $0x0, 0xcd(%rax)
jmp 0x12f6d7
movq -0x18(%rbp), %rax
cmpl $0x2, 0x38(%rax)
jne 0x12f6c9
movq -0x30(%rbp), %rax
movb $0x1, 0xcd(%rax)
jmp 0x12f6d5
movl $0x1, -0x3c(%rbp)
jmp 0x1306eb
jmp 0x12f6d7
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x16a850
cmpl $0x0, %eax
jne 0x12f718
jmp 0x1306eb
movq -0x18(%rbp), %rax
cmpq $0x0, 0xa8(%rax)
je 0x12f73c
movq -0x18(%rbp), %rax
movq 0xa8(%rax), %rax
cmpq $0x0, 0x10(%rax)
jne 0x12f7e8
movq -0x8(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x18(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0xf0(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0xa8(%rax)
je 0x12f7a2
movq -0x18(%rbp), %rax
movq 0xa8(%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0x12f7a2
movq -0x18(%rbp), %rax
movq 0xa8(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x110(%rbp)
jmp 0x12f7b2
leaq 0x88484(%rip), %rax     # 0x1b7c2d
movq %rax, -0x110(%rbp)
jmp 0x12f7b2
movl -0xf0(%rbp), %r8d
movq -0xf8(%rbp), %rdx
movq -0x100(%rbp), %rsi
movq -0x108(%rbp), %rdi
movq -0x110(%rbp), %r9
leaq 0xa05ea(%rip), %rcx     # 0x1cfdc6
movb $0x0, %al
callq 0x12ee30
jmp 0x1306eb
movq -0x18(%rbp), %rax
cmpb $0x0, 0x16(%rax)
je 0x12f821
movq -0x18(%rbp), %rax
cmpb $0x0, 0x15(%rax)
je 0x12f816
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq 0x9be65(%rip), %rcx     # 0x1cb674
movb $0x0, %al
callq 0x12dfd0
movq -0x30(%rbp), %rax
movb $0x1, 0xcc(%rax)
movq -0x18(%rbp), %rax
cmpq $0x1, 0xb0(%rax)
jge 0x12f84e
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq 0x9be5c(%rip), %rcx     # 0x1cb69e
movb $0x0, %al
callq 0x12ee30
jmp 0x1306eb
movq -0x18(%rbp), %rax
cmpq $0x1, 0xb0(%rax)
jne 0x12f86e
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0x12f88e
movq -0x18(%rbp), %rax
cmpq $0x1, 0xb0(%rax)
jle 0x12f9c8
movq -0x18(%rbp), %rax
cmpb $0x0, 0x17(%rax)
jne 0x12f9c8
movq $0x0, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0xb0(%rcx), %rax
jge 0x12f9c6
movq -0xc8(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0xb0(%rcx), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jge 0x12f927
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rax
movq -0xc8(%rbp), %rcx
addq $0x1, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rax
movq -0xc8(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
subq (%rax), %rcx
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rax
movq -0xc8(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
jmp 0x12f96c
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rcx
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rax
movq -0xc8(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
subq (%rax), %rcx
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rax
movq -0xc8(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rax
movq -0xc8(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
jge 0x12f9ad
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rax
movq -0xc8(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq $0x0, 0x8(%rax)
jmp 0x12f9af
movq -0xc8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc8(%rbp)
jmp 0x12f899
jmp 0x12f9c8
movq -0x18(%rbp), %rax
cmpl $0x1, 0x40(%rax)
je 0x12f9f9
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x18(%rbp), %rax
movl 0x40(%rax), %r8d
leaq 0x9bcc5(%rip), %rcx     # 0x1cb6b2
movb $0x0, %al
callq 0x12ee30
jmp 0x1306eb
movq -0x18(%rbp), %rax
movzbl 0x99(%rax), %eax
cmpl $0x0, %eax
je 0x12fa6d
movq -0x18(%rbp), %rax
movzbl 0x9a(%rax), %eax
cmpl $0x10, %eax
jne 0x12fa6d
movq -0x30(%rbp), %rax
movl $0x4, 0xc8(%rax)
movl $0x1, -0x60(%rbp)
movq -0x18(%rbp), %rax
cmpb $0x0, 0x19(%rax)
jne 0x12fa5d
movq -0x18(%rbp), %rcx
addq $0xd0, %rcx
movl $0x14, %edi
xorl %r9d, %r9d
xorl %eax, %eax
movl %eax, %edx
movl $0x10, %r8d
movl %r9d, %esi
callq 0x161320
movq -0x30(%rbp), %rax
movb $0x1, 0xd3(%rax)
jmp 0x12fc96
movq -0x18(%rbp), %rax
movzbl 0x99(%rax), %eax
cmpl $0x0, %eax
je 0x12fae3
movq -0x18(%rbp), %rax
movzbl 0x9a(%rax), %eax
cmpl $0x4, %eax
jne 0x12fae3
movq -0x30(%rbp), %rax
movl $0x1, 0xc8(%rax)
movl $0x1, -0x60(%rbp)
movq -0x18(%rbp), %rax
cmpb $0x0, 0x19(%rax)
jne 0x12fad3
movq -0x18(%rbp), %rcx
addq $0xd0, %rcx
movl $0xa, %edi
movl $0x3, %esi
xorl %eax, %eax
movl %eax, %edx
movl $0x4, %r8d
xorl %r9d, %r9d
callq 0x161320
movq -0x30(%rbp), %rax
movb $0x1, 0xd3(%rax)
jmp 0x12fc94
movq -0x18(%rbp), %rax
cmpl $0x0, 0x30(%rax)
je 0x12faf7
movq -0x18(%rbp), %rax
cmpl $0x1, 0x30(%rax)
jne 0x12fb6a
movq -0x30(%rbp), %rax
movb $0x1, 0xcf(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x30(%rax)
sete %al
andb $0x1, %al
movzbl %al, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0xd0(%rax)
movq -0x30(%rbp), %rax
movl $0x1, 0xc8(%rax)
movq -0x18(%rbp), %rax
cmpl $0x1, 0x28(%rax)
je 0x12fb5e
movq -0x18(%rbp), %rax
cmpl $0x2, 0x28(%rax)
je 0x12fb5e
movq -0x18(%rbp), %rax
cmpl $0x4, 0x28(%rax)
je 0x12fb5e
movq -0x18(%rbp), %rax
cmpl $0x8, 0x28(%rax)
je 0x12fb5e
movq -0x18(%rbp), %rax
cmpl $0x10, 0x28(%rax)
jne 0x12fb65
movl $0x1, -0x60(%rbp)
jmp 0x12fc92
movq -0x18(%rbp), %rax
cmpl $0x2, 0x30(%rax)
jne 0x12fbc0
movq -0x30(%rbp), %rax
movl $0x3, 0xc8(%rax)
movq -0x18(%rbp), %rax
cmpl $0x1, 0x28(%rax)
je 0x12fbb4
movq -0x18(%rbp), %rax
cmpl $0x2, 0x28(%rax)
je 0x12fbb4
movq -0x18(%rbp), %rax
cmpl $0x4, 0x28(%rax)
je 0x12fbb4
movq -0x18(%rbp), %rax
cmpl $0x8, 0x28(%rax)
je 0x12fbb4
movq -0x18(%rbp), %rax
cmpl $0x10, 0x28(%rax)
jne 0x12fbbb
movl $0x1, -0x60(%rbp)
jmp 0x12fc90
movq -0x18(%rbp), %rax
cmpl $0x3, 0x30(%rax)
jne 0x12fc14
movq -0x30(%rbp), %rax
movl $0x1, 0xc8(%rax)
movq -0x30(%rbp), %rax
movb $0x1, 0xd3(%rax)
movq -0x18(%rbp), %rax
cmpl $0x1, 0x28(%rax)
je 0x12fc0b
movq -0x18(%rbp), %rax
cmpl $0x2, 0x28(%rax)
je 0x12fc0b
movq -0x18(%rbp), %rax
cmpl $0x4, 0x28(%rax)
je 0x12fc0b
movq -0x18(%rbp), %rax
cmpl $0x8, 0x28(%rax)
jne 0x12fc12
movl $0x1, -0x60(%rbp)
jmp 0x12fc8e
movq -0x8(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x18(%rbp), %rax
movl 0x30(%rax), %eax
movl %eax, -0x114(%rbp)
movq -0x18(%rbp), %rax
movl 0x30(%rax), %eax
movl %eax, %edx
leaq 0xf2a7e(%rip), %rdi     # 0x2226d0
movl $0xe, %esi
callq 0x1334d0
movq -0x130(%rbp), %rdi
movq -0x128(%rbp), %rsi
movq -0x120(%rbp), %rdx
movl -0x114(%rbp), %r8d
movq %rax, %r9
leaq 0x9ba4f(%rip), %rcx     # 0x1cb6d1
movb $0x0, %al
callq 0x12ee30
jmp 0x1306eb
jmp 0x12fc90
jmp 0x12fc92
jmp 0x12fc94
jmp 0x12fc96
cmpl $0x0, -0x60(%rbp)
jne 0x12fcc3
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x18(%rbp), %rax
movl 0x28(%rax), %r8d
leaq 0x9ba3a(%rip), %rcx     # 0x1cb6f1
movb $0x0, %al
callq 0x12ee30
jmp 0x1306eb
movq -0x18(%rbp), %rax
cmpl $0x1, 0x2c(%rax)
jae 0x12fcde
movq -0x30(%rbp), %rax
movl 0xc8(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x2c(%rax)
movq -0x18(%rbp), %rax
movl 0x2c(%rax), %eax
movq -0x30(%rbp), %rcx
cmpl 0xc8(%rcx), %eax
jae 0x12fd18
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x18(%rbp), %rax
movl 0x2c(%rax), %r8d
leaq 0x9ba16(%rip), %rcx     # 0x1cb722
movb $0x0, %al
callq 0x12ee30
jmp 0x1306eb
movq -0x18(%rbp), %rax
movl 0x2c(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xc4(%rax)
movq -0x30(%rbp), %rax
cmpl $0xa, 0xc4(%rax)
jbe 0x12fd44
movq -0x30(%rbp), %rax
movl $0xa, 0xc4(%rax)
movq -0x18(%rbp), %rax
cmpl $0x1, 0x3c(%rax)
je 0x12fd7f
movq -0x18(%rbp), %rax
cmpl $0x2, 0x3c(%rax)
je 0x12fd7f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x18(%rbp), %rax
movl 0x3c(%rax), %r8d
leaq 0x9b9da(%rip), %rcx     # 0x1cb74d
movb $0x0, %al
callq 0x12ee30
jmp 0x1306eb
movq -0x18(%rbp), %rax
cmpl $0x5, 0x1c(%rax)
jne 0x12fd9a
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x134fe0
movq -0x18(%rbp), %rax
cmpl $0x2, 0x34(%rax)
jne 0x12fdb9
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x135080
movq -0x8(%rbp), %rax
movzbl 0xd5(%rax), %eax
cmpl $0x0, %eax
je 0x12fe4f
movq -0x30(%rbp), %rax
cmpb $0x0, 0xcc(%rax)
jne 0x12fe4f
movq -0x30(%rbp), %rax
cmpb $0x0, 0xcd(%rax)
jne 0x12fe4f
movq -0x18(%rbp), %rax
cmpl $0x1, 0x1c(%rax)
jne 0x12fe4f
movq -0x18(%rbp), %rax
cmpl $0x1, 0x2c(%rax)
jne 0x12fe4d
movq -0x18(%rbp), %rax
cmpl $0x8, 0x28(%rax)
jae 0x12fe4d
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movl 0x2c(%rax), %eax
imulq %rax, %rdi
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
imulq %rax, %rdi
movl $0x8, %esi
callq 0x15ce90
movq -0x18(%rbp), %rcx
movl 0x2c(%rcx), %ecx
movq -0x18(%rbp), %rdx
movl 0x28(%rdx), %edx
imulq %rdx, %rcx
cqto
idivq %rcx
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
jmp 0x12fe4f
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
movzbl 0x9c(%rcx), %ecx
cmpq %rcx, %rax
jge 0x12ff34
movq -0x30(%rbp), %rax
movl 0xc8(%rax), %eax
addq -0x50(%rbp), %rax
movq -0x30(%rbp), %rcx
movl 0xc4(%rcx), %ecx
cmpq %rcx, %rax
jl 0x12fe91
jmp 0x12ff34
movq -0x18(%rbp), %rax
movq -0x50(%rbp), %rcx
movzbl 0x9d(%rax,%rcx), %eax
cmpl $0x1, %eax
jne 0x12fed8
movq -0x30(%rbp), %rax
movb $0x1, 0xd4(%rax)
movq -0x30(%rbp), %rax
movb $0x1, 0xd5(%rax)
movq -0x30(%rbp), %rax
movl 0xc8(%rax), %ecx
movq -0x50(%rbp), %rax
addl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xd8(%rax)
jmp 0x12ff34
movq -0x18(%rbp), %rax
movq -0x50(%rbp), %rcx
movzbl 0x9d(%rax,%rcx), %eax
cmpl $0x2, %eax
jne 0x12ff1f
movq -0x30(%rbp), %rax
movb $0x1, 0xd4(%rax)
movq -0x30(%rbp), %rax
movb $0x0, 0xd5(%rax)
movq -0x30(%rbp), %rax
movl 0xc8(%rax), %ecx
movq -0x50(%rbp), %rax
addl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xd8(%rax)
jmp 0x12ff34
jmp 0x12ff21
jmp 0x12ff23
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x12fe57
movq -0x30(%rbp), %rax
cmpb $0x0, 0xd4(%rax)
je 0x12ff5a
movq -0x30(%rbp), %rax
movl 0xd8(%rax), %ecx
addl $0x1, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xc4(%rax)
jmp 0x12ff6e
movq -0x30(%rbp), %rax
movl 0xc8(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xc4(%rax)
movq -0x30(%rbp), %rax
movl 0xc8(%rax), %eax
movq -0x30(%rbp), %rcx
movzbl 0xd4(%rcx), %esi
xorl %ecx, %ecx
movl $0x1, %edx
cmpl $0x0, %esi
cmovnel %edx, %ecx
addl %ecx, %eax
movl %eax, -0xcc(%rbp)
movl -0xcc(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x2c(%rcx), %eax
jae 0x12ffd0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0xcc(%rbp), %r8d
movq -0x18(%rbp), %rax
movl 0x2c(%rax), %r9d
leaq 0x9b7a7(%rip), %rcx     # 0x1cb770
movb $0x0, %al
callq 0x12dfd0
movq -0x30(%rbp), %rax
cmpb $0x0, 0xcd(%rax)
je 0x130020
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rax
movq -0x18(%rbp), %rcx
movl 0x2c(%rcx), %ecx
cqto
idivq %rcx
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x30(%rbp), %rax
movl 0xc4(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xc0(%rax)
movq -0x30(%rbp), %rax
movl $0x1, 0x30(%rax)
jmp 0x13004f
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x30(%rbp), %rax
movl $0x1, 0xc0(%rax)
movq -0x18(%rbp), %rax
movl 0x2c(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x30(%rbp), %rax
cmpb $0x0, 0xcc(%rax)
je 0x130171
movq -0x18(%rbp), %rax
cmpq $0x1, 0x88(%rax)
jl 0x1300ac
movq -0x18(%rbp), %rax
cmpq $0x1, 0x90(%rax)
jl 0x1300ac
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x8(%rbp), %rcx
cmpq 0xa8(%rcx), %rax
jg 0x1300ac
movq -0x18(%rbp), %rax
movq 0x90(%rax), %rax
movq -0x8(%rbp), %rcx
cmpq 0xa8(%rcx), %rax
jle 0x1300b8
movl $0x1, -0x3c(%rbp)
jmp 0x1306eb
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movq 0x90(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
addq 0x88(%rcx), %rax
subq $0x1, %rax
movq -0x18(%rbp), %rcx
cqto
idivq 0x88(%rcx)
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
addq 0x90(%rcx), %rax
subq $0x1, %rax
movq -0x18(%rbp), %rcx
cqto
idivq 0x90(%rcx)
movq %rax, -0xd8(%rbp)
movq -0x8(%rbp), %rax
cmpb $0x0, 0xd5(%rax)
je 0x13016f
movq -0x58(%rbp), %rcx
movq -0x18(%rbp), %rax
imulq 0x88(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0xd8(%rbp), %rcx
movq -0x18(%rbp), %rax
imulq 0x90(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x13019b
movq -0x30(%rbp), %rax
movq (%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movq 0x80(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movq $0x1, -0x58(%rbp)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rcx
movl 0x30(%rcx), %ecx
imulq %rcx, %rax
movq -0x18(%rbp), %rcx
movl 0x28(%rcx), %ecx
imulq %rcx, %rax
addq $0x7, %rax
movl $0x8, %ecx
cqto
idivq %rcx
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq $0xe8, %rsi
movq -0x30(%rbp), %rdx
addq $0x108, %rdx            # imm = 0x108
xorl %eax, %eax
movl %eax, %ecx
callq 0x1773f0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0xe8(%rax)
movq -0x30(%rbp), %rax
cmpb $0x0, 0xcf(%rax)
je 0x13021e
movl $0x1, -0x5c(%rbp)
jmp 0x130225
movl $0x3, -0x5c(%rbp)
movq -0x30(%rbp), %rax
cmpb $0x0, 0xd4(%rax)
je 0x13023b
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x30(%rbp), %rax
movzbl 0xcf(%rax), %eax
cmpl $0x0, %eax
je 0x130266
cmpl $0x1, -0x5c(%rbp)
jne 0x130266
movq -0x18(%rbp), %rax
cmpl $0x10, 0x28(%rax)
jne 0x130266
movq -0x30(%rbp), %rax
movb $0x1, 0xce(%rax)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdx
movl -0x5c(%rbp), %ecx
callq 0x16b750
movq %rax, -0x20(%rbp)
movq -0x30(%rbp), %rax
cmpb $0x0, 0xce(%rax)
je 0x1302b1
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdx
movl -0x5c(%rbp), %ecx
callq 0x16b750
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x44(%rbp), %rsi
callq 0x15b580
movq -0x30(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jge 0x1305ae
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0xe8(%rbp)
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
cqto
idivq -0x58(%rbp)
movq -0x30(%rbp), %rax
imulq 0x10(%rax), %rdx
movq -0x30(%rbp), %rax
movq %rdx, 0x40(%rax)
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
cqto
idivq -0x58(%rbp)
movq %rax, %rcx
movq -0x30(%rbp), %rax
imulq 0x18(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jl 0x130347
jmp 0x1305b0
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movl %eax, %edx
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movl %eax, %r8d
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rax
movq -0xe8(%rbp), %rsi
shlq $0x4, %rsi
addq %rsi, %rax
movq (%rax), %r9
movq -0x30(%rbp), %rax
movzbl 0xcd(%rax), %esi
leaq 0xa0838(%rip), %r10     # 0x1d0bd0
leaq 0xa1caa(%rip), %rax     # 0x1d2049
cmpl $0x0, %esi
cmovneq %rax, %r10
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rax
movq -0xe8(%rbp), %rsi
shlq $0x4, %rsi
addq %rsi, %rax
movq 0x8(%rax), %rax
leaq 0x9b3ea(%rip), %rsi     # 0x1cb7b4
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x15b350
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x30(%rbp), %rax
cmpb $0x0, 0xcc(%rax)
je 0x130409
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x50(%rax)
jmp 0x130431
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x30(%rbp), %rax
subq 0x48(%rax), %rsi
callq 0x15ccf0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
movl 0x30(%rcx), %ecx
imulq %rcx, %rax
movq -0x18(%rbp), %rcx
movl 0x28(%rcx), %ecx
imulq %rcx, %rax
addq $0x7, %rax
movl $0x8, %ecx
cqto
idivq %rcx
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x30(%rbp), %rax
cmpq $0x1, 0x50(%rax)
jge 0x130478
jmp 0x1305b0
movl $0x0, -0xec(%rbp)
movl -0xec(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl 0xc0(%rcx), %eax
jae 0x130546
movl -0xec(%rbp), %eax
cmpq $0x0, -0xc0(%rbp,%rax,8)
je 0x1304be
movl -0xec(%rbp), %eax
movq -0xc0(%rbp,%rax,8), %rdi
callq 0x169310
jmp 0x130515
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x168020
movq %rax, %rcx
movl -0xec(%rbp), %eax
movq %rcx, -0xc0(%rbp,%rax,8)
movl -0xec(%rbp), %eax
movq -0xc0(%rbp,%rax,8), %rdi
callq 0x167b90
movl -0xec(%rbp), %eax
movq -0xc0(%rbp,%rax,8), %rdi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x30(%rbp), %rax
imulq 0x20(%rax), %rsi
callq 0x168120
movl -0xec(%rbp), %eax
movq -0xc0(%rbp,%rax,8), %rdx
movq -0x30(%rbp), %rax
movl -0xec(%rbp), %ecx
movq %rdx, 0x70(%rax,%rcx,8)
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
jmp 0x130482
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x1351b0
movl %eax, -0xdc(%rbp)
cmpl $0x0, -0xdc(%rbp)
jne 0x13057c
movq -0x30(%rbp), %rax
cmpq $0x0, 0x38(%rax)
jle 0x130577
jmp 0x1305b0
jmp 0x1306eb
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x20(%rbp), %r8
movq -0x28(%rbp), %r9
callq 0x135250
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x38(%rax)
jmp 0x1302ca
jmp 0x1305b0
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x15b5a0
movq -0x8(%rbp), %rdi
callq 0x15d230
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x5, 0x20(%rax)
jb 0x1305f8
movq -0x18(%rbp), %rax
cmpl $0x8, 0x20(%rax)
ja 0x1305f8
movq -0x20(%rbp), %rdi
callq 0x16cb90
cmpq $0x0, -0x28(%rbp)
je 0x1305f6
movq -0x28(%rbp), %rdi
callq 0x16cb90
jmp 0x1305f8
movq -0x18(%rbp), %rax
cmpl $0x2, 0x20(%rax)
je 0x130620
movq -0x18(%rbp), %rax
cmpl $0x3, 0x20(%rax)
je 0x130620
movq -0x18(%rbp), %rax
cmpl $0x6, 0x20(%rax)
je 0x130620
movq -0x18(%rbp), %rax
cmpl $0x7, 0x20(%rax)
jne 0x13063b
movq -0x20(%rbp), %rdi
callq 0x16ca60
cmpq $0x0, -0x28(%rbp)
je 0x130639
movq -0x28(%rbp), %rdi
callq 0x16ca60
jmp 0x13063b
movq -0x18(%rbp), %rax
cmpl $0x3, 0x20(%rax)
je 0x130663
movq -0x18(%rbp), %rax
cmpl $0x4, 0x20(%rax)
je 0x130663
movq -0x18(%rbp), %rax
cmpl $0x7, 0x20(%rax)
je 0x130663
movq -0x18(%rbp), %rax
cmpl $0x8, 0x20(%rax)
jne 0x13066c
movl -0x64(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x64(%rbp)
movq -0x18(%rbp), %rax
cmpb $0x0, 0x13(%rax)
je 0x13069b
movl -0x64(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x64(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq 0x864ad(%rip), %rdx     # 0x1b6b3b
xorl %ecx, %ecx
movl $0x5, %r8d
callq 0x15d4c0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x135850
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0xc0(%rcx), %rdx
movq %rdx, 0x68(%rax)
movq 0xc8(%rcx), %rcx
movq %rcx, 0x70(%rax)
movl -0x64(%rbp), %eax
orl $0x2, %eax
movl %eax, -0x64(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl -0x64(%rbp), %ecx
callq 0x16aac0
movq $0x0, -0x50(%rbp)
cmpq $0xa, -0x50(%rbp)
jge 0x13072a
movq -0x50(%rbp), %rax
cmpq $0x0, -0xc0(%rbp,%rax,8)
je 0x13071a
movq -0x50(%rbp), %rax
movq -0xc0(%rbp,%rax,8), %rdi
callq 0x1676a0
jmp 0x13071c
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x1306f3
movq -0x20(%rbp), %rdi
callq 0x16af60
movq -0x28(%rbp), %rdi
callq 0x16af60
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x15d260
cmpl $0x0, -0x3c(%rbp)
je 0x130769
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq 0x9b077(%rip), %rcx     # 0x1cb7d9
movb $0x0, %al
callq 0x12ee30
cmpq $0x0, -0x30(%rbp)
je 0x13079b
movq -0x30(%rbp), %rax
cmpq $0x0, 0xe0(%rax)
je 0x13078e
movq -0x30(%rbp), %rax
movq 0xe0(%rax), %rdi
callq 0x177720
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x15b820
movq -0x8(%rbp), %rdi
movl -0x40(%rbp), %esi
callq 0x15b5a0
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq