// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tga.c
// Function: de_run_tga
static void de_run_tga(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	i64 pos;
	dbuf *unc_pixels = NULL;
	int saved_indent_level;
	i64 rowspan_tmp;
	const char *opt_trans_str;

	de_dbg_indent_save(c, &saved_indent_level);
	d = de_malloc(c, sizeof(lctx));
	d->input_encoding = de_get_input_encoding(c, NULL, DE_ENCODING_ASCII);
	d->trans_setting = TRANS_AUTO;

	opt_trans_str = de_get_ext_option(c, "tga:trans");
	if(opt_trans_str) {
		if(!de_strcmp(opt_trans_str, "auto")) {
			d->trans_setting = TRANS_AUTO;
		}
		else if(!de_strcmp(opt_trans_str, "0")) {
			d->trans_setting = TRANS_REMOVE;
		}
		else if(!de_strcmp(opt_trans_str, "1")) {
			d->trans_setting = TRANS_RESPECT;
		}
		else if(!de_strcmp(opt_trans_str, "2")) {
			d->trans_setting = TRANS_ASSOC;
		}
	}

	detect_file_format(c, d);

	if(d->file_format==FMT_VST) {
		de_declare_fmt(c, "TrueVista");
	}
	else {
		de_declare_fmt(c, "TGA");
	}

	d->thumbnail_image.is_thumb = 1;

	pos = 0;

	if(d->file_format==FMT_VST) {
		if(!do_read_vst_headers(c, d)) goto done;
	}
	else {
		if(!do_read_tga_headers(c, d)) goto done;
	}

	if(d->trans_setting==TRANS_ASSOC) {
		d->alpha_is_premultiplied = 1;
	}

	pos += 18;

	de_dbg(c, "image/color data at %"I64_FMT, pos);
	de_dbg_indent(c, 1);

	read_image_id(c, d, pos);
	pos += d->id_field_len;

	if(d->color_map_type!=0) {
		d->bytes_per_pal_entry = (d->cmap_depth+7)/8;
		d->pal_size_in_bytes = d->cmap_length * d->bytes_per_pal_entry;
		de_dbg(c, "color map at %"I64_FMT" (%d colors, %d bytes)", pos,
			(int)d->cmap_length, (int)d->pal_size_in_bytes);

		de_dbg_indent(c, 1);
		if(!do_read_palette(c, d, pos)) goto done;
		de_dbg_indent(c, -1);

		pos += d->pal_size_in_bytes;
	}

	de_dbg(c, "bitmap at %"I64_FMT, pos);
	de_dbg_indent(c, 1);

	d->bytes_per_pixel = ((d->pixel_depth+7)/8);
	if(d->pixel_depth==1) {
		rowspan_tmp = (d->main_image.width+7)/8;
	}
	else {
		rowspan_tmp = d->main_image.width * d->bytes_per_pixel;
	}
	d->main_image.img_size_in_bytes = d->main_image.height * rowspan_tmp;

	if(d->color_type!=TGA_CLRTYPE_PALETTE && d->color_type!=TGA_CLRTYPE_TRUECOLOR &&
		d->color_type!=TGA_CLRTYPE_GRAYSCALE)
	{
		de_err(c, "Unsupported color type (%d: %s)", (int)d->color_type, d->clrtype_name);
		goto done;
	}

	if( (d->color_type==TGA_CLRTYPE_PALETTE && d->pixel_depth==8) ||
		(d->color_type==TGA_CLRTYPE_TRUECOLOR && d->pixel_depth==15) ||
		(d->color_type==TGA_CLRTYPE_TRUECOLOR && d->pixel_depth==16) ||
		(d->color_type==TGA_CLRTYPE_TRUECOLOR && d->pixel_depth==24) ||
		(d->color_type==TGA_CLRTYPE_TRUECOLOR && d->pixel_depth==32) ||
		(d->color_type==TGA_CLRTYPE_GRAYSCALE && d->pixel_depth==1) ||
		(d->color_type==TGA_CLRTYPE_GRAYSCALE && d->pixel_depth==8) )
	{
		;
	}
	else {
		de_err(c, "Unsupported TGA image type (%s, depth=%d)", d->clrtype_name,
			(int)d->pixel_depth);
		goto done;
	}

	if(d->cmpr_type==TGA_CMPR_RLE) {
		if(d->pixel_depth<8) {
			de_err(c, "RLE compression not supported when depth (%d) is less than 8",
				(int)d->pixel_depth);
			goto done;
		}
		unc_pixels = dbuf_create_membuf(c, d->main_image.img_size_in_bytes, 1);
		dbuf_enable_wbuffer(unc_pixels);
		if(!do_decode_rle(c, d, pos, unc_pixels)) goto done;
	}
	else if(d->cmpr_type==TGA_CMPR_NONE) {
		unc_pixels = dbuf_open_input_subfile(c->infile, pos, d->main_image.img_size_in_bytes);
	}
	else {
		de_err(c, "Unsupported image or compression type");
		goto done;
	}

	do_decode_image(c, d, &d->main_image, unc_pixels, NULL, 0);

	de_dbg_indent(c, -2);

	if(d->thumbnail_offset!=0) {
		do_decode_thumbnail(c, d);
	}

done:
	dbuf_close(unc_pixels);
	de_dbg_indent_restore(c, saved_indent_level);
	de_free(c, d);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdi, %rbx
leaq 0x34(%rsp), %rsi
callq 0xe958c
movl $0x4f8, %esi            # imm = 0x4F8
movq %rbx, %rdi
callq 0xe969b
movq %rax, %r13
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0xeb7d1
movl %eax, 0x8(%r13)
movb $0x64, 0x10(%r13)
leaq 0x71a46(%rip), %rsi     # 0x13bb7d
movq %rbx, %rdi
callq 0xea6cb
testq %rax, %rax
je 0xca1a5
movq %rax, %r15
leaq 0x4643d(%rip), %rsi     # 0x11058b
movq %rax, %rdi
callq 0x181a0
testl %eax, %eax
je 0xca197
leaq 0x6ebb6(%rip), %rsi     # 0x138d17
movq %r15, %rdi
callq 0x181a0
testl %eax, %eax
je 0xca19b
leaq 0x68ec9(%rip), %rsi     # 0x13303d
movq %r15, %rdi
callq 0x181a0
testl %eax, %eax
je 0xca19f
leaq 0x76ec0(%rip), %rsi     # 0x141047
movq %r15, %rdi
callq 0x181a0
testl %eax, %eax
jne 0xca1a5
movb $0x67, %al
jmp 0xca1a1
movb $0x64, %al
jmp 0xca1a1
movb $0x65, %al
jmp 0xca1a1
movb $0x66, %al
movb %al, 0x10(%r13)
leaq 0x90(%r13), %r15
movq %rbx, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0xcbb4a
movl %eax, 0x98(%r13)
testl %eax, %eax
leaq 0x5de5d(%rip), %rax     # 0x128026
leaq 0x6cb9e(%rip), %rdx     # 0x136d6e
cmoveq %rax, %rdx
leaq 0x71aa2(%rip), %rsi     # 0x13bc7d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
leaq 0x60362(%rip), %r12     # 0x12a54e
cmpl $0x0, 0x98(%r13)
jne 0xca22b
movq 0x18(%rbx), %rdi
movl $0x2, %esi
callq 0xef0d5
testb %al, %al
jne 0xca22b
movq 0x18(%rbx), %rdi
movl $0x14, %esi
callq 0xef32a
cmpq $0x49474348, %rax       # imm = 0x49474348
jne 0xca22b
movl $0x1, %r14d
leaq 0x7195c(%rip), %r12     # 0x13bb87
movl %r14d, 0xc(%r13)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xeb6d6
movl $0x1, 0x50(%r13)
movl 0xc(%r13), %ebp
leaq 0x6f111(%rip), %rsi     # 0x13935e
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rdi
xorl %esi, %esi
callq 0xef0d5
cmpl $0x1, %ebp
jne 0xca346
testb %al, %al
movzbl %al, %eax
movl $0x12, %ecx
cmovnel %eax, %ecx
movzbl %cl, %eax
movq %rax, (%r13)
movl $0x1, 0xa0(%r13)
leaq 0x46485(%rip), %rax     # 0x110725
movq %rax, 0xa8(%r13)
movq 0x18(%rbx), %rdi
movl $0xc, %esi
callq 0xef1ca
movq %rax, 0x18(%r13)
movq 0x18(%rbx), %rdi
movl $0xe, %esi
callq 0xef1ca
movq %rax, 0x20(%r13)
movq 0x18(%r13), %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0xe9b05
movq 0x18(%rbx), %rdi
movl $0x10, %esi
callq 0xef0d5
movzbl %al, %edx
movq %rdx, 0x70(%r13)
leaq 0x719df(%rip), %rsi     # 0x13bcd5
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
cmpq $0x8, 0x70(%r13)
jne 0xca3d3
movb $0x1, 0x11(%r13)
movl $0x1, 0xa4(%r13)
leaq 0x6bd4f(%rip), %rax     # 0x136071
movq %rax, 0xb0(%r13)
movq $0x0, 0x58(%r13)
movq $0x100, 0x60(%r13)      # imm = 0x100
movq $0x18, 0x68(%r13)
jmp 0xca3ec
movzbl %al, %edx
movq %rdx, (%r13)
leaq 0x719f9(%rip), %rsi     # 0x13bd4d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movl $0x1, %esi
callq 0xef0d5
movb %al, 0x11(%r13)
movzbl %al, %edx
leaq 0x719e5(%rip), %rsi     # 0x13bd5f
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movl $0x2, %esi
callq 0xef0d5
movb %al, 0x12(%r13)
movzbl %al, %edx
leaq 0x719d2(%rip), %rsi     # 0x13bd72
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movzbl 0x12(%r13), %eax
cmpq $0xb, %rax
ja 0xca409
leaq 0x71704(%rip), %rcx     # 0x13bac0
movslq (%rcx,%rax,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
leaq 0x6bbdc(%rip), %rcx     # 0x135fa8
movl $0x2, %edx
jmp 0xca441
movl $0x2, 0xa4(%r13)
leaq 0x6bbc3(%rip), %rax     # 0x135fa8
movq %rax, 0xb0(%r13)
movq %rbx, %rdi
movq %r13, %rsi
callq 0xcbc62
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
jmp 0xca88f
leal -0x20(%rax), %ecx
cmpl $0x2, %ecx
jae 0xca42d
leaq 0x6bc59(%rip), %rcx     # 0x136071
movl $0x1, %edx
jmp 0xca441
leaq 0x4bbaa(%rip), %rcx     # 0x115fd0
movl $0x3, %edx
jmp 0xca441
leaq 0x48058(%rip), %rcx     # 0x11248c
xorl %edx, %edx
jmp 0xca441
leaq 0x71942(%rip), %rcx     # 0x13bd81
movl %eax, %edx
movl %edx, 0xa4(%r13)
movq %rcx, 0xb0(%r13)
decl %eax
cmpb $0xa, %al
ja 0xca475
leaq 0x716a8(%rip), %rcx     # 0x13bb04
movzbl %al, %edx
shll $0x2, %edx
movl (%rdx,%rcx), %eax
leaq 0x716c4(%rip), %rsi     # 0x13bb30
movslq (%rdx,%rsi), %rcx
addq %rsi, %rcx
jmp 0xca47e
leaq 0x48010(%rip), %rcx     # 0x11248c
xorl %eax, %eax
movl %eax, 0xa0(%r13)
movq %rcx, 0xa8(%r13)
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0xb0(%r13), %rdx
leaq 0x718e3(%rip), %rsi     # 0x13bd8a
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq 0xa8(%r13), %rdx
leaq 0x52aa4(%rip), %rsi     # 0x11cf63
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
cmpb $0x0, 0x11(%r13)
je 0xca584
movq 0x18(%rbx), %rdi
movl $0x3, %esi
callq 0xef1ca
movq %rax, 0x58(%r13)
movq 0x18(%rbx), %rdi
movl $0x5, %esi
callq 0xef1ca
movq %rax, 0x60(%r13)
movq 0x18(%rbx), %rdi
movl $0x7, %esi
callq 0xef0d5
movzbl %al, %eax
movq %rax, 0x68(%r13)
leaq 0x71878(%rip), %rsi     # 0x13bd99
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movl 0x58(%r13), %edx
leaq 0x7186b(%rip), %rsi     # 0x13bdae
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movl 0x60(%r13), %edx
leaq 0x71867(%rip), %rsi     # 0x13bdbf
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movl 0x68(%r13), %edx
leaq 0x71862(%rip), %rsi     # 0x13bdcf
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq 0x18(%rbx), %rdi
movl $0xc, %esi
callq 0xef1ca
movq %rax, 0x18(%r13)
movq 0x18(%rbx), %rdi
movl $0xe, %esi
callq 0xef1ca
movq %rax, 0x20(%r13)
movq 0x18(%r13), %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0xe9b05
movq 0x18(%rbx), %rdi
movl $0x10, %esi
callq 0xef0d5
movzbl %al, %edx
movq %rdx, 0x70(%r13)
leaq 0x71702(%rip), %rsi     # 0x13bcd5
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movq %r13, %rsi
callq 0xcbc62
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
cmpl $0x0, 0x98(%r13)
je 0xca88f
movq (%r15), %rdx
leaq 0x78(%rsp), %r15
movq %rdx, (%r15)
leaq 0x717c9(%rip), %rsi     # 0x13bdde
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef3a0
movq %rax, %r14
leaq 0x717c7(%rip), %rsi     # 0x13be09
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef3a0
movq %rax, %r15
leaq 0x71929(%rip), %rsi     # 0x13bf8e
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
testq %r14, %r14
je 0xca746
movq %r14, 0x18(%rsp)
leaq 0x7175b(%rip), %rsi     # 0x13bdef
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rax
movq 0x18(%rax), %rax
addq $-0x2, %rax
cmpq %r14, %rax
jge 0xca6c8
leaq 0x7174c(%rip), %rsi     # 0x13be05
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0xe9b27
jmp 0xca746
movq %r13, 0x8(%rsp)
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq %rbx, %rdi
callq 0xf6870
movq %rax, %r13
movq 0x18(%rbx), %rdi
movq %r14, 0x10(%rsp)
leaq 0x18(%rsp), %r14
movq %r14, %rsi
callq 0xef1ed
movq %rax, %r12
leaq 0x7171f(%rip), %rsi     # 0x13be24
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
addq %r12, 0x10(%rsp)
movq (%r14), %rax
movq 0x10(%rsp), %r14
addq $0x29, %rax
cmpq %r14, %rax
jle 0xcad22
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq %r13, %rdi
callq 0xf6bb0
movq 0x8(%rsp), %r13
testq %r15, %r15
je 0xca88f
leaq 0x7181e(%rip), %rsi     # 0x13bf74
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rax
movq 0x18(%rax), %rax
addq $-0x2, %rax
cmpq %r15, %rax
jge 0xca78d
leaq 0x7180f(%rip), %rsi     # 0x13bf8a
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0xe9b27
jmp 0xca88f
movq %r13, 0x8(%rsp)
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef1ca
movq %rax, %r14
leaq 0x717f4(%rip), %rsi     # 0x13bfa9
movq %rbx, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0xe9226
testq %r14, %r14
jle 0xca87d
movq %r14, %rcx
decq %rcx
movl $0xc7, %eax
cmpq %rax, %rcx
cmovaeq %rax, %rcx
incq %rcx
movq %rcx, 0x10(%rsp)
addq $0x8, %r15
xorl %ebp, %ebp
movq 0x18(%rbx), %rdi
leaq -0x6(%r15), %rsi
callq 0xef1ca
movq %rax, %r12
movq 0x18(%rbx), %rdi
leaq -0x4(%r15), %rsi
callq 0xef37e
movq %rax, %r13
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef37e
movq %rax, %r14
movq %rbx, %rdi
leaq 0x71798(%rip), %rsi     # 0x13bfbc
movl %ebp, %edx
movl %r12d, %ecx
movq %r13, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0xe9226
cmpq $0x14, %r12
jne 0xca86b
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rsi
movq %rbx, %rdi
movq %r13, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0xf8388
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
incq %rbp
addq $0xa, %r15
cmpq %rbp, 0x10(%rsp)
jne 0xca7eb
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq 0x8(%rsp), %r13
movq 0x18(%r13), %rsi
movq 0x20(%r13), %rdx
movq %rbx, %rdi
callq 0xf241d
testl %eax, %eax
je 0xcaa89
cmpb $0x67, 0x10(%r13)
jne 0xca8b6
movb $0x1, 0x89(%r13)
leaq 0x712d4(%rip), %rsi     # 0x13bb91
movl $0x12, %edx
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
cmpq $0x0, (%r13)
jle 0xca932
cmpl $0x0, 0xc(%r13)
jne 0xca932
movq %rbx, %rdi
callq 0xf6870
movq %rax, %r14
movq 0x18(%rbx), %rdi
movq (%r13), %rdx
movl 0x8(%r13), %r9d
movl $0x12, %esi
movq %rax, %rcx
xorl %r8d, %r8d
callq 0xf01b0
movq %r14, %rdi
callq 0xf7557
leaq 0x716c1(%rip), %rsi     # 0x13bfde
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r14, %rdi
callq 0xf6bb0
movq (%r13), %r12
addq $0x12, %r12
cmpb $0x0, 0x11(%r13)
je 0xcaa2b
movq 0x60(%r13), %rcx
movq 0x68(%r13), %r8
leaq 0x7(%r8), %rax
addq $0xe, %r8
testq %rax, %rax
cmovnsq %rax, %r8
sarq $0x3, %r8
movq %r8, 0xc0(%r13)
imulq %rcx, %r8
movq %r8, 0xc8(%r13)
leaq 0x71230(%rip), %rsi     # 0x13bba9
movq %rbx, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
cmpl $0x1, 0xa4(%r13)
jne 0xcaa17
movq 0x68(%r13), %rdx
cmpq $0x18, %rdx
jne 0xcab63
movq 0x70(%r13), %rdx
cmpq $0x8, %rdx
jne 0xcad0a
xorl %ebp, %ebp
cmpl $0x1, 0xc(%r13)
setne %al
cmpq $0x0, 0x60(%r13)
jle 0xcaa17
movb %al, %bpl
xorl %r15d, %r15d
movq 0x58(%r13), %r14
addq %r15, %r14
cmpq $0xff, %r14
ja 0xcaa0e
movq 0x18(%rbx), %rdi
movq 0xc0(%r13), %rsi
imulq %r15, %rsi
addq %r12, %rsi
movl %ebp, %edx
callq 0xefa60
movl %eax, 0xe8(%r13,%r14,4)
movq %rbx, %rdi
movq %r14, %rsi
movl %eax, %edx
callq 0xe9d68
incq %r15
cmpq 0x60(%r13), %r15
jl 0xca9d0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
addq 0xc8(%r13), %r12
leaq 0x6b790(%rip), %rsi     # 0x1361c2
movq %rbx, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x70(%r13), %rcx
leaq 0x7(%rcx), %rdx
leaq 0xe(%rcx), %rax
testq %rdx, %rdx
cmovnsq %rdx, %rax
movq 0x18(%r13), %rdx
sarq $0x3, %rax
movq %rax, 0xb8(%r13)
cmpq $0x1, %rcx
jne 0xcaa90
leaq 0x7(%rdx), %rax
addq $0xe, %rdx
testq %rax, %rax
cmovnsq %rax, %rdx
sarq $0x3, %rdx
jmp 0xcaa94
xorl %ebp, %ebp
jmp 0xcb355
imulq %rax, %rdx
imulq 0x20(%r13), %rdx
movq %rdx, 0x28(%r13)
movl 0xa4(%r13), %eax
leal -0x1(%rax), %esi
cmpl $0x3, %esi
jae 0xcab42
cmpl $0x1, %eax
sete %sil
cmpq $0x8, %rcx
sete %dil
testb %sil, %dil
jne 0xcab10
cmpl $0x2, %eax
sete %sil
leaq -0xf(%rcx), %rdi
cmpq $0x2, %rdi
setb %dil
leaq -0x18(%rcx), %r8
testq $-0x9, %r8
sete %r8b
orb %dil, %r8b
testb %sil, %r8b
jne 0xcab10
cmpq $0x1, %rcx
sete %sil
cmpl $0x3, %eax
sete %al
cmpq $0x8, %rcx
sete %dil
orb %sil, %dil
testb %al, %dil
je 0xcb294
movl 0xa0(%r13), %eax
cmpl $0x1, %eax
je 0xcab6f
cmpl $0x2, %eax
jne 0xcacf2
cmpq $0x7, %rcx
jg 0xcb154
leaq 0x710e4(%rip), %rsi     # 0x13bc1a
xorl %ebp, %ebp
movq %rbx, %rdi
movl %ecx, %edx
jmp 0xcad16
movq 0xb0(%r13), %rcx
leaq 0x71080(%rip), %rsi     # 0x13bbd0
xorl %ebp, %ebp
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9df7
jmp 0xcb355
leaq 0x71483(%rip), %rsi     # 0x13bfed
jmp 0xcad11
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xf1988
movq %rax, %rbp
leaq 0x18(%r13), %rdx
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xcb51b
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0xe9585
movq 0xe0(%r13), %rdx
testq %rdx, %rdx
je 0xcb355
leaq 0x71631(%rip), %rsi     # 0x13c1eb
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rdi
movq 0xe0(%r13), %rsi
callq 0xef0d5
movzbl %al, %eax
movq %rax, 0x38(%r13)
movq 0x18(%rbx), %rdi
movq 0xe0(%r13), %rsi
incq %rsi
callq 0xef0d5
movzbl %al, %ecx
movq %rcx, 0x40(%r13)
movl 0x38(%r13), %edx
leaq 0x60288(%rip), %rsi     # 0x12ae95
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movl $0x2, %r15d
cmpq $0x0, 0x38(%r13)
je 0xcac85
cmpq $0x0, 0x40(%r13)
jne 0xcac85
leaq 0x715d0(%rip), %rsi     # 0x13c202
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9b27
movq 0x18(%rbx), %rdi
movq 0xe0(%r13), %rsi
callq 0xef1ca
movq %rax, 0x38(%r13)
movq 0x18(%rbx), %rdi
movq 0xe0(%r13), %rsi
addq $0x2, %rsi
callq 0xef1ca
movq %rax, 0x40(%r13)
movl 0x38(%r13), %edx
leaq 0x715fa(%rip), %rsi     # 0x13c26d
movq %rbx, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0xe9226
movl $0x4, %r15d
movq 0x38(%r13), %rsi
movq 0x40(%r13), %rdx
movq %rbx, %rdi
callq 0xf241d
testl %eax, %eax
je 0xcb2b3
movq %r13, %r12
addq $0x38, %r12
movq 0x38(%r13), %rdx
imulq 0x40(%r13), %rdx
imulq 0xb8(%r13), %rdx
movq %rdx, 0x48(%r13)
movq 0x18(%rbx), %rdi
addq 0xe0(%r13), %r15
movq %r15, %rsi
callq 0xf1988
movq %rax, %r14
leaq 0x60170(%rip), %r8      # 0x12ae46
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %rax, %rcx
movl $0x1, %r9d
callq 0xcb51b
jmp 0xcb2b6
leaq 0x70f5e(%rip), %rsi     # 0x13bc57
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
jmp 0xcb355
leaq 0x71306(%rip), %rsi     # 0x13c017
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
jmp 0xcb355
movq %r13, %rdi
callq 0xf6883
movq 0x18(%rbx), %rdi
movq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rax
movl 0x8(%rax), %r9d
movl $0x29, %edx
movq %r13, %rcx
movl $0x1, %r8d
callq 0xf01b0
movq %r13, %rdi
callq 0xf6900
movq %r13, %rdi
callq 0xf7557
leaq 0x57f77(%rip), %rsi     # 0x122cdd
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
addq $0x29, 0x18(%rsp)
leaq 0x710bd(%rip), %rbp     # 0x13be3d
xorl %r12d, %r12d
movq 0x18(%rsp), %rax
addq $0x51, %rax
cmpq %r14, %rax
jg 0xca72c
movq %r13, %rdi
callq 0xf6883
movq 0x18(%rbx), %rdi
movq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rax
movl 0x8(%rax), %r9d
movl $0x51, %edx
movq %r13, %rcx
movl $0x1, %r8d
callq 0xf01b0
movq %r13, %rdi
callq 0xf6900
movq %r13, %rdi
callq 0xf7557
movq %rbx, %rdi
movq %rbp, %rsi
movl %r12d, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rsp), %rax
leaq 0x51(%rax), %rcx
movq %rcx, 0x18(%rsp)
incq %r12
cmpq $0x4, %r12
jne 0xcad83
addq $0x5d, %rax
cmpq %r14, %rax
jg 0xca72c
xorl %r12d, %r12d
movl $0x1, %ebp
xorl %r14d, %r14d
movq 0x18(%rbx), %rdi
leaq 0x18(%rsp), %rsi
callq 0xef1ed
movq %rax, 0x40(%rsp,%r14,8)
testq %rax, %rax
cmovnel %ebp, %r12d
incq %r14
cmpq $0x6, %r14
jne 0xcae14
testl %r12d, %r12d
je 0xcaeaa
movq 0x8(%rsp), %r12
leaq 0x4e8(%r12), %r14
movq 0x50(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq 0x48(%rsp), %rcx
movq 0x58(%rsp), %r8
movq 0x60(%rsp), %r9
movq 0x68(%rsp), %rax
movq %rax, (%rsp)
movq %r14, %rdi
callq 0xeae97
movb $0x2, 0x4e9(%r12)
leaq 0x80(%rsp), %r12
movl $0x40, %edx
movq %r14, %rdi
movq %r12, %rsi
xorl %ecx, %ecx
callq 0xeb4f8
leaq 0x4dfea(%rip), %rsi     # 0x118e87
movq %rbx, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rsp), %rax
leaq 0x2f(%rax), %rcx
movq %rcx, 0x18(%rsp)
addq $0x58, %rax
movq 0x10(%rsp), %r14
cmpq %r14, %rax
jg 0xca72c
movq %r13, %rdi
callq 0xf6883
movq 0x18(%rbx), %rdi
movq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rax
movl 0x8(%rax), %r9d
movl $0x29, %edx
movq %r13, %rcx
movl $0x1, %r8d
callq 0xf01b0
movq %r13, %rdi
callq 0xf6900
movq %r13, %rdi
callq 0xf7557
leaq 0x70f45(%rip), %rsi     # 0x13be53
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rsp), %rax
leaq 0x29(%rax), %rcx
movq %rcx, 0x18(%rsp)
addq $0x2c, %rax
cmpq %r14, %rax
jg 0xca72c
movq 0x18(%rbx), %rdi
leaq 0x18(%rsp), %r14
movq %r14, %rsi
callq 0xef1ed
movq %rax, %r12
movq %rax, 0x40(%rsp)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef14d
movzbl %al, %r8d
movq %r8, 0x48(%rsp)
testq %r12, %r12
setne %al
cmpb $0x20, %r8b
setne %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xcafb2
movabsq $-0x5c28f5c28f5c28f5, %rcx # imm = 0xA3D70A3D70A3D70B
movq %r12, %rax
imulq %rcx
addq %r12, %rdx
movq %rdx, %rax
shrq $0x3f, %rax
shrq $0x6, %rdx
addl %eax, %edx
imull $0x64, %edx, %eax
subl %eax, %r12d
leaq 0x70ec0(%rip), %rsi     # 0x13be65
movq %rbx, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rsp), %rax
addq $0x4, %rax
movq 0x10(%rsp), %r14
cmpq %r14, %rax
jg 0xca72c
movq 0x18(%rbx), %rdi
leaq 0x18(%rsp), %rsi
callq 0xef3a0
movq %rax, 0x40(%rsp)
testq %rax, %rax
je 0xcaff4
leaq 0x70e98(%rip), %rsi     # 0x13be80
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rsp), %rax
addq $0x4, %rax
cmpq %r14, %rax
jg 0xca72c
movq 0x18(%rbx), %rdi
leaq 0x18(%rsp), %r14
movq %r14, %rsi
callq 0xef1ed
movq 0x8(%rsp), %r12
movq %rax, 0xd0(%r12)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef1ed
movq %rax, 0xd8(%r12)
testq %rax, %rax
je 0xcb058
movl 0xd0(%r12), %edx
leaq 0x70e4d(%rip), %rsi     # 0x13be99
movq %rbx, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
addq $0xc, %rax
cmpq 0x10(%rsp), %rax
jg 0xca72c
movq 0x18(%rbx), %rdi
leaq 0x18(%rsp), %r14
movq %r14, %rsi
callq 0xef3a0
movq 0x8(%rsp), %rcx
movq %rax, 0xe0(%rcx)
leaq 0x70e14(%rip), %rsi     # 0x13bead
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq (%r14), %rax
movq 0x10(%rsp), %rcx
addq $0x4, %rax
cmpq %rcx, %rax
jg 0xca72c
movq 0x18(%rbx), %rdi
movq %rcx, %r12
leaq 0x18(%rsp), %r14
movq %r14, %rsi
callq 0xef3a0
movq %rax, 0x40(%rsp)
leaq 0x70dee(%rip), %rsi     # 0x13bec9
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
cmpq %r12, (%r14)
jge 0xca72c
movq 0x18(%rbx), %rdi
leaq 0x18(%rsp), %rsi
callq 0xef14d
movq 0x8(%rsp), %r14
movb %al, 0x88(%r14)
movl $0x1, 0x9c(%r14)
movzbl %al, %edx
leaq 0x70dc5(%rip), %rsi     # 0x13bee5
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movzbl 0x88(%r14), %eax
testl %eax, %eax
je 0xcb386
cmpl $0x4, %eax
jne 0xca72c
movq 0x8(%rsp), %rax
movb $0x1, 0x89(%rax)
jmp 0xca72c
movq %rbx, %rdi
movq %rdx, %rsi
movl $0x1, %edx
callq 0xf0faf
movq %rax, %rbp
movq %rax, %rdi
callq 0xf0e3f
leaq 0x40(%rsp), %r14
leaq 0x18(%rsp), %r15
leaq 0x80(%rsp), %rcx
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xfa6e0
movq 0x18(%rbx), %rax
movq %rax, (%r14)
movq %r12, 0x8(%r14)
movq 0x18(%rax), %rax
subq %r12, %rax
movq %rax, 0x10(%r14)
movq %rbp, 0x38(%rsp)
movq %rbp, (%r15)
movb $0x1, 0x8(%r15)
movq 0x28(%r13), %rcx
movq %rcx, 0x10(%r15)
movq %r13, 0x8(%rsp)
movq 0xb8(%r13), %r13
leaq -0x9(%r13), %rdx
cmpq $-0x8, %rdx
jb 0xcb2e6
testq %rax, %rax
setg %al
testq %rcx, %rcx
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xcb2d0
xorl %r14d, %r14d
leaq 0x78(%rsp), %rbp
movq 0x40(%rsp), %rdi
movq %r12, %rsi
callq 0xef0d5
movq %r12, %r15
incq %r15
testb %al, %al
js 0xcb22e
incb %al
movzbl %al, %r12d
movq 0x40(%rsp), %rdi
imulq %r13, %r12
movq 0x18(%rsp), %rcx
movq %r15, %rsi
movq %r12, %rdx
callq 0xefabc
movq %r12, %rdx
jmp 0xcb26f
andb $0x7f, %al
incb %al
movzbl %al, %r12d
movq 0x40(%rsp), %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0xeeee8
movq %r12, 0x10(%rsp)
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0xefb82
decq %r12
jne 0xcb24e
movq 0x10(%rsp), %rdx
imulq %r13, %rdx
movq %r13, %r12
addq %r15, %r12
movq 0x48(%rsp), %rax
movq 0x50(%rsp), %rcx
addq %rax, %rcx
cmpq %rcx, %r12
jge 0xcb2d3
addq %rdx, %r14
cmpq 0x28(%rsp), %r14
jl 0xcb1f3
jmp 0xcb2d3
movq 0xb0(%r13), %rdx
leaq 0x7094e(%rip), %rsi     # 0x13bbf0
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
jmp 0xcb355
xorl %r14d, %r14d
movq %r14, %rdi
callq 0xf0b13
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
jmp 0xcb355
movq %r12, %rax
subq %rax, %r12
movq %r12, 0x88(%rsp)
movb $0x1, 0x84(%rsp)
movq 0x18(%rsp), %rdi
callq 0xf0ea4
movl 0x80(%rsp), %ebp
testl %ebp, %ebp
je 0xcb321
leaq 0x80(%rsp), %rsi
movq %rbx, %rdi
callq 0xfa6a8
leaq 0x4999d(%rip), %rsi     # 0x114caf
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9df7
jmp 0xcb343
movq 0x88(%rsp), %rdx
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rcx
leaq 0x4f352(%rip), %rsi     # 0x11a68b
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq 0x8(%rsp), %r13
testl %ebp, %ebp
movq 0x38(%rsp), %rbp
je 0xcab7e
movq %rbp, %rdi
callq 0xf0b13
movl 0x34(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe9752
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rax
movq 0x80(%rax), %rdx
testq %rdx, %rdx
je 0xca72c
leaq 0x70b57(%rip), %rsi     # 0x13bef9
movq %rbx, %rdi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0xe9b27
jmp 0xca72c