// File: /workspace/github_c_makefile_star2_O0/ToniWestbrook[P]paladin/bwamem.c
// Function: mem_aln2sam
void mem_aln2sam(const mem_opt_t *opt, const bntseq_t *bns, kstring_t *str, bseq1_t *s, int n, const mem_aln_t *list, int which, const mem_aln_t *m_)
{
	int i, l_name;
	mem_aln_t ptmp = list[which], *p = &ptmp, mtmp, *m = 0; // make a copy of the alignment to convert
	if (m_) mtmp = *m_, m = &mtmp;

	// set flag
	p->flag |= m? 0x1 : 0; // is paired in sequencing
	p->flag |= p->rid < 0? 0x4 : 0; // is mapped
	p->flag |= m && m->rid < 0? 0x8 : 0; // is mate mapped
	if (p->rid < 0 && m && m->rid >= 0) // copy mate to alignment
		p->rid = m->rid, p->pos = m->pos, p->is_rev = m->is_rev, p->n_cigar = 0;
	if (m && m->rid < 0 && p->rid >= 0) // copy alignment to mate
		m->rid = p->rid, m->pos = p->pos, m->is_rev = p->is_rev, m->n_cigar = 0;
	p->flag |= p->is_rev? 0x10 : 0; // is on the reverse strand
	p->flag |= m && m->is_rev? 0x20 : 0; // is mate on the reverse strand


	// print up to CIGAR
	l_name = strlen(s->name);
	ks_resize(str, str->l + s->l_seq + l_name + (s->qual? s->l_seq : 0) + 20);
	kputsn(s->name, l_name, str); kputc('\t', str); // QNAME
	kputw((p->flag&0xffff) | (p->flag&0x10000? 0x100 : 0), str); kputc('\t', str); // FLAG
	if (p->rid >= 0) { // with coordinate
		kputs(bns->anns[p->rid].name, str); kputc('\t', str); // RNAME
		kputl(p->pos + 1, str); kputc('\t', str); // POS
		kputw(p->mapq, str); kputc('\t', str); // MAPQ
		if (p->n_cigar) { // aligned
			for (i = 0; i < p->n_cigar; ++i) {
				int c = p->cigar[i]&0xf;
				if (!(opt->flag&MEM_F_SOFTCLIP) && !p->is_alt && (c == 3 || c == 4))
					c = which? 4 : 3; // use hard clipping for supplementary alignments
				kputw(p->cigar[i]>>4, str); kputc("MIDSH"[c], str);
			}
		} else kputc('*', str); // having a coordinate but unaligned (e.g. when copy_mate is true)
	} else kputsn("*\t0\t0\t*", 7, str); // without coordinte
	kputc('\t', str);

	// print the mate position if applicable
	if (m && m->rid >= 0) {
		if (p->rid == m->rid) kputc('=', str);
		else kputs(bns->anns[m->rid].name, str);
		kputc('\t', str);
		kputl(m->pos + 1, str); kputc('\t', str);
		if (p->rid == m->rid) {
			int64_t p0 = p->pos + (p->is_rev? get_rlen(p->n_cigar, p->cigar) - 1 : 0);
			int64_t p1 = m->pos + (m->is_rev? get_rlen(m->n_cigar, m->cigar) - 1 : 0);
			if (m->n_cigar == 0 || p->n_cigar == 0) kputc('0', str);
			else kputl(-(p0 - p1 + (p0 > p1? 1 : p0 < p1? -1 : 0)), str);
		} else kputc('0', str);
	} else kputsn("*\t0\t0", 5, str);
	kputc('\t', str);

	// print SEQ and QUAL
	if (p->flag & 0x100) { // for secondary alignments, don't write SEQ and QUAL
		kputsn("*\t*", 3, str);
	} else if (!p->is_rev) { // the forward strand
		int i, qb = 0, qe = s->l_seq;
		if (p->n_cigar && which && !(opt->flag&MEM_F_SOFTCLIP) && !p->is_alt) { // have cigar && not the primary alignment && not softclip all
			if ((p->cigar[0]&0xf) == 4 || (p->cigar[0]&0xf) == 3) qb += p->cigar[0]>>4;
			if ((p->cigar[p->n_cigar-1]&0xf) == 4 || (p->cigar[p->n_cigar-1]&0xf) == 3) qe -= p->cigar[p->n_cigar-1]>>4;
		}
		ks_resize(str, str->l + (qe - qb) + 1);
		//OLD for (i = qb; i < qe; ++i) str->s[str->l++] = "ACGTN"[(int)s->seq[i]];
		for (i = qb; i < qe; ++i) str->s[(int)(str->l++)] = aa_ascii_hash[(int)(s->seq[i])];
		kputc('\t', str);
		if (s->qual) { // printf qual
			ks_resize(str, str->l + (qe - qb) + 1);
			for (i = qb; i < qe; ++i) str->s[str->l++] = s->qual[i];
			str->s[str->l] = 0;
		} else kputc('*', str);
	} else { // the reverse strand
		int i, qb = 0, qe = s->l_seq;
		if (p->n_cigar && which && !(opt->flag&MEM_F_SOFTCLIP) && !p->is_alt) {
			if ((p->cigar[0]&0xf) == 4 || (p->cigar[0]&0xf) == 3) qe -= p->cigar[0]>>4;
			if ((p->cigar[p->n_cigar-1]&0xf) == 4 || (p->cigar[p->n_cigar-1]&0xf) == 3) qb += p->cigar[p->n_cigar-1]>>4;
		}
		ks_resize(str, str->l + (qe - qb) + 1);
		//OLD for (i = qe-1; i >= qb; --i) str->s[str->l++] = "TGCAN"[(int)s->seq[i]];
		for (i = qe-1; i >= qb; --i) str->s[(int)(str->l++)] = aa_ascii_hash[(int)(s->seq[i])];
		kputc('\t', str);
		if (s->qual) { // printf qual
			ks_resize(str, str->l + (qe - qb) + 1);
			for (i = qe-1; i >= qb; --i) str->s[str->l++] = s->qual[i];
			str->s[str->l] = 0;
		} else kputc('*', str);
	}

	// print optional tags
	if (p->n_cigar) {
		kputsn("\tNM:i:", 6, str); kputw(p->NM, str);
		kputsn("\tMD:Z:", 6, str); kputs((char*)(p->cigar + p->n_cigar), str);
	}
	if (p->score >= 0) { kputsn("\tAS:i:", 6, str); kputw(p->score, str); }
	if (p->sub >= 0) { kputsn("\tXS:i:", 6, str); kputw(p->sub, str); }
	if (bwa_rg_id[0]) { kputsn("\tRG:Z:", 6, str); kputs(bwa_rg_id, str); }
	if (!(p->flag & 0x100)) { // not multi-hit
		for (i = 0; i < n; ++i)
			if (i != which && !(list[i].flag&0x100)) break;
		if (i < n) { // there are other primary hits; output them
			kputsn("\tSA:Z:", 6, str);
			for (i = 0; i < n; ++i) {
				const mem_aln_t *r = &list[i];
				int k;
				if (i == which || (r->flag&0x100)) continue; // proceed if: 1) different from the current; 2) not shadowed multi hit
				kputs(bns->anns[r->rid].name, str); kputc(',', str);
				kputl(r->pos+1, str); kputc(',', str);
				kputc("+-"[r->is_rev], str); kputc(',', str);
				for (k = 0; k < r->n_cigar; ++k) {
					kputw(r->cigar[k]>>4, str); kputc("MIDSH"[r->cigar[k]&0xf], str);
				}
				kputc(',', str); kputw(r->mapq, str);
				kputc(',', str); kputw(r->NM, str);
				kputc(';', str);
			}
		}
		if (p->alt_sc > 0)
			ksprintf(str, "\tpa:f:%.3f", (double)p->score / p->alt_sc);
	}
	if (p->XA) { kputsn("\tXA:Z:", 6, str); kputs(p->XA, str); }
	if (s->comment) { kputc('\t', str); kputs(s->comment, str); }
	if ((opt->flag&MEM_F_REF_HDR) && p->rid >= 0 && bns->anns[p->rid].anno != 0 && bns->anns[p->rid].anno[0] != 0) {
		int tmp;
		kputsn("\tXR:Z:", 6, str);
		tmp = str->l;
		kputs(bns->anns[p->rid].anno, str);
		for (i = tmp; i < str->l; ++i) // replace TAB in the comment to SPACE
			if (str->s[i] == '\t') str->s[i] = ' ';
	}
	kputc('\n', str);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movq -0x30(%rbp), %rsi
movslq 0x10(%rbp), %rax
imulq $0x38, %rax, %rax
addq %rax, %rsi
leaq -0x70(%rbp), %rdi
movl $0x38, %edx
callq 0x3250
leaq -0x70(%rbp), %rax
movq %rax, -0x78(%rbp)
movq $0x0, -0xb8(%rbp)
cmpq $0x0, 0x18(%rbp)
je 0x294c4
movq 0x18(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
movl $0x38, %edx
callq 0x3250
leaq -0xb0(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rdx
xorl %ecx, %ecx
movl $0x1, %eax
cmpq $0x0, %rdx
cmovnel %eax, %ecx
movq -0x78(%rbp), %rax
orl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
movq -0x78(%rbp), %rax
movl 0x8(%rax), %edx
xorl %ecx, %ecx
movl $0x4, %eax
cmpl $0x0, %edx
cmovll %eax, %ecx
movq -0x78(%rbp), %rax
orl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
xorl %eax, %eax
cmpq $0x0, -0xb8(%rbp)
movb %al, -0xf9(%rbp)
je 0x29527
movq -0xb8(%rbp), %rax
cmpl $0x0, 0x8(%rax)
setl %al
movb %al, -0xf9(%rbp)
movb -0xf9(%rbp), %dl
xorl %ecx, %ecx
movl $0x8, %eax
testb $0x1, %dl
cmovnel %eax, %ecx
movq -0x78(%rbp), %rax
orl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
movq -0x78(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jge 0x295b1
cmpq $0x0, -0xb8(%rbp)
je 0x295b1
movq -0xb8(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jl 0x295b1
movq -0xb8(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0xb8(%rbp), %rax
movq (%rax), %rcx
movq -0x78(%rbp), %rax
movq %rcx, (%rax)
movq -0xb8(%rbp), %rax
movl 0x10(%rax), %edx
andl $0x1, %edx
movq -0x78(%rbp), %rax
movl 0x10(%rax), %ecx
andl $0x1, %edx
andl $-0x2, %ecx
orl %edx, %ecx
movl %ecx, 0x10(%rax)
movq -0x78(%rbp), %rax
movl $0x0, 0x14(%rax)
cmpq $0x0, -0xb8(%rbp)
je 0x29621
movq -0xb8(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jge 0x29621
movq -0x78(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jl 0x29621
movq -0x78(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0xb8(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x78(%rbp), %rax
movq (%rax), %rcx
movq -0xb8(%rbp), %rax
movq %rcx, (%rax)
movq -0x78(%rbp), %rax
movl 0x10(%rax), %edx
andl $0x1, %edx
movq -0xb8(%rbp), %rax
movl 0x10(%rax), %ecx
andl $0x1, %edx
andl $-0x2, %ecx
orl %edx, %ecx
movl %ecx, 0x10(%rax)
movq -0xb8(%rbp), %rax
movl $0x0, 0x14(%rax)
movq -0x78(%rbp), %rax
movl 0x10(%rax), %edx
andl $0x1, %edx
xorl %ecx, %ecx
movl $0x10, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x78(%rbp), %rax
orl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
xorl %eax, %eax
cmpq $0x0, -0xb8(%rbp)
movb %al, -0xfa(%rbp)
je 0x2966d
movq -0xb8(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0xfa(%rbp)
movb -0xfa(%rbp), %dl
xorl %ecx, %ecx
movl $0x20, %eax
testb $0x1, %dl
cmovnel %eax, %ecx
movq -0x78(%rbp), %rax
orl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x30f0
movl %eax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x108(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x296dd
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x114(%rbp)
jmp 0x296e7
xorl %eax, %eax
movl %eax, -0x114(%rbp)
jmp 0x296e7
movq -0x110(%rbp), %rdi
movq -0x108(%rbp), %rsi
movl -0x114(%rbp), %eax
cltq
addq %rax, %rsi
addq $0x14, %rsi
callq 0x2a500
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
movl -0x38(%rbp), %esi
movq -0x18(%rbp), %rdx
callq 0x2a600
movq -0x18(%rbp), %rsi
movl $0x9, %edi
callq 0x2a760
movq -0x78(%rbp), %rax
movl 0xc(%rax), %edi
andl $0xffff, %edi           # imm = 0xFFFF
movq -0x78(%rbp), %rax
movl 0xc(%rax), %edx
andl $0x10000, %edx          # imm = 0x10000
xorl %eax, %eax
movl $0x100, %ecx            # imm = 0x100
cmpl $0x0, %edx
cmovnel %ecx, %eax
orl %eax, %edi
movq -0x18(%rbp), %rsi
callq 0x2a8b0
movq -0x18(%rbp), %rsi
movl $0x9, %edi
callq 0x2a760
movq -0x78(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jl 0x298d4
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x78(%rbp), %rcx
movslq 0x8(%rcx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x2aac0
movq -0x18(%rbp), %rsi
movl $0x9, %edi
callq 0x2a760
movq -0x78(%rbp), %rax
movq (%rax), %rdi
addq $0x1, %rdi
movq -0x18(%rbp), %rsi
callq 0x2ab00
movq -0x18(%rbp), %rsi
movl $0x9, %edi
callq 0x2a760
movq -0x78(%rbp), %rax
movl 0x10(%rax), %edi
shrl $0x2, %edi
andl $0xff, %edi
movq -0x18(%rbp), %rsi
callq 0x2a8b0
movq -0x18(%rbp), %rsi
movl $0x9, %edi
callq 0x2a760
movq -0x78(%rbp), %rax
cmpl $0x0, 0x14(%rax)
je 0x298c4
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x78(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jge 0x298c2
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %eax
andl $0xf, %eax
movl %eax, -0xbc(%rbp)
movq -0x8(%rbp), %rax
movl 0x48(%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
jne 0x2987e
movq -0x78(%rbp), %rax
movl 0x10(%rax), %eax
shrl %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x2987e
cmpl $0x3, -0xbc(%rbp)
je 0x29865
cmpl $0x4, -0xbc(%rbp)
jne 0x2987e
movl 0x10(%rbp), %edx
movl $0x3, %eax
movl $0x4, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0xbc(%rbp)
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %edi
shrl $0x4, %edi
movq -0x18(%rbp), %rsi
callq 0x2a8b0
movslq -0xbc(%rbp), %rcx
leaq 0x11429(%rip), %rax     # 0x3acd0
movsbl (%rax,%rcx), %edi
movq -0x18(%rbp), %rsi
callq 0x2a760
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x29809
jmp 0x298d2
movq -0x18(%rbp), %rsi
movl $0x2a, %edi
callq 0x2a760
jmp 0x298e9
movq -0x18(%rbp), %rdx
leaq 0x113f7(%rip), %rdi     # 0x3acd6
movl $0x7, %esi
callq 0x2a600
movq -0x18(%rbp), %rsi
movl $0x9, %edi
callq 0x2a760
cmpq $0x0, -0xb8(%rbp)
je 0x29b25
movq -0xb8(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jl 0x29b25
movq -0x78(%rbp), %rax
movl 0x8(%rax), %eax
movq -0xb8(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jne 0x29939
movq -0x18(%rbp), %rsi
movl $0x3d, %edi
callq 0x2a760
jmp 0x29960
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0xb8(%rbp), %rcx
movslq 0x8(%rcx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x2aac0
movq -0x18(%rbp), %rsi
movl $0x9, %edi
callq 0x2a760
movq -0xb8(%rbp), %rax
movq (%rax), %rdi
addq $0x1, %rdi
movq -0x18(%rbp), %rsi
callq 0x2ab00
movq -0x18(%rbp), %rsi
movl $0x9, %edi
callq 0x2a760
movq -0x78(%rbp), %rax
movl 0x8(%rax), %eax
movq -0xb8(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jne 0x29b15
movq -0x78(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x120(%rbp)
movq -0x78(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x299e6
movq -0x78(%rbp), %rax
movl 0x14(%rax), %edi
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x2ad20
subl $0x1, %eax
movl %eax, -0x124(%rbp)
jmp 0x299f0
xorl %eax, %eax
movl %eax, -0x124(%rbp)
jmp 0x299f0
movq -0x120(%rbp), %rax
movl -0x124(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0xc8(%rbp)
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x130(%rbp)
movq -0xb8(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x29a52
movq -0xb8(%rbp), %rax
movl 0x14(%rax), %edi
movq -0xb8(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x2ad20
subl $0x1, %eax
movl %eax, -0x134(%rbp)
jmp 0x29a5c
xorl %eax, %eax
movl %eax, -0x134(%rbp)
jmp 0x29a5c
movq -0x130(%rbp), %rax
movl -0x134(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0xd0(%rbp)
movq -0xb8(%rbp), %rax
cmpl $0x0, 0x14(%rax)
je 0x29a8d
movq -0x78(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jne 0x29a9d
movq -0x18(%rbp), %rsi
movl $0x30, %edi
callq 0x2a760
jmp 0x29b13
movq -0xc8(%rbp), %rax
subq -0xd0(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0xc8(%rbp), %rax
cmpq -0xd0(%rbp), %rax
jle 0x29acf
movl $0x1, %eax
movl %eax, -0x144(%rbp)
jmp 0x29af0
movq -0xc8(%rbp), %rdx
movq -0xd0(%rbp), %rsi
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rsi, %rdx
cmovll %ecx, %eax
movl %eax, -0x144(%rbp)
movq -0x140(%rbp), %rax
movl -0x144(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
xorl %ecx, %ecx
movl %ecx, %edi
subq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x2ab00
jmp 0x29b23
movq -0x18(%rbp), %rsi
movl $0x30, %edi
callq 0x2a760
jmp 0x29b3a
movq -0x18(%rbp), %rdx
leaq 0x111ae(%rip), %rdi     # 0x3acde
movl $0x5, %esi
callq 0x2a600
movq -0x18(%rbp), %rsi
movl $0x9, %edi
callq 0x2a760
movq -0x78(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x29b73
movq -0x18(%rbp), %rdx
leaq 0x11180(%rip), %rdi     # 0x3ace4
movl $0x3, %esi
callq 0x2a600
jmp 0x2a02f
movq -0x78(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x29dd8
movl $0x0, -0xd8(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xdc(%rbp)
movq -0x78(%rbp), %rax
cmpl $0x0, 0x14(%rax)
je 0x29c86
cmpl $0x0, 0x10(%rbp)
je 0x29c86
movq -0x8(%rbp), %rax
movl 0x48(%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
jne 0x29c86
movq -0x78(%rbp), %rax
movl 0x10(%rax), %eax
shrl %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x29c86
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %eax
andl $0xf, %eax
cmpl $0x4, %eax
je 0x29c02
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %eax
andl $0xf, %eax
cmpl $0x3, %eax
jne 0x29c1b
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %eax
shrl $0x4, %eax
addl -0xd8(%rbp), %eax
movl %eax, -0xd8(%rbp)
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x78(%rbp), %rcx
movl 0x14(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
andl $0xf, %eax
cmpl $0x4, %eax
je 0x29c5b
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x78(%rbp), %rcx
movl 0x14(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
andl $0xf, %eax
cmpl $0x3, %eax
jne 0x29c84
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x78(%rbp), %rcx
movl 0x14(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %ecx
shrl $0x4, %ecx
movl -0xdc(%rbp), %eax
subl %ecx, %eax
movl %eax, -0xdc(%rbp)
jmp 0x29c86
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movl -0xdc(%rbp), %eax
subl -0xd8(%rbp), %eax
cltq
addq %rax, %rsi
addq $0x1, %rsi
callq 0x2a500
movl -0xd8(%rbp), %eax
movl %eax, -0xd4(%rbp)
movl -0xd4(%rbp), %eax
cmpl -0xdc(%rbp), %eax
jge 0x29d15
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0xd4(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movslq %eax, %rcx
leaq 0x1704e(%rip), %rax     # 0x40d30
movb (%rax,%rcx), %dl
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0xd4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd4(%rbp)
jmp 0x29cb7
movq -0x18(%rbp), %rsi
movl $0x9, %edi
callq 0x2a760
movq -0x20(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x29dc5
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movl -0xdc(%rbp), %eax
subl -0xd8(%rbp), %eax
cltq
addq %rax, %rsi
addq $0x1, %rsi
callq 0x2a500
movl -0xd8(%rbp), %eax
movl %eax, -0xd4(%rbp)
movl -0xd4(%rbp), %eax
cmpl -0xdc(%rbp), %eax
jge 0x29db0
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0xd4(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movb %dl, (%rax,%rcx)
movl -0xd4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd4(%rbp)
jmp 0x29d63
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
movb $0x0, (%rax,%rcx)
jmp 0x29dd3
movq -0x18(%rbp), %rsi
movl $0x2a, %edi
callq 0x2a760
jmp 0x2a02d
movl $0x0, -0xe4(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xe8(%rbp)
movq -0x78(%rbp), %rax
cmpl $0x0, 0x14(%rax)
je 0x29ed8
cmpl $0x0, 0x10(%rbp)
je 0x29ed8
movq -0x8(%rbp), %rax
movl 0x48(%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
jne 0x29ed8
movq -0x78(%rbp), %rax
movl 0x10(%rax), %eax
shrl %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x29ed8
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %eax
andl $0xf, %eax
cmpl $0x4, %eax
je 0x29e54
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %eax
andl $0xf, %eax
cmpl $0x3, %eax
jne 0x29e6f
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %ecx
shrl $0x4, %ecx
movl -0xe8(%rbp), %eax
subl %ecx, %eax
movl %eax, -0xe8(%rbp)
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x78(%rbp), %rcx
movl 0x14(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
andl $0xf, %eax
cmpl $0x4, %eax
je 0x29eaf
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x78(%rbp), %rcx
movl 0x14(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
andl $0xf, %eax
cmpl $0x3, %eax
jne 0x29ed6
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x78(%rbp), %rcx
movl 0x14(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
shrl $0x4, %eax
addl -0xe4(%rbp), %eax
movl %eax, -0xe4(%rbp)
jmp 0x29ed8
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movl -0xe8(%rbp), %eax
subl -0xe4(%rbp), %eax
cltq
addq %rax, %rsi
addq $0x1, %rsi
callq 0x2a500
movl -0xe8(%rbp), %eax
subl $0x1, %eax
movl %eax, -0xe0(%rbp)
movl -0xe0(%rbp), %eax
cmpl -0xe4(%rbp), %eax
jl 0x29f6a
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0xe0(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movslq %eax, %rcx
leaq 0x16df9(%rip), %rax     # 0x40d30
movb (%rax,%rcx), %dl
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0xe0(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xe0(%rbp)
jmp 0x29f0c
movq -0x18(%rbp), %rsi
movl $0x9, %edi
callq 0x2a760
movq -0x20(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x2a01d
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movl -0xe8(%rbp), %eax
subl -0xe4(%rbp), %eax
cltq
addq %rax, %rsi
addq $0x1, %rsi
callq 0x2a500
movl -0xe8(%rbp), %eax
subl $0x1, %eax
movl %eax, -0xe0(%rbp)
movl -0xe0(%rbp), %eax
cmpl -0xe4(%rbp), %eax
jl 0x2a008
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0xe0(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movb %dl, (%rax,%rcx)
movl -0xe0(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xe0(%rbp)
jmp 0x29fbb
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
movb $0x0, (%rax,%rcx)
jmp 0x2a02b
movq -0x18(%rbp), %rsi
movl $0x2a, %edi
callq 0x2a760
jmp 0x2a02d
jmp 0x2a02f
movq -0x78(%rbp), %rax
cmpl $0x0, 0x14(%rax)
je 0x2a096
movq -0x18(%rbp), %rdx
leaq 0x10ca4(%rip), %rdi     # 0x3ace8
movl $0x6, %esi
callq 0x2a600
movq -0x78(%rbp), %rax
movl 0x10(%rax), %edi
shrl $0xa, %edi
movq -0x18(%rbp), %rsi
callq 0x2a8b0
movq -0x18(%rbp), %rdx
leaq 0x10c83(%rip), %rdi     # 0x3acef
movl $0x6, %esi
callq 0x2a600
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x78(%rbp), %rax
movslq 0x14(%rax), %rax
shlq $0x2, %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x2aac0
movq -0x78(%rbp), %rax
cmpl $0x0, 0x28(%rax)
jl 0x2a0c5
movq -0x18(%rbp), %rdx
leaq 0x10c4b(%rip), %rdi     # 0x3acf6
movl $0x6, %esi
callq 0x2a600
movq -0x78(%rbp), %rax
movl 0x28(%rax), %edi
movq -0x18(%rbp), %rsi
callq 0x2a8b0
movq -0x78(%rbp), %rax
cmpl $0x0, 0x2c(%rax)
jl 0x2a0f4
movq -0x18(%rbp), %rdx
leaq 0x10c23(%rip), %rdi     # 0x3acfd
movl $0x6, %esi
callq 0x2a600
movq -0x78(%rbp), %rax
movl 0x2c(%rax), %edi
movq -0x18(%rbp), %rsi
callq 0x2a8b0
leaq 0x16d75(%rip), %rax     # 0x40e70
cmpb $0x0, (%rax)
je 0x2a125
movq -0x18(%rbp), %rdx
leaq 0x10bf9(%rip), %rdi     # 0x3ad04
movl $0x6, %esi
callq 0x2a600
movq -0x18(%rbp), %rsi
leaq 0x16d50(%rip), %rdi     # 0x40e70
callq 0x2aac0
movq -0x78(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
jne 0x2a392
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x2a17c
movl -0x34(%rbp), %eax
cmpl 0x10(%rbp), %eax
je 0x2a16f
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
jne 0x2a16f
jmp 0x2a17c
jmp 0x2a171
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2a141
movl -0x34(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x2a35e
movq -0x18(%rbp), %rdx
leaq 0x10b78(%rip), %rdi     # 0x3ad0b
movl $0x6, %esi
callq 0x2a600
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x2a35c
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xf0(%rbp)
movl -0x34(%rbp), %eax
cmpl 0x10(%rbp), %eax
je 0x2a1e2
movq -0xf0(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x2a1e7
jmp 0x2a34e
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0xf0(%rbp), %rcx
movslq 0x8(%rcx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x2aac0
movq -0x18(%rbp), %rsi
movl $0x2c, %edi
callq 0x2a760
movq -0xf0(%rbp), %rax
movq (%rax), %rdi
addq $0x1, %rdi
movq -0x18(%rbp), %rsi
callq 0x2ab00
movq -0x18(%rbp), %rsi
movl $0x2c, %edi
callq 0x2a760
movq -0xf0(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x104ec(%rip), %rax     # 0x3a745
movsbl (%rax,%rcx), %edi
movq -0x18(%rbp), %rsi
callq 0x2a760
movq -0x18(%rbp), %rsi
movl $0x2c, %edi
callq 0x2a760
movl $0x0, -0xf4(%rbp)
movl -0xf4(%rbp), %eax
movq -0xf0(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jge 0x2a2f2
movq -0xf0(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0xf4(%rbp), %rcx
movl (%rax,%rcx,4), %edi
shrl $0x4, %edi
movq -0x18(%rbp), %rsi
callq 0x2a8b0
movq -0xf0(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0xf4(%rbp), %rcx
movl (%rax,%rcx,4), %eax
andl $0xf, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x109fc(%rip), %rax     # 0x3acd0
movsbl (%rax,%rcx), %edi
movq -0x18(%rbp), %rsi
callq 0x2a760
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0x2a27e
movq -0x18(%rbp), %rsi
movl $0x2c, %edi
callq 0x2a760
movq -0xf0(%rbp), %rax
movl 0x10(%rax), %edi
shrl $0x2, %edi
andl $0xff, %edi
movq -0x18(%rbp), %rsi
callq 0x2a8b0
movq -0x18(%rbp), %rsi
movl $0x2c, %edi
callq 0x2a760
movq -0xf0(%rbp), %rax
movl 0x10(%rax), %edi
shrl $0xa, %edi
movq -0x18(%rbp), %rsi
callq 0x2a8b0
movq -0x18(%rbp), %rsi
movl $0x3b, %edi
callq 0x2a760
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2a1a4
jmp 0x2a35e
movq -0x78(%rbp), %rax
cmpl $0x0, 0x30(%rax)
jle 0x2a390
movq -0x18(%rbp), %rdi
movq -0x78(%rbp), %rax
cvtsi2sdl 0x28(%rax), %xmm0
movq -0x78(%rbp), %rax
cvtsi2sdl 0x30(%rax), %xmm1
divsd %xmm1, %xmm0
leaq 0x10989(%rip), %rsi     # 0x3ad12
movb $0x1, %al
callq 0x139b0
jmp 0x2a392
movq -0x78(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x2a3c3
movq -0x18(%rbp), %rdx
leaq 0x10975(%rip), %rdi     # 0x3ad1d
movl $0x6, %esi
callq 0x2a600
movq -0x78(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x2aac0
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x2a3ed
movq -0x18(%rbp), %rsi
movl $0x9, %edi
callq 0x2a760
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x2aac0
movq -0x8(%rbp), %rax
movl 0x48(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x2a4e9
movq -0x78(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jl 0x2a4e9
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x78(%rbp), %rcx
movslq 0x8(%rcx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x20(%rax)
je 0x2a4e9
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x78(%rbp), %rcx
movslq 0x8(%rcx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x2a4e9
movq -0x18(%rbp), %rdx
leaq 0x108c0(%rip), %rdi     # 0x3ad24
movl $0x6, %esi
callq 0x2a600
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl %eax, -0xf8(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x78(%rbp), %rcx
movslq 0x8(%rcx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x2aac0
movl -0xf8(%rbp), %eax
movl %eax, -0x34(%rbp)
movslq -0x34(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x2a4e7
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x9, %eax
jne 0x2a4da
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
movb $0x20, (%rax,%rcx)
jmp 0x2a4dc
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2a4a8
jmp 0x2a4e9
movq -0x18(%rbp), %rsi
movl $0xa, %edi
callq 0x2a760
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq