// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/padding.c
// Function: bam_pad2unpad
int bam_pad2unpad(samfile_t *in, samfile_t *out, faidx_t *fai)
{
	bam_header_t *h = 0;
	bam1_t *b = 0;
	kstring_t r, q;
	int r_tid = -1;
	uint32_t *cigar2 = 0;
	int ret = 0, n2 = 0, m2 = 0, *posmap = 0;

	b = bam_init1();
	r.l = r.m = q.l = q.m = 0; r.s = q.s = 0;
	int read_ret;
	h = in->header;
	while ((read_ret = samread(in, b)) >= 0) { // read one alignment from `in'
		uint32_t *cigar = bam1_cigar(b);
		n2 = 0;
		if (b->core.pos == 0 && b->core.tid >= 0 && strcmp(bam1_qname(b), h->target_name[b->core.tid]) == 0) {
			// fprintf(stderr, "[depad] Found embedded reference '%s'\n", bam1_qname(b));
			r_tid = b->core.tid;
			unpad_seq(b, &r);
			if (h->target_len[r_tid] != r.l) {
				fprintf(stderr, "[depad] ERROR: (Padded) length of '%s' is %d in BAM header, but %ld in embedded reference\n", bam1_qname(b), h->target_len[r_tid], r.l);
				return -1;
			}
			if (fai) {
				// Check the embedded reference matches the FASTA file
				if (load_unpadded_ref(fai, h->target_name[b->core.tid], h->target_len[b->core.tid], &q)) {
					fprintf(stderr, "[depad] ERROR: Failed to load embedded reference '%s' from FASTA\n", h->target_name[b->core.tid]);
					return -1;
				}
				assert(r.l == q.l);
				int i;
				for (i = 0; i < r.l; ++i) {
					if (r.s[i] != q.s[i]) {
						// Show gaps as ASCII 45
						fprintf(stderr, "[depad] ERROR: Embedded sequence and reference FASTA don't match for %s base %i, '%c' vs '%c'\n",
							h->target_name[b->core.tid], i+1,
							r.s[i] ? bam_nt16_rev_table[(int)r.s[i]] : 45,
							q.s[i] ? bam_nt16_rev_table[(int)q.s[i]] : 45);
						return -1;
					}
				}
			}
			write_cigar(cigar2, n2, m2, bam_cigar_gen(b->core.l_qseq, BAM_CMATCH));
			replace_cigar(b, n2, cigar2);
			posmap = update_posmap(posmap, r);
		} else if (b->core.n_cigar > 0) {
			int i, k, op;
			if (b->core.tid < 0) {
				fprintf(stderr, "[depad] ERROR: Read '%s' has CIGAR but no RNAME\n", bam1_qname(b));
				return -1;
			} else if (b->core.tid == r_tid) {
				; // good case, reference available
				//fprintf(stderr, "[depad] Have ref '%s' for read '%s'\n", h->target_name[b->core.tid], bam1_qname(b));
			} else if (fai) {
				if (load_unpadded_ref(fai, h->target_name[b->core.tid], h->target_len[b->core.tid], &r)) {
					fprintf(stderr, "[depad] ERROR: Failed to load '%s' from reference FASTA\n", h->target_name[b->core.tid]);
					return -1;
				}
				posmap = update_posmap(posmap, r);
				r_tid = b->core.tid;
				// fprintf(stderr, "[depad] Loaded %s from FASTA file\n", h->target_name[b->core.tid]);
			} else {				
				fprintf(stderr, "[depad] ERROR: Missing %s embedded reference sequence (and no FASTA file)\n", h->target_name[b->core.tid]);
				return -1;
			}
			unpad_seq(b, &q);
			if (bam_cigar_op(cigar[0]) == BAM_CSOFT_CLIP) {
				write_cigar(cigar2, n2, m2, cigar[0]);
			} else if (bam_cigar_op(cigar[0]) == BAM_CHARD_CLIP) {
				write_cigar(cigar2, n2, m2, cigar[0]);
				if (b->core.n_cigar > 2 && bam_cigar_op(cigar[1]) == BAM_CSOFT_CLIP) {
					write_cigar(cigar2, n2, m2, cigar[1]);
				}
			}
			/* Determine CIGAR operator for each base in the aligned read */
			for (i = 0, k = b->core.pos; i < q.l; ++i, ++k)
				q.s[i] = q.s[i]? (r.s[k]? BAM_CMATCH : BAM_CINS) : (r.s[k]? BAM_CDEL : BAM_CPAD);
			/* Include any pads if starts with an insert */
			if (q.s[0] == BAM_CINS) {
				for (k = 0; k+1 < b->core.pos && !r.s[b->core.pos - k - 1]; ++k);
				if (k) write_cigar(cigar2, n2, m2, bam_cigar_gen(k, BAM_CPAD));
			}
			/* Count consecutive CIGAR operators to turn into a CIGAR string */
			for (i = k = 1, op = q.s[0]; i < q.l; ++i) {
				if (op != q.s[i]) {
					write_cigar(cigar2, n2, m2, bam_cigar_gen(k, op));
					op = q.s[i]; k = 1;
				} else ++k;
			}
			write_cigar(cigar2, n2, m2, bam_cigar_gen(k, op));
			if (bam_cigar_op(cigar[b->core.n_cigar-1]) == BAM_CSOFT_CLIP) {
				write_cigar(cigar2, n2, m2, cigar[b->core.n_cigar-1]);
                        } else if (bam_cigar_op(cigar[b->core.n_cigar-1]) == BAM_CHARD_CLIP) {
				if (b->core.n_cigar > 2 && bam_cigar_op(cigar[b->core.n_cigar-2]) == BAM_CSOFT_CLIP) {
					write_cigar(cigar2, n2, m2, cigar[b->core.n_cigar-2]);
			  	}
				write_cigar(cigar2, n2, m2, cigar[b->core.n_cigar-1]);
			}
			/* Remove redundant P operators between M/X/=/D operators, e.g. 5M2P10M -> 15M */
			int pre_op, post_op;
			for (i = 2; i < n2; ++i)
				if (bam_cigar_op(cigar2[i-1]) == BAM_CPAD) {
					pre_op = bam_cigar_op(cigar2[i-2]);
					post_op = bam_cigar_op(cigar2[i]);
					/* Note don't need to check for X/= as code above will use M only */
					if ((pre_op == BAM_CMATCH || pre_op == BAM_CDEL) && (post_op == BAM_CMATCH || post_op == BAM_CDEL)) {
						/* This is a redundant P operator */
						cigar2[i-1] = 0; // i.e. 0M
						/* If had same operator either side, combine them in post_op */
						if (pre_op == post_op) {
							/* If CIGAR M, could treat as simple integers since BAM_CMATCH is zero*/
							cigar2[i] = bam_cigar_gen(bam_cigar_oplen(cigar2[i-2]) + bam_cigar_oplen(cigar2[i]), post_op);
							cigar2[i-2] = 0; // i.e. 0M
						}
					}
				}
			/* Remove the zero'd operators (0M) */
			for (i = k = 0; i < n2; ++i)
				if (cigar2[i]) cigar2[k++] = cigar2[i];
			n2 = k;
			replace_cigar(b, n2, cigar2);
			b->core.pos = posmap[b->core.pos];
			if (b->core.mtid < 0 || b->core.mpos < 0) {
				/* Nice case, no mate to worry about*/
				// fprintf(stderr, "[depad] Read '%s' mate not mapped\n", bam1_qname(b));
				/* TODO - Warning if FLAG says mate should be mapped? */
				/* Clean up funny input where mate position is given but mate reference is missing: */
				b->core.mtid = -1;
				b->core.mpos = -1;
			} else if (b->core.mtid == b->core.tid) {
				/* Nice case, same reference */
				// fprintf(stderr, "[depad] Read '%s' mate mapped to same ref\n", bam1_qname(b));
				b->core.mpos = posmap[b->core.mpos];
			} else {
				/* Nasty case, Must load alternative posmap */
				// fprintf(stderr, "[depad] Loading reference '%s' temporarily\n", h->target_name[b->core.mtid]);
				if (!fai) {
					fprintf(stderr, "[depad] ERROR: Needed reference %s sequence for mate (and no FASTA file)\n", h->target_name[b->core.mtid]);
					return -1;
				}
				/* Temporarily load the other reference sequence */
				if (load_unpadded_ref(fai, h->target_name[b->core.mtid], h->target_len[b->core.mtid], &r)) {
					fprintf(stderr, "[depad] ERROR: Failed to load '%s' from reference FASTA\n", h->target_name[b->core.mtid]);
					return -1;
				}
				posmap = update_posmap(posmap, r);
				b->core.mpos = posmap[b->core.mpos];
				/* Restore the reference and posmap*/
				if (load_unpadded_ref(fai, h->target_name[b->core.tid], h->target_len[b->core.tid], &r)) {
					fprintf(stderr, "[depad] ERROR: Failed to load '%s' from reference FASTA\n", h->target_name[b->core.tid]);
					return -1;
				}
				posmap = update_posmap(posmap, r);
			}
		}
		samwrite(out, b);
	}
	if (read_ret < -1) {
		fprintf(stderr, "[depad] truncated file.\n");
		ret = 1;
	}
	free(r.s); free(q.s); free(posmap);
	bam_destroy1(b);
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdx, %r14
movq %rsi, 0x90(%rsp)
movq %rdi, %rbx
movl $0x1, %edi
movl $0x38, %esi
callq 0x3610
movq %rax, %r12
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x20(%rsp)
xorl %eax, %eax
movq %rax, 0x70(%rsp)
movq $0x0, 0x58(%rsp)
movq %rax, 0x30(%rsp)
movq 0x10(%rbx), %r15
movq %rbx, 0x88(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x283b1
testl %eax, %eax
js 0x1c5cc
leaq 0x8(%r15), %rax
movq %rax, 0x8(%rsp)
leaq 0x14(%r12), %rax
movq %rax, 0x78(%rsp)
movq $0x0, (%rsp)
movl $0xffffffff, 0x1c(%rsp) # imm = 0xFFFFFFFF
xorl %ecx, %ecx
movq %r14, 0x48(%rsp)
xorl %r13d, %r13d
movq %r15, 0x40(%rsp)
movq %r12, 0x80(%rsp)
movq %rcx, 0x10(%rsp)
movq 0x8(%r12), %r14
movq 0x30(%r12), %rbp
cmpl $0x0, 0x4(%r12)
je 0x1bf2e
movq %r14, %rax
shrq $0x30, %rax
je 0x1c59d
movslq (%r12), %rax
testq %rax, %rax
js 0x1c695
cmpl 0x1c(%rsp), %eax
je 0x1bec9
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x1c6ab
movq 0x8(%r15), %rcx
movq 0x10(%r15), %rdx
movq (%rcx,%rax,8), %rsi
movl (%rdx,%rax,4), %edx
leaq 0x20(%rsp), %rcx
callq 0x1bb04
testl %eax, %eax
jne 0x1c6ca
movq 0x20(%rsp), %rbx
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %r15
shlq $0x2, %rsi
movq (%rsp), %rdi
callq 0x3720
movq %rax, (%rsp)
testq %rbx, %rbx
je 0x1bec1
xorl %eax, %eax
xorl %ecx, %ecx
movq (%rsp), %rdx
movl %ecx, (%rdx,%rax,4)
cmpb $0x1, (%r15,%rax)
sbbl $-0x1, %ecx
incq %rax
cmpq %rax, %rbx
jne 0x1beaa
movl (%r12), %eax
movl %eax, 0x1c(%rsp)
shrl $0x18, %r14d
addq %r14, %rbp
movq %rbp, %r14
movq %r12, %rdi
leaq 0x60(%rsp), %rsi
callq 0x1c777
movl (%rbp), %eax
movl %eax, %ecx
andl $0xf, %ecx
cmpl $0x5, %ecx
je 0x1c075
cmpl $0x4, %ecx
movq %r13, %r9
movq 0x10(%rsp), %r10
jne 0x1c0f1
testl %r10d, %r10d
jne 0x1bf20
movl $0x10, %esi
movq %r9, %rdi
callq 0x3720
movq %rax, %r9
movl (%r14), %eax
movl $0x4, %r10d
movl %eax, (%r9)
movl $0x1, %r15d
jmp 0x1c0ed
movslq (%r12), %rbx
testq %rbx, %rbx
js 0x1be32
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq (%rax,%rbx,8), %rsi
movq %rbp, %rdi
callq 0x35a0
testl %eax, %eax
jne 0x1be32
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
callq 0x1c777
movq 0x10(%r15), %rax
movl (%rax,%rbx,4), %r15d
movq 0x20(%rsp), %r8
cmpq %r15, %r8
jne 0x1c727
cmpq $0x0, 0x48(%rsp)
movq %r13, %rdx
movq 0x10(%rsp), %r8
je 0x1bff3
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movslq (%r12), %rdx
movq (%rcx,%rdx,8), %rsi
movl (%rax,%rdx,4), %edx
movq 0x48(%rsp), %rdi
leaq 0x60(%rsp), %rcx
callq 0x1bb04
testl %eax, %eax
jne 0x1c749
cmpq %r15, 0x60(%rsp)
jne 0x1c758
testq %r15, %r15
movq %r13, %rdx
movq 0x10(%rsp), %r8
je 0x1bff3
movq 0x30(%rsp), %rsi
movq 0x70(%rsp), %rdi
xorl %ecx, %ecx
movsbq (%rsi,%rcx), %r14
movsbq (%rdi,%rcx), %rax
cmpb %al, %r14b
jne 0x1c635
incq %rcx
cmpq %rcx, %r15
jne 0x1bfd8
testl %r8d, %r8d
jne 0x1c012
movl $0x10, %esi
movq %rdx, %rdi
callq 0x3720
movq %rax, %rdx
movl $0x4, %eax
movq %rax, 0x10(%rsp)
movl 0x10(%r12), %eax
shll $0x4, %eax
movl %eax, (%rdx)
movq %r12, %rdi
movl $0x1, %esi
movq %rdx, %r13
callq 0x1c981
movq 0x20(%rsp), %r14
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %r15
shlq $0x2, %rsi
movq (%rsp), %rdi
callq 0x3720
movq %rax, (%rsp)
testq %r14, %r14
je 0x1c06c
xorl %eax, %eax
xorl %ecx, %ecx
movq (%rsp), %rdx
movl %ecx, (%rdx,%rax,4)
cmpb $0x1, (%r15,%rax)
sbbl $-0x1, %ecx
incq %rax
cmpq %rax, %r14
jne 0x1c055
movl %ebx, 0x1c(%rsp)
jmp 0x1c598
movq 0x10(%rsp), %r10
testl %r10d, %r10d
movq %r13, %r9
jne 0x1c09b
movl $0x10, %esi
movq %r9, %rdi
callq 0x3720
movq %rax, %r9
movl (%r14), %eax
movl $0x4, %r10d
movl %eax, (%r9)
movl $0x1, %r15d
movabsq $0x2ffffffffffff, %rax  # imm = 0x2FFFFFFFFFFFF
cmpq %rax, 0x8(%r12)
jbe 0x1c0ed
movl 0x4(%r14), %eax
movl %eax, %ecx
andl $0xf, %ecx
cmpl $0x4, %ecx
jne 0x1c0ed
cmpl $0x1, %r10d
jne 0x1c0e3
movl $0x8, %esi
movq %r9, %rdi
callq 0x3720
movq %rax, %r9
movl 0x4(%r14), %eax
movl $0x2, %r10d
movl %eax, 0x4(%r9)
movl $0x2, %r15d
xorl %eax, %eax
jmp 0x1c0f6
xorl %r15d, %r15d
movb $0x1, %al
movq 0x60(%rsp), %rbp
movq 0x70(%rsp), %rbx
testq %rbp, %rbp
je 0x1c13d
movslq 0x4(%r12), %rcx
addq 0x30(%rsp), %rcx
xorl %edx, %edx
xorl %esi, %esi
cmpb $0x0, (%rcx,%rdx)
sete %sil
leal (,%rsi,4), %edi
orb $0x2, %dil
cmpb $0x0, (%rbx,%rdx)
movzbl %dil, %edi
cmovnel %esi, %edi
movb %dil, (%rbx,%rdx)
incq %rdx
cmpq %rdx, %rbp
jne 0x1c111
movq %r14, 0x50(%rsp)
movb (%rbx), %cl
cmpb $0x1, %cl
jne 0x1c1d7
movl 0x4(%r12), %esi
movq 0x30(%rsp), %rcx
cmpl $0x2, %esi
movl $0x1, %edx
cmovgel %esi, %edx
decl %edx
decl %esi
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movq %rdx, %rdi
subq $0x1, %rdi
jb 0x1c188
movslq %esi, %r8
incl %r14d
leal -0x1(%r8), %esi
cmpb $0x0, (%rcx,%r8)
je 0x1c16f
jmp 0x1c18b
movl %edx, %r14d
testl %r14d, %r14d
je 0x1c1d5
cmpl %r10d, %r15d
jne 0x1c1bf
movq %r15, %r13
addl %r15d, %r15d
testb %al, %al
movl $0x4, %eax
cmovnel %eax, %r15d
leal (,%r15,4), %esi
movq %r9, %rdi
callq 0x3720
movq %r15, %r10
movq %r13, %r15
movq %rax, %r9
shll $0x4, %r14d
orl $0x6, %r14d
movl %r15d, %eax
incl %r15d
movl %r14d, (%r9,%rax,4)
movb (%rbx), %cl
jmp 0x1c1d7
movb $0x1, %cl
movsbl %cl, %r13d
movl $0x10, %r14d
cmpq $0x2, %rbp
jb 0x1c272
movl $0x1, %r14d
movl $0x1, %r12d
movsbl (%rbx,%r12), %eax
cmpl %eax, %r13d
jne 0x1c206
incl %r14d
jmp 0x1c25e
cmpl %r10d, %r15d
jne 0x1c242
movq %r15, 0x10(%rsp)
movq %rbp, %r15
leal (%r10,%r10), %ebp
testl %r10d, %r10d
movl $0x4, %eax
cmovel %eax, %ebp
leal (,%rbp,4), %eax
movslq %eax, %rsi
movq %r9, %rdi
callq 0x3720
movq %rax, %r9
movl %ebp, %r10d
movq %r15, %rbp
movq 0x10(%rsp), %r15
shll $0x4, %r14d
orl %r13d, %r14d
movslq %r15d, %rax
incl %r15d
movl %r14d, (%r9,%rax,4)
movsbl (%rbx,%r12), %r13d
movl $0x1, %r14d
incq %r12
cmpq %r12, %rbp
jne 0x1c1f7
shll $0x4, %r14d
movq 0x80(%rsp), %r12
cmpl %r10d, %r15d
movq 0x40(%rsp), %rbp
jne 0x1c2a3
leal (%r15,%r15), %ebx
testl %r15d, %r15d
movl $0x4, %eax
cmovel %eax, %ebx
leal (,%rbx,4), %eax
movslq %eax, %rsi
movq %r9, %rdi
callq 0x3720
movq %rbx, %r10
movq %rax, %r9
orl %r13d, %r14d
leal 0x1(%r15), %ebx
movq %r15, %r13
movslq %r15d, %rax
movl %r14d, (%r9,%rax,4)
movq 0x8(%r12), %rcx
movq %rcx, %rax
shrq $0x30, %rax
movq 0x50(%rsp), %rsi
movl -0x4(%rsi,%rax,4), %edx
andl $0xf, %edx
cmpl $0x5, %edx
je 0x1c31f
cmpl $0x4, %edx
movq %rbp, %r15
jne 0x1c3d4
cmpl %r10d, %ebx
jne 0x1c316
leal (%r10,%r10), %r14d
testl %r10d, %r10d
movl $0x4, %eax
cmovel %eax, %r14d
leal (,%r14,4), %eax
movslq %eax, %rsi
movq %r9, %rdi
callq 0x3720
movq %rax, %r9
movzwl 0xe(%r12), %eax
movl %r14d, %r10d
movq 0x50(%rsp), %rsi
addl $0x2, %r13d
jmp 0x1c3c6
movabsq $0x2ffffffffffff, %rdx  # imm = 0x2FFFFFFFFFFFF
cmpq %rdx, %rcx
movq %rbp, %r15
jbe 0x1c38a
leal -0x2(%rax), %ecx
movl (%rsi,%rcx,4), %ecx
andl $0xf, %ecx
cmpl $0x4, %ecx
jne 0x1c38a
cmpl %r10d, %ebx
jne 0x1c378
leal (%r10,%r10), %r14d
testl %r10d, %r10d
movl $0x4, %eax
cmovel %eax, %r14d
leal (,%r14,4), %eax
movslq %eax, %rsi
movq %r9, %rdi
callq 0x3720
movq %rax, %r9
movzwl 0xe(%r12), %eax
movl %r14d, %r10d
movq 0x50(%rsp), %rsi
movl -0x8(%rsi,%rax,4), %eax
addl $0x2, %r13d
movslq %ebx, %rcx
movl %eax, (%r9,%rcx,4)
movl %r13d, %ebx
cmpl %r10d, %ebx
jne 0x1c3bc
leal (%rbx,%rbx), %r14d
testl %ebx, %ebx
movl $0x4, %eax
cmovel %eax, %r14d
leal (,%r14,4), %eax
movslq %eax, %rsi
movq %r9, %rdi
callq 0x3720
movq %r14, %r10
movq 0x50(%rsp), %rsi
movq %rax, %r9
movzwl 0xe(%r12), %eax
leal 0x1(%rbx), %r13d
movl -0x4(%rsi,%rax,4), %eax
movslq %ebx, %rcx
movl %eax, (%r9,%rcx,4)
movl %r13d, %ebx
movl %ebx, %eax
cmpl $0x3, %ebx
jl 0x1c42d
movl $0x2, %ecx
movl -0x4(%r9,%rcx,4), %edx
andl $0xf, %edx
cmpl $0x6, %edx
jne 0x1c425
movl -0x8(%r9,%rcx,4), %edx
movl (%r9,%rcx,4), %esi
movl %edx, %edi
orl %esi, %edi
testb $0xd, %dil
jne 0x1c425
movl $0x0, -0x4(%r9,%rcx,4)
movl %esi, %edi
xorl %edx, %edi
testb $0x2, %dil
jne 0x1c425
andl $-0x10, %edx
addl %edx, %esi
movl %esi, (%r9,%rcx,4)
movl $0x0, -0x8(%r9,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x1c3e0
testl %ebx, %ebx
jle 0x1c450
xorl %ecx, %ecx
xorl %esi, %esi
movl (%r9,%rcx,4), %edx
testl %edx, %edx
je 0x1c446
movslq %esi, %rdi
incl %esi
movl %edx, (%r9,%rdi,4)
incq %rcx
cmpq %rcx, %rax
jne 0x1c435
jmp 0x1c452
xorl %esi, %esi
movq %r10, 0x10(%rsp)
movq %r12, %rdi
movq %r9, %r13
movq %r9, %rdx
callq 0x1c981
movslq 0x4(%r12), %rax
movq (%rsp), %rcx
movl (%rcx,%rax,4), %eax
movl %eax, 0x4(%r12)
movslq 0x14(%r12), %rax
testq %rax, %rax
js 0x1c499
movslq 0x18(%r12), %rcx
testq %rcx, %rcx
js 0x1c499
cmpl (%r12), %eax
jne 0x1c4b3
movq (%rsp), %rax
movl (%rax,%rcx,4), %eax
jmp 0x1c4a9
movq 0x78(%rsp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x18(%r12)
jmp 0x1c59d
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x1c6d9
movq 0x8(%r15), %rcx
movq 0x10(%r15), %rdx
movq (%rcx,%rax,8), %rsi
movl (%rdx,%rax,4), %edx
leaq 0x20(%rsp), %rcx
callq 0x1bb04
testl %eax, %eax
jne 0x1c707
movq 0x20(%rsp), %r14
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %r15
shlq $0x2, %rsi
movq (%rsp), %rdi
callq 0x3720
movq %rax, %rbx
testq %r14, %r14
je 0x1c51d
xorl %eax, %eax
xorl %ecx, %ecx
movl %ecx, (%rbx,%rax,4)
cmpb $0x1, (%r15,%rax)
sbbl $-0x1, %ecx
incq %rax
cmpq %rax, %r14
jne 0x1c50a
movslq 0x18(%r12), %rax
movl (%rbx,%rax,4), %eax
movl %eax, 0x18(%r12)
movslq (%r12), %rax
movq 0x40(%rsp), %rdx
movq 0x8(%rdx), %rcx
movq 0x10(%rdx), %rdx
movq (%rcx,%rax,8), %rsi
movl (%rdx,%rax,4), %edx
movq 0x48(%rsp), %rdi
leaq 0x20(%rsp), %rcx
callq 0x1bb04
testl %eax, %eax
jne 0x1c718
movq 0x20(%rsp), %r14
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %r15
shlq $0x2, %rsi
movq %rbx, %rdi
callq 0x3720
movq %rax, (%rsp)
testq %r14, %r14
je 0x1c598
xorl %eax, %eax
xorl %ecx, %ecx
movq (%rsp), %rdx
movl %ecx, (%rdx,%rax,4)
cmpb $0x1, (%r15,%rax)
sbbl $-0x1, %ecx
incq %rax
cmpq %rax, %r14
jne 0x1c581
movq 0x40(%rsp), %r15
movq 0x90(%rsp), %rdi
movq %r12, %rsi
callq 0x283e6
movq 0x88(%rsp), %rdi
movq %r12, %rsi
callq 0x283b1
testl %eax, %eax
movq 0x10(%rsp), %rcx
jns 0x1be17
jmp 0x1c5d4
movq $0x0, (%rsp)
cmpl $-0x1, %eax
jne 0x1c624
movq 0x30(%rsp), %rdi
callq 0x3350
movq 0x70(%rsp), %rdi
callq 0x3350
movq (%rsp), %rdi
callq 0x3350
testq %r12, %r12
je 0x1c60d
movq 0x30(%r12), %rdi
callq 0x3350
movq %r12, %rdi
callq 0x3350
movq 0x58(%rsp), %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x45b6
movl $0x1, %eax
movq %rax, 0x58(%rsp)
jmp 0x1c5d9
movq 0x339ac(%rip), %rsi     # 0x4ffe8
movq 0x8(%rsp), %rdi
movq (%rdi), %r10
movslq (%r12), %r11
movl $0x2d, %r9d
movl $0x2d, %r8d
testb %r14b, %r14b
je 0x1c668
leaq 0x34a80(%rip), %rdi     # 0x510e0
movq (%rdi), %rdi
movsbl (%rdi,%r14), %r8d
movq (%rsi), %rdi
movq (%r10,%r11,8), %rdx
incq %rcx
testb %al, %al
je 0x1c685
leaq 0x34a63(%rip), %rsi     # 0x510e0
movq (%rsi), %rsi
movsbl (%rsi,%rax), %r9d
leaq 0x26136(%rip), %rsi     # 0x427c2
xorl %eax, %eax
callq 0x3750
jmp 0x1c6fd
movq 0x3394c(%rip), %rax     # 0x4ffe8
movq (%rax), %rdi
leaq 0x2617b(%rip), %rsi     # 0x42821
movq %rbp, %rdx
jmp 0x1c6f6
movq 0x33936(%rip), %rcx     # 0x4ffe8
movq (%rcx), %rdi
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq (%rcx,%rax,8), %rdx
leaq 0x261c3(%rip), %rsi     # 0x4288b
jmp 0x1c6f6
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x4522
jmp 0x1c6fd
movq 0x33908(%rip), %rcx     # 0x4ffe8
movq (%rcx), %rdi
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq (%rcx,%rax,8), %rdx
leaq 0x261e0(%rip), %rsi     # 0x428d6
xorl %eax, %eax
callq 0x3750
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x1c612
movq 0x8(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x4547
jmp 0x1c6fd
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x456c
jmp 0x1c6fd
movq 0x338ba(%rip), %rax     # 0x4ffe8
movq (%rax), %rdi
movq 0x30(%r12), %rdx
leaq 0x25fa6(%rip), %rsi     # 0x426e3
movl %r15d, %ecx
xorl %eax, %eax
callq 0x3750
jmp 0x1c6fd
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x4591
jmp 0x1c6fd
leaq 0x26021(%rip), %rdi     # 0x42780
leaq 0x25e6e(%rip), %rsi     # 0x425d4
leaq 0x2601e(%rip), %rcx     # 0x4278b
movl $0xb6, %edx
callq 0x31b0