// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/sam_view.c
// Function: main_samview
int main_samview(int argc, char *argv[])
{
	int c, is_header = 0, is_header_only = 0, is_bamin = 1, ret = 0, compress_level = -1, is_bamout = 0, is_count = 0;
	int of_type = BAM_OFDEC, is_long_help = 0, n_threads = 0;
	int64_t count = 0;
	samfile_t *in = 0, *out = 0;
	char in_mode[5], out_mode[5], *fn_out = 0, *fn_list = 0, *fn_ref = 0, *fn_rg = 0, *q;

	/* parse command-line options */
	strcpy(in_mode, "r"); strcpy(out_mode, "w");
	while ((c = getopt(argc, argv, "SbBct:h1Ho:q:f:F:ul:r:xX?T:R:L:s:Q:@:m:")) >= 0) {
		switch (c) {
		case 's':
			if ((g_subsam_seed = strtol(optarg, &q, 10)) != 0) {
				srand(g_subsam_seed);
				g_subsam_seed = rand();
			}
			g_subsam_frac = strtod(q, &q);
			break;
		case 'm': g_min_qlen = atoi(optarg); break;
		case 'c': is_count = 1; break;
		case 'S': is_bamin = 0; break;
		case 'b': is_bamout = 1; break;
		case 't': fn_list = strdup(optarg); is_bamin = 0; break;
		case 'h': is_header = 1; break;
		case 'H': is_header_only = 1; break;
		case 'o': fn_out = strdup(optarg); break;
		case 'f': g_flag_on = strtol(optarg, 0, 0); break;
		case 'F': g_flag_off = strtol(optarg, 0, 0); break;
		case 'q': g_min_mapQ = atoi(optarg); break;
		case 'u': compress_level = 0; break;
		case '1': compress_level = 1; break;
		case 'l': g_library = strdup(optarg); break;
		case 'L': g_bed = bed_read(optarg); break;
		case 'r': g_rg = strdup(optarg); break;
		case 'R': fn_rg = strdup(optarg); break;
		case 'x': of_type = BAM_OFHEX; break;
		case 'X': of_type = BAM_OFSTR; break;
		case '?': is_long_help = 1; break;
		case 'T': fn_ref = strdup(optarg); is_bamin = 0; break;
		case 'B': bam_no_B = 1; break;
		case 'Q': g_qual_scale = atoi(optarg); break;
		case '@': n_threads = strtol(optarg, 0, 0); break;
		default: return usage(is_long_help);
		}
	}
	if (compress_level >= 0) is_bamout = 1;
	if (is_header_only) is_header = 1;
	if (is_bamout) strcat(out_mode, "b");
	else {
		if (of_type == BAM_OFHEX) strcat(out_mode, "x");
		else if (of_type == BAM_OFSTR) strcat(out_mode, "X");
	}
	if (is_bamin) strcat(in_mode, "b");
	if (is_header) strcat(out_mode, "h");
	if (compress_level >= 0) {
		char tmp[2];
		tmp[0] = compress_level + '0'; tmp[1] = '\0';
		strcat(out_mode, tmp);
	}
	if (argc == optind) return usage(is_long_help); // potential memory leak...

	// read the list of read groups
	if (fn_rg) {
		FILE *fp_rg;
		char buf[1024];
		int ret;
		g_rghash = kh_init(rg);
		fp_rg = fopen(fn_rg, "r");
		while (!feof(fp_rg) && fscanf(fp_rg, "%s", buf) > 0) // this is not a good style, but bear me...
			kh_put(rg, g_rghash, strdup(buf), &ret); // we'd better check duplicates...
		fclose(fp_rg);
	}

	// generate the fn_list if necessary
	if (fn_list == 0 && fn_ref) fn_list = samfaipath(fn_ref);
	// open file handlers
	if ((in = samopen(argv[optind], in_mode, fn_list)) == 0) {
		fprintf(stderr, "[main_samview] fail to open \"%s\" for reading.\n", argv[optind]);
		ret = 1;
		goto view_end;
	}
	if (in->header == 0) {
		fprintf(stderr, "[main_samview] fail to read the header from \"%s\".\n", argv[optind]);
		ret = 1;
		goto view_end;
	}
	if (g_rghash) { // FIXME: I do not know what "bam_header_t::n_text" is for...
		char *tmp;
		int l;
		tmp = drop_rg(in->header->text, g_rghash, &l);
		free(in->header->text);
		in->header->text = tmp;
		in->header->l_text = l;
	}
	if (!is_count && (out = samopen(fn_out? fn_out : "-", out_mode, in->header)) == 0) {
		fprintf(stderr, "[main_samview] fail to open \"%s\" for writing.\n", fn_out? fn_out : "standard output");
		ret = 1;
		goto view_end;
	}
	if (n_threads > 1) samthreads(out, n_threads, 256); 
	if (is_header_only) goto view_end; // no need to print alignments

	if (argc == optind + 1) { // convert/print the entire file
		bam1_t *b = bam_init1();
		int r;
		while ((r = samread(in, b)) >= 0) { // read one alignment from `in'
			if (!process_aln(in->header, b)) {
				if (!is_count) samwrite(out, b); // write the alignment to `out'
				count++;
			}
		}
		if (r < -1) {
			fprintf(stderr, "[main_samview] truncated file.\n");
			ret = 1;
		}
		bam_destroy1(b);
	} else { // retrieve alignments in specified regions
		int i;
		bam_index_t *idx = 0;
		if (is_bamin) idx = bam_index_load(argv[optind]); // load BAM index
		if (idx == 0) { // index is unavailable
			fprintf(stderr, "[main_samview] random alignment retrieval only works for indexed BAM files.\n");
			ret = 1;
			goto view_end;
		}
		for (i = optind + 1; i < argc; ++i) {
			int tid, beg, end, result;
			bam_parse_region(in->header, argv[i], &tid, &beg, &end); // parse a region in the format like `chr2:100-200'
			if (tid < 0) { // reference name is not found
				fprintf(stderr, "[main_samview] region \"%s\" specifies an unknown reference name. Continue anyway.\n", argv[i]);
				continue;
			}
			// fetch alignments
			if (is_count) {
				count_func_data_t count_data = { in->header, &count };
				result = bam_fetch(in->x.bam, idx, tid, beg, end, &count_data, count_func);
			} else
				result = bam_fetch(in->x.bam, idx, tid, beg, end, out, view_func);
			if (result < 0) {
				fprintf(stderr, "[main_samview] retrieval of region \"%s\" failed due to truncated file or corrupt BAM index file\n", argv[i]);
				ret = 1;
				break;
			}
		}
		bam_index_destroy(idx); // destroy the BAM index
	}

view_end:
	if (is_count && ret == 0) 
		printf("%" PRId64 "\n", count);

	// close files, free and return
	free(fn_list); free(fn_ref); free(fn_out); free(g_library); free(g_rg); free(fn_rg);
	if (g_bed) bed_destroy(g_bed);
	if (g_rghash) {
		khint_t k;
		for (k = 0; k < kh_end(g_rghash); ++k)
			if (kh_exist(g_rghash, k)) free((char*)kh_key(g_rghash, k));
		kh_destroy(rg, g_rghash);
	}
	samclose(in);
	if (!is_count)
		samclose(out);
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4f8, %rsp            # imm = 0x4F8
movq $0x0, 0xb0(%rsp)
movw $0x72, 0x62(%rsp)
movw $0x77, 0x22(%rsp)
leaq 0x3677e(%rip), %rdx     # 0x40290
movl %edi, 0x3c(%rsp)
movq %rsi, 0x58(%rsp)
callq 0x3210
testl %eax, %eax
js 0x9e0f
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl $0x1, %r12d
movq $0x0, 0x18(%rsp)
leaq 0x3674d(%rip), %r15     # 0x40290
leaq 0x365d6(%rip), %r13     # 0x40120
movl $0x0, 0x30(%rsp)
movq $0x0, 0x78(%rsp)
movq $0x0, 0x70(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x68(%rsp)
movq $0x0, 0x98(%rsp)
movl $0x0, 0x28(%rsp)
xorl %ebp, %ebp
movq $0x0, 0x48(%rsp)
xorl %r14d, %r14d
leal -0x3f(%rax), %ecx
cmpl $0x39, %ecx
ja 0x9bb7
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
jmpq *%rax
movl $0x1, 0x28(%rsp)
jmp 0x9dcd
cmpl $0x31, %eax
jne 0xa972
movl $0x1, %ebx
jmp 0x9dcd
movl $0x1, %ebp
jmp 0x9dcd
movq 0x46405(%rip), %rax     # 0x4ffe0
movq (%rax), %rdi
callq 0x3570
movq %rax, 0x40(%rsp)
jmp 0x9d9c
movq 0x463ec(%rip), %rax     # 0x4ffe0
movq (%rax), %rdi
callq 0x3570
movq %rax, 0x4773d(%rip)     # 0x51340
jmp 0x9dcd
movq 0x463d1(%rip), %rax     # 0x4ffe0
movq (%rax), %rdi
callq 0x34c0
movl %eax, 0x4771b(%rip)     # 0x51338
jmp 0x9dcd
movl $0x1, 0x30(%rsp)
jmp 0x9dcd
movq 0x463aa(%rip), %rax     # 0x4ffe0
movq (%rax), %rdi
callq 0x3570
movq %rax, 0x78(%rsp)
jmp 0x9dcd
movl $0x1, %eax
movq %rax, 0x18(%rsp)
jmp 0x9dcd
movl $0x2, %ebp
jmp 0x9dcd
leaq 0x47704(%rip), %rax     # 0x5136c
movl $0x1, (%rax)
jmp 0x9dcd
xorl %ebx, %ebx
jmp 0x9dcd
movq 0x4635f(%rip), %rax     # 0x4ffe0
movq (%rax), %rdi
leaq 0xe8(%rsp), %rsi
movl $0xa, %edx
callq 0x34b0
movl %eax, 0x4768c(%rip)     # 0x51328
testl %eax, %eax
je 0x9cb2
movl %eax, %edi
callq 0x35e0
callq 0x3740
movl %eax, 0x47676(%rip)     # 0x51328
leaq 0xe8(%rsp), %rsi
movq (%rsi), %rdi
callq 0x37f0
movsd %xmm0, 0x467c6(%rip)    # 0x50490
jmp 0x9dcd
movq 0x4630a(%rip), %rax     # 0x4ffe0
movq (%rax), %rdi
callq 0x34c0
movl %eax, 0x47674(%rip)     # 0x51358
jmp 0x9dcd
movq 0x462f0(%rip), %rax     # 0x4ffe0
movq (%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x34b0
movq %rax, 0x98(%rsp)
jmp 0x9dcd
movl $0x1, %eax
movq %rax, 0x48(%rsp)
jmp 0x9dcd
movq 0x462c1(%rip), %rax     # 0x4ffe0
movq (%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x34b0
movl %eax, 0x47603(%rip)     # 0x51334
jmp 0x9dcd
movq 0x462a3(%rip), %rax     # 0x4ffe0
movq (%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x34b0
movl %eax, 0x475e1(%rip)     # 0x51330
jmp 0x9dcd
movq 0x46288(%rip), %rax     # 0x4ffe0
movq (%rax), %rdi
callq 0x30fe5
movq %rax, 0x475e1(%rip)     # 0x51348
jmp 0x9dcd
movq 0x46270(%rip), %rax     # 0x4ffe0
movq (%rax), %rdi
callq 0x34c0
movl %eax, 0x475ae(%rip)     # 0x5132c
jmp 0x9dcd
movl $0x1, %r14d
jmp 0x9dcd
movq 0x46251(%rip), %rax     # 0x4ffe0
movq (%rax), %rdi
callq 0x3570
movq %rax, 0x70(%rsp)
xorl %r12d, %r12d
jmp 0x9dcd
movq 0x46238(%rip), %rax     # 0x4ffe0
movq (%rax), %rdi
callq 0x3570
movq %rax, 0x47599(%rip)     # 0x51350
jmp 0x9dcd
movq 0x46220(%rip), %rax     # 0x4ffe0
movq (%rax), %rdi
callq 0x3570
movq %rax, 0x68(%rsp)
movl 0x3c(%rsp), %edi
movq 0x58(%rsp), %rsi
movq %r15, %rdx
callq 0x3210
testl %eax, %eax
jns 0x9b98
cmpl $0x0, 0x30(%rsp)
sete 0x17(%rsp)
testl %r14d, %r14d
sete %al
testl %r12d, %r12d
sete %cl
movq %rcx, 0xa8(%rsp)
cmpl $0x0, 0x18(%rsp)
sete %r14b
jmp 0x9e6d
movq $0x0, 0x48(%rsp)
movb $0x1, %al
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
xorl %ebp, %ebp
movl $0x0, 0x28(%rsp)
movq $0x0, 0x98(%rsp)
movq $0x0, 0x68(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x70(%rsp)
movq $0x0, 0x78(%rsp)
movq $0x0, 0xa8(%rsp)
movb $0x1, 0x17(%rsp)
movb $0x1, %r14b
testl %ebx, %ebx
sets %cl
andb %al, %cl
movw $0x62, %r15w
cmpb $0x1, %cl
jne 0x9e94
cmpl $0x1, %ebp
je 0x9e8f
cmpl $0x2, %ebp
jne 0x9ea4
movw $0x58, %r15w
jmp 0x9e94
movw $0x78, %r15w
leaq 0x22(%rsp), %rdi
callq 0x3360
movw %r15w, 0x22(%rsp,%rax)
cmpb $0x0, 0xa8(%rsp)
jne 0x9ebf
leaq 0x62(%rsp), %rdi
callq 0x3360
movw $0x62, 0x62(%rsp,%rax)
testb %r14b, 0x17(%rsp)
jne 0x9ed7
leaq 0x22(%rsp), %rdi
callq 0x3360
movw $0x68, 0x22(%rsp,%rax)
testl %ebx, %ebx
js 0x9ef6
addb $0x30, %bl
leaq 0xf0(%rsp), %rsi
movb %bl, (%rsi)
movb $0x0, 0x1(%rsi)
leaq 0x22(%rsp), %rdi
callq 0x3480
movq 0x460bb(%rip), %rcx     # 0x4ffb8
movl 0x3c(%rsp), %eax
cmpl %eax, (%rcx)
je 0xa972
cmpq $0x0, 0x78(%rsp)
je 0xa37a
movl $0x1, %edi
movl $0x28, %esi
callq 0x3610
movq %rax, 0x47435(%rip)     # 0x51360
leaq 0x3be1d(%rip), %rsi     # 0x45d4f
movq 0x78(%rsp), %rdi
callq 0x36f0
movq %rax, %r15
movq %rax, %rdi
callq 0x3630
testl %eax, %eax
jne 0xa372
leaq 0xf0(%rsp), %rbx
leaq 0x362b2(%rip), %r12     # 0x40210
movq %r15, 0x80(%rsp)
movq %r15, %rdi
leaq 0x3b89d(%rip), %rsi     # 0x4580d
movq %rbx, %rdx
xorl %eax, %eax
callq 0x30f0
testl %eax, %eax
jle 0xa372
movq 0x473d7(%rip), %r14     # 0x51360
movq %rbx, %rdi
callq 0x3570
movq %rax, %rsi
movl (%r14), %r8d
movl 0x8(%r14), %eax
cmpl 0xc(%r14), %eax
jb 0xa1a8
movl 0x4(%r14), %eax
leal (%rax,%rax), %ecx
cmpl %r8d, %ecx
movl $0x0, %ecx
sbbl %ecx, %ecx
orl $0x1, %ecx
addl %r8d, %ecx
movl $0x21, %edx
leal -0x2(%rdx), %edi
decl %edx
cmpl %ecx, (%r12,%rdi,4)
ja 0x9fc1
movl %edx, %ecx
movl (%r12,%rcx,4), %ebp
xorps %xmm0, %xmm0
cvtsi2sd %rbp, %xmm0
mulsd 0x3502e(%rip), %xmm0    # 0x3f010
addsd 0x3502e(%rip), %xmm0    # 0x3f018
cvttsd2si %xmm0, %r12
cmpl %r12d, %eax
jae 0xa1a8
movq %rsi, 0x18(%rsp)
movl %ebp, %eax
shrl $0x4, %eax
leaq 0x4(,%rax,4), %r15
movq %r15, %rdi
callq 0x3240
movq %rax, %r13
movq %rax, %rdi
movl $0xaa, %esi
movq %r15, %rdx
callq 0x3080
movl (%r14), %edx
cmpl %ebp, %edx
jae 0xa044
movq 0x18(%r14), %rdi
leaq (,%rbp,8), %rsi
callq 0x3720
movq %rax, 0x18(%r14)
movl (%r14), %edx
testl %edx, %edx
movq 0x80(%rsp), %r15
je 0xa184
leal -0x1(%rbp), %edi
xorl %r8d, %r8d
movq 0x10(%r14), %r9
movl %r8d, %eax
shrl $0x4, %eax
movl (%r9,%rax,4), %esi
leal (%r8,%r8), %ecx
andl $0x1e, %ecx
movl %esi, %r10d
shrl %cl, %r10d
testb $0x3, %r10b
jne 0xa15f
movq 0x18(%r14), %rdx
movl %r8d, %r10d
movq (%rdx,%r10,8), %r10
btsl %ecx, %esi
movl %esi, (%r9,%rax,4)
movsbl (%r10), %ecx
testl %ecx, %ecx
je 0xa0bc
movb 0x1(%r10), %al
testb %al, %al
je 0xa0be
leaq 0x2(%r10), %rdx
movl %ecx, %esi
shll $0x5, %esi
subl %ecx, %esi
movsbl %al, %ecx
addl %esi, %ecx
movb (%rdx), %al
incq %rdx
testb %al, %al
jne 0xa0a5
jmp 0xa0be
xorl %ecx, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %ebp
movl %edx, %esi
movl %ecx, %eax
xorl %edx, %edx
divl %edi
movl %esi, %eax
movl %esi, %ecx
addl %esi, %ecx
andl $0x1e, %ecx
movl $0x2, %ebx
shll %cl, %ebx
shrl $0x4, %eax
movl (%r13,%rax,4), %r11d
testl %r11d, %ebx
jne 0xa113
incl %edx
addl %edx, %esi
xorl %eax, %eax
cmpl %ebp, %esi
jb 0xa0f5
movl %ebp, %eax
subl %eax, %esi
movl %esi, %eax
shrl $0x4, %eax
movl (%r13,%rax,4), %r11d
leal (%rsi,%rsi), %ecx
andl $0x1e, %ecx
movl $0x2, %ebx
shll %cl, %ebx
testl %r11d, %ebx
je 0xa0eb
notl %ebx
andl %r11d, %ebx
movl %ebx, (%r13,%rax,4)
movl (%r14), %edx
movl %esi, %r11d
cmpl %edx, %esi
jae 0xa157
movl (%r9,%rax,4), %r9d
shrl %cl, %r9d
movq 0x18(%r14), %rsi
testb $0x3, %r9b
jne 0xa15b
movq (%rsi,%r11,8), %rdx
movq %r10, (%rsi,%r11,8)
movl $0x1, %esi
shll %cl, %esi
movq 0x10(%r14), %r9
orl %esi, (%r9,%rax,4)
movq %rdx, %r10
jmp 0xa091
movq 0x18(%r14), %rsi
movq %r10, (%rsi,%r11,8)
incl %r8d
cmpl %edx, %r8d
jne 0xa05a
cmpl %ebp, %edx
jbe 0xa184
movq 0x18(%r14), %rdi
leaq (,%rbp,8), %rsi
callq 0x3720
movq %rax, 0x18(%r14)
movq 0x10(%r14), %rdi
callq 0x3350
movq %r13, 0x10(%r14)
movl %ebp, (%r14)
movl 0x4(%r14), %eax
movl %eax, 0x8(%r14)
movl %r12d, 0xc(%r14)
movl %ebp, %r8d
movq 0x18(%rsp), %rsi
movsbl (%rsi), %edi
testl %edi, %edi
je 0xa1d4
movb 0x1(%rsi), %al
testb %al, %al
je 0xa1d6
movq %rsi, %rcx
addq $0x2, %rcx
movl %edi, %edx
shll $0x5, %edx
subl %edi, %edx
movsbl %al, %edi
addl %edx, %edi
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0xa1bd
jmp 0xa1d6
xorl %edi, %edi
movl %edi, %eax
xorl %edx, %edx
divl %r8d
movl %edx, %r10d
movq 0x10(%r14), %r12
movl %edx, %eax
shrl $0x4, %eax
movl (%r12,%rax,4), %eax
leal (%r10,%r10), %ecx
shrl %cl, %eax
testb $0x2, %al
je 0xa1ff
movl %r10d, %r13d
jmp 0xa2d3
leal -0x1(%r8), %ecx
movl %edi, %eax
xorl %edx, %edx
divl %ecx
incl %edx
movl %r10d, %ebx
movl %r8d, %r13d
movq %rsi, 0x18(%rsp)
movq %r14, 0x30(%rsp)
movq %r10, 0x28(%rsp)
movl %edx, 0xa0(%rsp)
movl %ebx, %eax
shrl $0x4, %eax
movl (%r12,%rax,4), %ebp
leal (%rbx,%rbx), %r15d
andl $0x1e, %r15d
movl %ebp, %eax
movl %r15d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0xa2a9
testb $0x1, %al
jne 0xa276
movq 0x18(%r14), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rdi
movq %r8, %r14
callq 0x35a0
movl 0xa0(%rsp), %edx
movq 0x28(%rsp), %r10
movq %r14, %r8
movq 0x30(%rsp), %r14
movq 0x18(%rsp), %rsi
testl %eax, %eax
je 0xa2a9
btl %r15d, %ebp
cmovbl %ebx, %r13d
addl %edx, %ebx
cmpl %r8d, %ebx
movl %r8d, %eax
movl $0x0, %ecx
cmovbl %ecx, %eax
subl %eax, %ebx
cmpl %r10d, %ebx
jne 0xa227
movb $0x1, %al
movl %r8d, %ecx
cmpl %r8d, %r13d
movq 0x80(%rsp), %r15
je 0xa2c3
jmp 0xa2d3
movl %r15d, %ecx
shrl %cl, %ebp
testb $0x2, %bpl
sete %al
movl %r13d, %ecx
movl %ebx, %r10d
movq 0x80(%rsp), %r15
cmpl %r8d, %ecx
cmovel %r10d, %ecx
testb %al, %al
cmovnel %r10d, %ecx
movl %ecx, %r13d
movl %r13d, %eax
shrl $0x4, %eax
movl (%r12,%rax,4), %edx
leal (,%r13,2), %ecx
andl $0x1e, %ecx
shrl %cl, %edx
testb $0x2, %dl
jne 0xa324
testb $0x1, %dl
leaq 0xf0(%rsp), %rbx
leaq 0x35f0f(%rip), %r12     # 0x40210
je 0xa362
movq 0x18(%r14), %rdx
movl %r13d, %edi
movq %rsi, (%rdx,%rdi,8)
movl $0x3, %edx
shll %cl, %edx
notl %edx
movq 0x10(%r14), %rcx
andl %edx, (%rcx,%rax,4)
incl 0x4(%r14)
jmp 0xa362
movq 0x18(%r14), %rdx
movl %r13d, %edi
movq %rsi, (%rdx,%rdi,8)
movl $0x3, %edx
shll %cl, %edx
notl %edx
movq 0x10(%r14), %rcx
andl %edx, (%rcx,%rax,4)
movq 0x4(%r14), %xmm0
psubd 0x34cf3(%rip), %xmm0    # 0x3f040
movq %xmm0, 0x4(%r14)
leaq 0xf0(%rsp), %rbx
leaq 0x35eae(%rip), %r12     # 0x40210
movq %r15, %rdi
callq 0x3630
testl %eax, %eax
je 0x9f66
movq %r15, %rdi
callq 0x3640
movq 0x40(%rsp), %rdx
testq %rdx, %rdx
sete %al
cmpq $0x0, 0x70(%rsp)
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xa3a2
movq 0x70(%rsp), %rdi
callq 0x284ea
movq %rax, %rdx
movq 0x45c0f(%rip), %rax     # 0x4ffb8
movslq (%rax), %rax
movq 0x58(%rsp), %rcx
movq (%rcx,%rax,8), %rdi
leaq 0x62(%rsp), %rsi
movq %rdx, 0x40(%rsp)
callq 0x27ef0
movq %rax, %r15
testq %rax, %rax
je 0xa986
movq 0x10(%r15), %rdx
testq %rdx, %rdx
je 0xa992
movq 0x46f7c(%rip), %rax     # 0x51360
movq %rax, 0x30(%rsp)
testq %rax, %rax
movq %r15, 0x50(%rsp)
je 0xa6fc
movq 0x38(%rdx), %r14
xorl %r13d, %r13d
movq $0x0, 0x28(%rsp)
xorl %r15d, %r15d
movq %r15, 0x18(%rsp)
movq %r14, %rdi
movl $0xa, %esi
callq 0x34f0
movq %rax, %r12
testq %rax, %rax
jne 0xa432
movq %r14, %rdi
callq 0x3360
movq %rax, %r12
addq %r14, %r12
movq %r12, %r15
subq %r14, %r15
cmpq $0x3, %r15
jl 0xa6d9
movl $0x4, %edx
movq %r14, %rdi
leaq 0x36094(%rip), %rsi     # 0x404e5
callq 0x3230
testl %eax, %eax
je 0xa478
movslq %r15d, %rbx
leaq (%rbx,%r13), %rax
incq %rax
movq 0x28(%rsp), %rbp
cmpq %rbp, %rax
jae 0xa4c8
movq 0x18(%rsp), %r15
jmp 0xa50c
movq %r14, %rdi
leaq 0x36068(%rip), %rsi     # 0x404ea
callq 0x3460
testq %rax, %rax
je 0xa6c9
movq %r15, 0xd8(%rsp)
movq %r13, 0xe0(%rsp)
leaq 0x4(%rax), %rbp
movq %rbp, 0xa0(%rsp)
movzbl (%rbp), %edx
cmpl $0xa, %edx
ja 0xa4c3
movl $0x601, %ecx            # imm = 0x601
btl %edx, %ecx
jb 0xa586
incq %rbp
jmp 0xa4ac
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rbp
shrq $0x10, %rbp
orq %rax, %rbp
incq %rbp
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
callq 0x3720
movq %rax, %r15
leaq (%r15,%r13), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x37d0
leaq (%rbx,%r13), %r14
movb $0x0, (%r15,%r14)
addq %rbx, %r13
incq %r13
cmpq %rbp, %r13
jae 0xa536
movq %rbp, 0x28(%rsp)
jmp 0xa57a
movq %r13, %rax
shrq %rax
orq %r13, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %r15, %rdi
movq %rsi, 0x28(%rsp)
callq 0x3720
movq %rax, %r15
movw $0xa, (%r15,%r14)
jmp 0xa6ce
movb $0x0, (%rbp)
movq 0x30(%rsp), %rcx
movl (%rcx), %edi
testl %edi, %edi
je 0xa5e5
movq 0xa0(%rsp), %rcx
movsbl (%rcx), %ecx
testl %ecx, %ecx
movq %r12, 0xd0(%rsp)
movq %r14, 0xc8(%rsp)
movl %edx, 0x8c(%rsp)
movq %rbp, 0xc0(%rsp)
je 0xa5ec
movb 0x5(%rax), %dl
testb %dl, %dl
je 0xa5ee
addq $0x6, %rax
movl %ecx, %esi
shll $0x5, %esi
subl %ecx, %esi
movsbl %dl, %ecx
addl %esi, %ecx
movb (%rax), %dl
incq %rax
testb %dl, %dl
jne 0xa5ce
jmp 0xa5ee
xorl %edi, %edi
jmp 0xa6a9
xorl %ecx, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %edi
movl %edx, %ebp
leal -0x1(%rdi), %esi
movl %ecx, %eax
xorl %edx, %edx
divl %esi
movl %edx, %r15d
incl %r15d
movq 0x30(%rsp), %rax
movq 0x10(%rax), %r13
movl %ebp, %r14d
movq %rdi, 0x80(%rsp)
movl %r14d, %eax
shrl $0x4, %eax
movl (%r13,%rax,4), %ebx
leal (%r14,%r14), %r12d
andl $0x1e, %r12d
movl %ebx, %eax
movl %r12d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0xa67e
testb $0x1, %al
jne 0xa664
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rax
movl %r14d, %ecx
movq (%rax,%rcx,8), %rdi
movq 0xa0(%rsp), %rsi
callq 0x35a0
movq 0x80(%rsp), %rdi
testl %eax, %eax
je 0xa67e
addl %r15d, %r14d
cmpl %edi, %r14d
movl %edi, %eax
movl $0x0, %ecx
cmovbl %ecx, %eax
subl %eax, %r14d
cmpl %ebp, %r14d
jne 0xa619
jmp 0xa68a
movl %r12d, %ecx
shrl %cl, %ebx
testb $0x3, %bl
cmovel %r14d, %edi
movq 0xd0(%rsp), %r12
movq 0xc8(%rsp), %r14
movl 0x8c(%rsp), %edx
movq 0xc0(%rsp), %rbp
movb %dl, (%rbp)
movq 0x30(%rsp), %rax
cmpl (%rax), %edi
movq 0xe0(%rsp), %r13
movq 0xd8(%rsp), %r15
jne 0xa45a
movq 0x18(%rsp), %r15
incq %r12
movq %r12, %r14
jmp 0xa40a
movq 0x50(%rsp), %r15
movq 0x10(%r15), %rax
movq 0x38(%rax), %rdi
callq 0x3350
movq 0x10(%r15), %rdx
movq 0x18(%rsp), %rax
movq %rax, 0x38(%rdx)
movl %r13d, 0x30(%rdx)
cmpl $0x0, 0x48(%rsp)
movq 0x98(%rsp), %rsi
je 0xa710
xorl %r13d, %r13d
jmp 0xa741
movq 0x68(%rsp), %rax
testq %rax, %rax
leaq 0x35771(%rip), %rdi     # 0x3fe90
cmovneq %rax, %rdi
leaq 0x22(%rsp), %rsi
callq 0x27ef0
movq %rax, %r13
movq 0x98(%rsp), %rsi
testq %rax, %rax
je 0xaabf
cmpl $0x2, %esi
jl 0xa753
movq %r13, %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x27ed0
xorl %r14d, %r14d
cmpb $0x0, 0x17(%rsp)
movq %r13, 0x18(%rsp)
je 0xa941
movq 0x4584b(%rip), %rax     # 0x4ffb8
movslq (%rax), %rax
leal 0x1(%rax), %ecx
cmpl 0x3c(%rsp), %ecx
jne 0xa7d0
movl $0x1, %edi
movl $0x38, %esi
callq 0x3610
movq %rax, %rbx
movq %r15, %rdi
movq %rax, %rsi
callq 0x283b1
testl %eax, %eax
js 0xa90d
movq 0x10(%r15), %rdi
movq %rbx, %rsi
callq 0xab2e
testl %eax, %eax
jne 0xa7c8
cmpl $0x0, 0x48(%rsp)
jne 0xa7c0
movq %r13, %rdi
movq %rbx, %rsi
callq 0x283e6
incq 0xb0(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
jmp 0xa791
cmpb $0x0, 0xa8(%rsp)
jne 0xaab0
movq 0x58(%rsp), %rcx
movq (%rcx,%rax,8), %rdi
callq 0x2a134
movl 0x3c(%rsp), %ecx
testq %rax, %rax
je 0xaab0
movq %rax, %r12
movq 0x457b5(%rip), %rax     # 0x4ffb8
movslq (%rax), %r15
leal 0x1(%r15), %eax
xorl %r14d, %r14d
cmpl %ecx, %eax
jge 0xa934
movq 0x58(%rsp), %rax
leaq (%rax,%r15,8), %r14
addq $0x8, %r14
notl %r15d
addl %ecx, %r15d
leaq 0xbc(%rsp), %r13
leaq 0x94(%rsp), %rbp
leaq 0x90(%rsp), %rbx
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rdi
movq (%r14), %rsi
movq %r13, %rdx
movq %rbp, %rcx
movq %rbx, %r8
callq 0x22e08
movl 0xbc(%rsp), %edx
testl %edx, %edx
js 0xa903
cmpl $0x0, 0x48(%rsp)
je 0xa8bc
movq 0x50(%rsp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0xf0(%rsp)
leaq 0xb0(%rsp), %rax
movq %rax, 0xf8(%rsp)
movq 0x8(%rcx), %rdi
movl 0x94(%rsp), %ecx
movl 0x90(%rsp), %r8d
leaq 0x4e1(%rip), %rax       # 0xad8c
movq %rax, (%rsp)
movq %r12, %rsi
leaq 0xf0(%rsp), %r9
jmp 0xa8e7
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rdi
movl 0x94(%rsp), %ecx
movl 0x90(%rsp), %r8d
leaq 0x4cf(%rip), %rax       # 0xadaa
movq %rax, (%rsp)
movq %r12, %rsi
movq 0x18(%rsp), %r9
callq 0x2ae7a
testl %eax, %eax
js 0xab08
addq $0x8, %r14
decl %r15d
jne 0xa840
jmp 0xa931
movq %r14, %rdi
callq 0x3cc8
jmp 0xa8f4
xorl %r14d, %r14d
cmpl $-0x1, %eax
jne 0xaaf8
testq %rbx, %rbx
je 0xa941
movq 0x30(%rbx), %rdi
callq 0x3350
movq %rbx, %rdi
callq 0x3350
jmp 0xa941
xorl %r14d, %r14d
movq %r12, %rdi
callq 0x298a9
movq 0x50(%rsp), %r15
cmpl $0x0, 0x48(%rsp)
setne %bpl
sete %al
movl %r14d, %ecx
orb %al, %cl
jne 0xa9b4
movq 0xb0(%rsp), %rsi
leaq 0x39554(%rip), %rdi     # 0x43eb7
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x3060
movb $0x1, %bpl
jmp 0xa9b4
movl 0x28(%rsp), %edi
callq 0x3a3b
movl $0x1, %r14d
jmp 0xaa9b
movq 0x58(%rsp), %rdi
callq 0x3d5f
jmp 0xa99c
movq 0x58(%rsp), %rdi
callq 0x3d30
movq $0x0, 0x18(%rsp)
cmpl $0x0, 0x48(%rsp)
setne %bpl
movl $0x1, %r14d
movq 0x40(%rsp), %rdi
callq 0x3350
movq 0x70(%rsp), %rdi
callq 0x3350
movq 0x68(%rsp), %rdi
callq 0x3350
movq 0x46967(%rip), %rdi     # 0x51340
callq 0x3350
movq 0x4696b(%rip), %rdi     # 0x51350
callq 0x3350
movq 0x78(%rsp), %rdi
callq 0x3350
movq 0x4694d(%rip), %rdi     # 0x51348
testq %rdi, %rdi
je 0xaa05
callq 0x31a85
movq 0x46954(%rip), %rbx     # 0x51360
testq %rbx, %rbx
je 0xaa84
movq %r15, %r12
movl %r14d, %r13d
movl (%rbx), %eax
testl %eax, %eax
je 0xaa5b
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x10(%rbx), %rcx
movq %r15, %rdx
shrq $0x4, %rdx
movl (%rcx,%rdx,4), %edx
movl %r14d, %ecx
andb $0x1e, %cl
shrl %cl, %edx
testb $0x3, %dl
jne 0xaa4d
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x3350
movl (%rbx), %eax
incq %r15
movl %eax, %ecx
addl $0x2, %r14d
cmpq %rcx, %r15
jb 0xaa23
movq 0x18(%rbx), %rdi
callq 0x3350
movq 0x10(%rbx), %rdi
callq 0x3350
movq 0x20(%rbx), %rdi
callq 0x3350
movq %rbx, %rdi
callq 0x3350
movl %r13d, %r14d
movq %r12, %r15
movq %r15, %rdi
callq 0x2836b
testb %bpl, %bpl
jne 0xaa9b
movq 0x18(%rsp), %rdi
callq 0x2836b
movl %r14d, %eax
addq $0x4f8, %rsp            # imm = 0x4F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3cec
movq 0x50(%rsp), %r15
jmp 0xa9a5
movq 0x68(%rsp), %rcx
testq %rcx, %rcx
movq 0x4551a(%rip), %rax     # 0x4ffe8
movq (%rax), %rdi
leaq 0x35871(%rip), %rdx     # 0x40349
cmovneq %rcx, %rdx
leaq 0x35837(%rip), %rsi     # 0x4031a
movq $0x0, 0x18(%rsp)
xorl %eax, %eax
callq 0x3750
jmp 0xa9a5
callq 0x3d0e
movl $0x1, %r14d
jmp 0xa919
movq 0x454d9(%rip), %rax     # 0x4ffe8
movq (%rax), %rdi
movq (%r14), %rdx
leaq 0x358fc(%rip), %rsi     # 0x40418
xorl %eax, %eax
callq 0x3750
movl $0x1, %r14d
jmp 0xa934