// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/samtools-0.1.18/bam_sort.c
// Function: bam_merge_core
int bam_merge_core(int by_qname, const char *out, const char *headers, int n, char * const *fn,
					int flag, const char *reg)
{
	bamFile fpout, *fp;
	heap1_t *heap;
	bam_header_t *hout = 0;
	bam_header_t *hheaders = NULL;
	int i, j, *RG_len = 0;
	uint64_t idx = 0;
	char **RG = 0;
	bam_iter_t *iter = 0;

	if (headers) {
		tamFile fpheaders = sam_open(headers);
		if (fpheaders == 0) {
			const char *message = strerror(errno);
			fprintf(stderr, "[bam_merge_core] cannot open '%s': %s\n", headers, message);
			return -1;
		}
		hheaders = sam_header_read(fpheaders);
		sam_close(fpheaders);
	}

	g_is_by_qname = by_qname;
	fp = (bamFile*)calloc(n, sizeof(bamFile));
	heap = (heap1_t*)calloc(n, sizeof(heap1_t));
	iter = (bam_iter_t*)calloc(n, sizeof(bam_iter_t));
	// prepare RG tag
	if (flag & MERGE_RG) {
		RG = (char**)calloc(n, sizeof(void*));
		RG_len = (int*)calloc(n, sizeof(int));
		for (i = 0; i != n; ++i) {
			int l = strlen(fn[i]);
			const char *s = fn[i];
			if (l > 4 && strcmp(s + l - 4, ".bam") == 0) l -= 4;
			for (j = l - 1; j >= 0; --j) if (s[j] == '/') break;
			++j; l -= j;
			RG[i] = calloc(l + 1, 1);
			RG_len[i] = l;
			strncpy(RG[i], s + j, l);
		}
	}
	// read the first
	for (i = 0; i != n; ++i) {
		bam_header_t *hin;
		fp[i] = bam_open(fn[i], "r");
		if (fp[i] == 0) {
			int j;
			fprintf(stderr, "[bam_merge_core] fail to open file %s\n", fn[i]);
			for (j = 0; j < i; ++j) bam_close(fp[j]);
			free(fp); free(heap);
			// FIXME: possible memory leak
			return -1;
		}
		hin = bam_header_read(fp[i]);
		if (i == 0) { // the first BAM
			hout = hin;
		} else { // validate multiple baf
			int min_n_targets = hout->n_targets;
			if (hin->n_targets < min_n_targets) min_n_targets = hin->n_targets;

			for (j = 0; j < min_n_targets; ++j)
				if (strcmp(hout->target_name[j], hin->target_name[j]) != 0) {
					fprintf(stderr, "[bam_merge_core] different target sequence name: '%s' != '%s' in file '%s'\n",
							hout->target_name[j], hin->target_name[j], fn[i]);
					return -1;
				}

			// If this input file has additional target reference sequences,
			// add them to the headers to be output
			if (hin->n_targets > hout->n_targets) {
				swap_header_targets(hout, hin);
				// FIXME Possibly we should also create @SQ text headers
				// for the newly added reference sequences
			}

			bam_header_destroy(hin);
		}
	}

	if (hheaders) {
		// If the text headers to be swapped in include any @SQ headers,
		// check that they are consistent with the existing binary list
		// of reference information.
		if (hheaders->n_targets > 0) {
			if (hout->n_targets != hheaders->n_targets) {
				fprintf(stderr, "[bam_merge_core] number of @SQ headers in '%s' differs from number of target sequences\n", headers);
				if (!reg) return -1;
			}
			for (j = 0; j < hout->n_targets; ++j)
				if (strcmp(hout->target_name[j], hheaders->target_name[j]) != 0) {
					fprintf(stderr, "[bam_merge_core] @SQ header '%s' in '%s' differs from target sequence\n", hheaders->target_name[j], headers);
					if (!reg) return -1;
				}
		}

		swap_header_text(hout, hheaders);
		bam_header_destroy(hheaders);
	}

	if (reg) {
		int tid, beg, end;
		if (bam_parse_region(hout, reg, &tid, &beg, &end) < 0) {
			fprintf(stderr, "[%s] Malformated region string or undefined reference name\n", __func__);
			return -1;
		}
		for (i = 0; i < n; ++i) {
			bam_index_t *idx;
			idx = bam_index_load(fn[i]);
			iter[i] = bam_iter_query(idx, tid, beg, end);
			bam_index_destroy(idx);
		}
	}

	for (i = 0; i < n; ++i) {
		heap1_t *h = heap + i;
		h->i = i;
		h->b = (bam1_t*)calloc(1, sizeof(bam1_t));
		if (bam_iter_read(fp[i], iter[i], h->b) >= 0) {
			h->pos = ((uint64_t)h->b->core.tid<<32) | (uint32_t)((int32_t)h->b->core.pos+1)<<1 | bam1_strand(h->b);
			h->idx = idx++;
		}
		else h->pos = HEAP_EMPTY;
	}
	if (flag & MERGE_UNCOMP) fpout = strcmp(out, "-")? bam_open(out, "wu") : bam_dopen(fileno(stdout), "wu");
	else if (flag & MERGE_LEVEL1) fpout = strcmp(out, "-")? bam_open(out, "w1") : bam_dopen(fileno(stdout), "w1");
	else fpout = strcmp(out, "-")? bam_open(out, "w") : bam_dopen(fileno(stdout), "w");
	if (fpout == 0) {
		fprintf(stderr, "[%s] fail to create the output file.\n", __func__);
		return -1;
	}
	bam_header_write(fpout, hout);
	bam_header_destroy(hout);

	ks_heapmake(heap, n, heap);
	while (heap->pos != HEAP_EMPTY) {
		bam1_t *b = heap->b;
		if (flag & MERGE_RG) {
			uint8_t *rg = bam_aux_get(b, "RG");
			if (rg) bam_aux_del(b, rg);
			bam_aux_append(b, "RG", 'Z', RG_len[heap->i] + 1, (uint8_t*)RG[heap->i]);
		}
		bam_write1_core(fpout, &b->core, b->data_len, b->data);
		if ((j = bam_iter_read(fp[heap->i], iter[heap->i], b)) >= 0) {
			heap->pos = ((uint64_t)b->core.tid<<32) | (uint32_t)((int)b->core.pos+1)<<1 | bam1_strand(b);
			heap->idx = idx++;
		} else if (j == -1) {
			heap->pos = HEAP_EMPTY;
			free(heap->b->data); free(heap->b);
			heap->b = 0;
		} else fprintf(stderr, "[bam_merge_core] '%s' is truncated. Continue anyway.\n", fn[heap->i]);
		ks_heapadjust(heap, 0, n, heap);
	}

	if (flag & MERGE_RG) {
		for (i = 0; i != n; ++i) free(RG[i]);
		free(RG); free(RG_len);
	}
	for (i = 0; i != n; ++i) {
		bam_iter_destroy(iter[i]);
		bam_close(fp[i]);
	}
	bam_close(fpout);
	free(fp); free(heap); free(iter);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %r9d, 0x14(%rsp)
movq %r8, %r12
movq %rsi, 0x78(%rsp)
movl %edi, %ebx
testq %rdx, %rdx
movl %ecx, 0x4(%rsp)
movq %rdx, 0x70(%rsp)
je 0x2fa295
movq %rdx, %r15
movq %rdx, %rdi
callq 0x2ed5c3
testq %rax, %rax
je 0x2fa61c
movq %rax, %r14
movq %rax, %rdi
callq 0x2ec1f7
movq %rax, %r15
movq %r14, %rdi
callq 0x2ed666
movl 0x4(%rsp), %ecx
jmp 0x2fa298
xorl %r15d, %r15d
movl %ebx, 0x1960c6(%rip)    # 0x490364
movslq %ecx, %rbx
movl $0x8, %esi
movq %rbx, %rdi
callq 0x30ed0
movq %rax, %r14
movl $0x20, %esi
movq %rbx, %rdi
callq 0x30ed0
movq %rax, 0x18(%rsp)
movl $0x8, %esi
movq %rbx, %rdi
callq 0x30ed0
movq %rax, %r13
testb $0x1, 0x14(%rsp)
movq %r14, 0x30(%rsp)
movq %rax, 0x20(%rsp)
movq %r12, 0x28(%rsp)
movq %rbx, 0x50(%rsp)
movq %r15, 0x38(%rsp)
jne 0x2fa30a
movq $0x0, 0x48(%rsp)
movq $0x0, 0x40(%rsp)
jmp 0x2fa3f6
movl $0x8, %esi
movq %rbx, %rdi
callq 0x30ed0
movq %rax, %r14
movl $0x4, %esi
movq %rbx, %rdi
callq 0x30ed0
movq %rax, 0x40(%rsp)
testl %ebx, %ebx
movq %r14, 0x48(%rsp)
je 0x2fa56b
movl 0x4(%rsp), %ebx
xorl %r15d, %r15d
movq (%r12,%r15,8), %r13
movq %r13, %rdi
callq 0x2ee50
movq %rax, %rbp
cmpl $0x5, %ebp
jl 0x2fa379
movl %ebp, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
leaq (%rax,%r13), %rdi
addq $-0x4, %rdi
leaq 0xbef08(%rip), %rsi     # 0x3b9272
callq 0x308e0
leal -0x4(%rbp), %ecx
testl %eax, %eax
cmovnel %ebp, %ecx
movl %ecx, %ebp
movl %ebp, %eax
movl %ebp, %r12d
sarl $0x1f, %r12d
andl %ebp, %r12d
leaq (%rax,%r13), %rcx
decq %rcx
movl %ebp, %eax
testl %eax, %eax
jle 0x2fa3a2
decl %eax
cmpb $0x2f, (%rcx)
leaq -0x1(%rcx), %rcx
jne 0x2fa38e
incl %eax
movl %eax, %r12d
subl %r12d, %ebp
leal 0x1(%rbp), %eax
movslq %eax, %rdi
movl $0x1, %esi
callq 0x30ed0
movq %rax, (%r14,%r15,8)
movq 0x40(%rsp), %rcx
movl %ebp, (%rcx,%r15,4)
movslq %r12d, %rcx
addq %rcx, %r13
movslq %ebp, %rdx
movq %rax, %rdi
movq %r13, %rsi
callq 0x31120
incq %r15
cmpq %rbx, %r15
movq 0x28(%rsp), %r12
jne 0x2fa340
movq 0x30(%rsp), %r14
movq 0x20(%rsp), %r13
movq 0x38(%rsp), %r15
movl 0x4(%rsp), %eax
testl %eax, %eax
sete 0x3(%rsp)
je 0x2fa51d
movl %eax, %eax
movq %rax, 0x90(%rsp)
xorl %ebp, %ebp
movq $0x0, 0x8(%rsp)
movq (%r12,%rbp,8), %rdi
leaq 0x45214(%rip), %rsi     # 0x33f63b
callq 0x2e5723
movq %rax, (%r14,%rbp,8)
testq %rax, %rax
je 0x2fa629
movq %rax, %rdi
callq 0x2e811e
movq %rax, %rcx
testq %rbp, %rbp
je 0x2fa505
movq %rbp, 0x80(%rsp)
movq 0x8(%rsp), %rax
movl (%rax), %eax
movq %rcx, 0x88(%rsp)
movl (%rcx), %ecx
cmpl %eax, %ecx
movl %eax, 0x60(%rsp)
movl %ecx, 0x5c(%rsp)
cmovll %ecx, %eax
testl %eax, %eax
jle 0x2fa4b5
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %r13
movq 0x88(%rsp), %rcx
movq 0x8(%rcx), %r14
movl %eax, %ebp
xorl %r15d, %r15d
movq (%r13,%r15,8), %r12
movq (%r14,%r15,8), %rbx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x308e0
testl %eax, %eax
jne 0x2fa532
incq %r15
cmpq %r15, %rbp
jne 0x2fa491
movl 0x60(%rsp), %ecx
movl 0x5c(%rsp), %edx
cmpl %ecx, %edx
movq 0x88(%rsp), %rdi
jle 0x2fa4e2
movq 0x8(%rsp), %rax
movl %edx, (%rax)
movl %ecx, (%rdi)
movups 0x8(%rdi), %xmm0
movups 0x8(%rax), %xmm1
movups %xmm0, 0x8(%rax)
movups %xmm1, 0x8(%rdi)
callq 0x2e809a
movq 0x30(%rsp), %r14
movq 0x20(%rsp), %r13
movq 0x28(%rsp), %r12
movq 0x38(%rsp), %r15
movq 0x80(%rsp), %rbp
jmp 0x2fa50a
movq %rcx, 0x8(%rsp)
incq %rbp
cmpq 0x90(%rsp), %rbp
jne 0x2fa41c
jmp 0x2fa579
movq $0x0, 0x8(%rsp)
movb $0x1, 0x3(%rsp)
movq 0x18(%rsp), %r14
jmp 0x2fa582
movq 0x18ba87(%rip), %rax    # 0x485fc0
movq (%rax), %rdi
movq 0x28(%rsp), %rax
movq 0x80(%rsp), %rcx
movq (%rax,%rcx,8), %r8
leaq 0xbe813(%rip), %rsi     # 0x3b8d67
movq %r12, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x31920
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x2faa78
movb $0x1, 0x3(%rsp)
movq $0x0, 0x8(%rsp)
movq 0x18(%rsp), %r14
movl 0x4(%rsp), %eax
movq 0xd0(%rsp), %r12
testq %r15, %r15
je 0x2fa6e3
movl (%r15), %r15d
testl %r15d, %r15d
jle 0x2fa6ab
movq 0x8(%rsp), %rax
cmpl %r15d, (%rax)
jne 0x2fa674
leaq 0xbe857(%rip), %rbp     # 0x3b8e0b
xorl %r13d, %r13d
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax,%r13,8), %rdi
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax,%r13,8), %rbx
movq %rbx, %rsi
callq 0x308e0
testl %eax, %eax
jne 0x2fa5ed
incq %r13
movslq %r15d, %rax
cmpq %rax, %r13
jl 0x2fa5b7
jmp 0x2fa6ab
movq 0x18b9cc(%rip), %rax    # 0x485fc0
movq (%rax), %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movq 0x70(%rsp), %rcx
xorl %eax, %eax
callq 0x31920
testq %r12, %r12
je 0x2fa561
movq 0x8(%rsp), %rax
movl (%rax), %r15d
jmp 0x2fa5dd
movq %r15, %rdi
callq 0xa9397
jmp 0x2fa561
movq 0x18b990(%rip), %rax    # 0x485fc0
movq (%rax), %rdi
movq (%r12,%rbp,8), %rdx
leaq 0xbe702(%rip), %rsi     # 0x3b8d40
xorl %eax, %eax
callq 0x31920
testq %rbp, %rbp
je 0x2fa65d
xorl %ebx, %ebx
movq (%r14,%rbx,8), %rdi
callq 0x2e582b
incq %rbx
cmpq %rbx, %rbp
jne 0x2fa64c
movq %r14, %rdi
callq 0x32018
movq 0x18(%rsp), %rdi
callq 0x32018
jmp 0x2fa561
movq 0x18b945(%rip), %rax    # 0x485fc0
movq (%rax), %rdi
leaq 0xbe72e(%rip), %rsi     # 0x3b8db3
movq 0x70(%rsp), %rdx
xorl %eax, %eax
callq 0x31920
testq %r12, %r12
je 0x2fa561
movq 0x8(%rsp), %rax
movl (%rax), %r15d
testl %r15d, %r15d
jg 0x2fa5ad
movq 0x8(%rsp), %rdx
movslq 0x30(%rdx), %rax
movq 0x38(%rsp), %rdi
movq 0x30(%rdi), %rcx
movq %rcx, 0x30(%rdx)
movq %rax, 0x30(%rdi)
movq 0x40(%rdx), %rax
movq 0x40(%rdi), %rcx
movq %rcx, 0x40(%rdx)
movq %rax, 0x40(%rdi)
callq 0x2e809a
movl 0x4(%rsp), %eax
movq 0x20(%rsp), %r13
testq %r12, %r12
je 0x2fa75e
leaq 0x6c(%rsp), %rdx
leaq 0x68(%rsp), %rcx
leaq 0x64(%rsp), %r8
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x2e79eb
testl %eax, %eax
js 0x2faae6
cmpl $0x0, 0x4(%rsp)
movq 0x28(%rsp), %r12
jle 0x2fa755
movl 0x4(%rsp), %r14d
xorl %r15d, %r15d
movq (%r12,%r15,8), %rdi
callq 0x2ef9e6
movq %rax, %rbx
movl 0x6c(%rsp), %esi
movl 0x68(%rsp), %edx
movl 0x64(%rsp), %ecx
movq %rax, %rdi
callq 0x2efd33
movq %rax, (%r13,%r15,8)
movq %rbx, %rdi
callq 0x2ef15b
incq %r15
cmpq %r15, %r14
jne 0x2fa720
movq 0x18(%rsp), %r14
movl 0x4(%rsp), %eax
testl %eax, %eax
jle 0x2fa7f4
movl %eax, %ebx
movq %r14, %r13
addq $0x18, %r13
xorl %ebp, %ebp
xorl %r15d, %r15d
movl %ebp, -0x18(%r13)
movl $0x1, %edi
movl $0x38, %esi
callq 0x30ed0
movq %rax, %r12
movq %rax, (%r13)
movq 0x30(%rsp), %rax
movq (%rax,%rbp,8), %rdi
movq 0x20(%rsp), %rax
movq (%rax,%rbp,8), %rsi
movq %r12, %rdx
callq 0x2f0565
testl %eax, %eax
js 0x2fa7db
movl (%r12), %eax
movl 0x4(%r12), %ecx
shlq $0x20, %rax
leal 0x2(,%rcx,2), %ecx
orq %rax, %rcx
movq 0x8(%r12), %rax
shrq $0x24, %rax
andl $0x1, %eax
orq %rcx, %rax
movq %r15, -0x8(%r13)
incq %r15
jmp 0x2fa7e2
movq $-0x1, %rax
movq %rax, -0x10(%r13)
incq %rbp
addq $0x20, %r13
cmpq %rbp, %rbx
jne 0x2fa774
jmp 0x2fa7f7
xorl %r15d, %r15d
movl 0x14(%rsp), %ecx
testb $0x2, %cl
jne 0x2fa828
movq 0x78(%rsp), %rdi
movb (%rdi), %al
testb $0x4, %cl
movq 0x50(%rsp), %r13
jne 0x2fa84a
cmpb $0x2d, %al
jne 0x2fa81f
cmpb $0x0, 0x1(%rdi)
je 0x2faaac
leaq 0x7c2b4(%rip), %rsi     # 0x376ada
jmp 0x2fa85f
movq 0x78(%rsp), %rdi
cmpb $0x2d, (%rdi)
movq 0x50(%rsp), %r13
jne 0x2fa841
cmpb $0x0, 0x1(%rdi)
je 0x2faa8a
leaq 0xbe655(%rip), %rsi     # 0x3b8e9d
jmp 0x2fa85f
cmpb $0x2d, %al
jne 0x2fa858
cmpb $0x0, 0x1(%rdi)
je 0x2faac4
leaq 0xbe641(%rip), %rsi     # 0x3b8ea0
callq 0x2e5723
movq %rax, %r12
testq %rax, %rax
je 0x2faaa2
movq %r12, %rdi
movq 0x8(%rsp), %rbx
movq %rbx, %rsi
callq 0x2e82e4
movq %rbx, %rdi
callq 0x2e809a
cmpl $0x2, 0x4(%rsp)
jb 0x2fa8ac
movq %r13, %rbx
shrq %rbx
decq %rbx
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x2f9624
addq $-0x1, %rbx
jb 0x2fa898
cmpq $-0x1, 0x8(%r14)
je 0x2fa9e1
leaq 0xba24a(%rip), %r13     # 0x3b4b08
movq 0x18(%r14), %rbp
testb $0x1, 0x14(%rsp)
je 0x2fa90a
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2e6f6c
testq %rax, %rax
je 0x2fa8e4
movq %rbp, %rdi
movq %rax, %rsi
callq 0x2e70dd
movslq (%r14), %rax
movq 0x40(%rsp), %rcx
movl (%rcx,%rax,4), %ecx
incl %ecx
movq 0x48(%rsp), %rdx
movq (%rdx,%rax,8), %r8
movq %rbp, %rdi
movq %r13, %rsi
movl $0x5a, %edx
callq 0x2e6eb0
movl 0x24(%rbp), %edx
movq 0x30(%rbp), %rcx
movq %r12, %rdi
movq %rbp, %rsi
callq 0x2e87c6
movq %r14, %rbx
movslq (%r14), %r14
movq 0x30(%rsp), %rax
movq (%rax,%r14,8), %rdi
movq 0x20(%rsp), %rax
movq (%rax,%r14,8), %rsi
movq %rbp, %rdx
callq 0x2f0565
testl %eax, %eax
js 0x2fa972
movl (%rbp), %eax
movl 0x4(%rbp), %ecx
shlq $0x20, %rax
leal 0x2(,%rcx,2), %ecx
orq %rax, %rcx
movq 0x8(%rbp), %rax
shrq $0x24, %rax
andl $0x1, %eax
orq %rcx, %rax
movq %rax, 0x8(%rbx)
movq %r15, 0x10(%rbx)
incq %r15
movq %rbx, %r14
jmp 0x2fa99d
cmpl $-0x1, %eax
jne 0x2fa9b9
movq 0x18(%rsp), %r14
movq $-0x1, 0x8(%r14)
movq 0x30(%rbp), %rdi
callq 0x32018
movq %rbp, %rdi
callq 0x32018
movq $0x0, 0x18(%r14)
xorl %edi, %edi
movq 0x50(%rsp), %rsi
movq %r14, %rdx
callq 0x2f9624
cmpq $-0x1, 0x8(%r14)
jne 0x2fa8be
jmp 0x2fa9e1
movq 0x18b600(%rip), %rax    # 0x485fc0
movq (%rax), %rdi
movq 0x28(%rsp), %rax
movq (%rax,%r14,8), %rdx
leaq 0xbe4f6(%rip), %rsi     # 0x3b8ec9
xorl %eax, %eax
callq 0x31920
movq 0x18(%rsp), %r14
jmp 0x2fa99d
testb $0x1, 0x14(%rsp)
movq 0x30(%rsp), %r15
movq 0x20(%rsp), %r13
je 0x2faa29
cmpb $0x0, 0x3(%rsp)
movq 0x48(%rsp), %rbp
jne 0x2faa17
movl 0x4(%rsp), %ebx
xorl %r14d, %r14d
movq (%rbp,%r14,8), %rdi
callq 0x32018
incq %r14
cmpq %r14, %rbx
jne 0x2faa05
movq %rbp, %rdi
callq 0x32018
movq 0x40(%rsp), %rdi
callq 0x32018
cmpb $0x0, 0x3(%rsp)
movl 0x4(%rsp), %eax
jne 0x2faa54
movl %eax, %ebx
xorl %r14d, %r14d
movq (%r13,%r14,8), %rdi
callq 0x2f0549
movq (%r15,%r14,8), %rdi
callq 0x2e582b
incq %r14
cmpq %r14, %rbx
jne 0x2faa39
movq %r12, %rdi
callq 0x2e582b
movq %r15, %rdi
callq 0x32018
movq 0x18(%rsp), %rdi
callq 0x32018
movq %r13, %rdi
callq 0x32018
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18b55f(%rip), %rax    # 0x485ff0
movq (%rax), %rdi
callq 0x2d230
leaq 0xbe3fd(%rip), %rsi     # 0x3b8e9d
jmp 0x2faada
callq 0xa93c6
jmp 0x2fa561
movq 0x18b53d(%rip), %rax    # 0x485ff0
movq (%rax), %rdi
callq 0x2d230
leaq 0x7c018(%rip), %rsi     # 0x376ada
jmp 0x2faada
movq 0x18b525(%rip), %rax    # 0x485ff0
movq (%rax), %rdi
callq 0x2d230
leaq 0xbe3c6(%rip), %rsi     # 0x3b8ea0
movl %eax, %edi
callq 0x2e5a78
jmp 0x2fa864
movq 0x18b4d3(%rip), %rax    # 0x485fc0
movq (%rax), %rdi
leaq 0xbe35b(%rip), %rsi     # 0x3b8e52
leaq 0xbe390(%rip), %rdx     # 0x3b8e8e
xorl %eax, %eax
callq 0x31920
jmp 0x2fa561