// File: /workspace/github_cpp_makefile_star2_O2/BenLangmead[P]bowtie/./ebwt_search_util.h
// Function: PartialAlignmentManager::toMutsString(PartialAlignment const&, SDnaStringExpandable<25, 2> const&, SStringExpandable<char, 25, 2, 0> const&, EList<QueryMutation, 128>&, bool)
static uint8_t toMutsString(const PartialAlignment& pal,
	                            const BTDnaString& seq,
	                            const BTString& quals,
	                            EList<QueryMutation>& muts,
	                            bool maqPenalty = true)
	{
		muts.reserveExact(4);
		assert_eq(0, muts.size());
		uint32_t plen = (uint32_t)seq.length();
		assert_gt(plen, 0);
		assert_neq(1, pal.unk.type);
		// Do first mutation
		uint8_t oldQuals = 0;
		uint32_t pos0 = pal.entry.pos0;
		assert_lt(pos0, plen);
		uint16_t tpos0 = plen-1-pos0;
		uint32_t chr0 = pal.entry.char0;
		uint8_t oldChar = (uint8_t)seq[tpos0];
		uint8_t oldQual0 = mmPenalty(maqPenalty, phredCharToPhredQual(quals[tpos0]));
		assert_leq(oldQual0, 99);
		oldQuals += oldQual0; // take quality hit
		muts.push_back(QueryMutation(tpos0, oldChar, chr0));
		if(pal.entry.pos1 != 0xffff) {
			// Do second mutation
			uint32_t pos1 = pal.entry.pos1;
			assert_lt(pos1, plen);
			uint16_t tpos1 = plen-1-pos1;
			uint32_t chr1 = pal.entry.char1;
			oldChar = (uint8_t)seq[tpos1];
			uint8_t oldQual1 = mmPenalty(maqPenalty, phredCharToPhredQual(quals[tpos1]));
			assert_leq(oldQual1, 99);
			oldQuals += oldQual1; // take quality hit
			assert_neq(tpos1, tpos0);
			muts.push_back(QueryMutation(tpos1, oldChar, chr1));
			if(pal.entry.pos2 != 0xffff) {
				// Do second mutation
				uint32_t pos2 = pal.entry.pos2;
				assert_lt(pos2, plen);
				uint16_t tpos2 = plen-1-pos2;
				uint32_t chr2 = pal.entry.char2;
				oldChar = (uint8_t)seq[tpos2];
				uint8_t oldQual2 = mmPenalty(maqPenalty, phredCharToPhredQual(quals[tpos2]));
				assert_leq(oldQual2, 99);
				oldQuals += oldQual2; // take quality hit
				assert_neq(tpos2, tpos0);
				assert_neq(tpos2, tpos1);
				muts.push_back(QueryMutation(tpos2, oldChar, chr2)); // apply mutation
			}
		}
		assert_gt(muts.size(), 0);
		assert_leq(muts.size(), 3);
		return oldQuals;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, %r14d
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
pushq $0x4
popq %rsi
movq %rcx, %rdi
callq 0x374e4
movl 0x20(%r12), %ebp
movq (%r13), %rax
decl %ebp
movl %ebp, %ecx
subl %eax, %ecx
shrq $0x30, %rax
andb $0x3, %al
movzwl %cx, %esi
movq 0x8(%r12), %rdx
movb (%rdx,%rsi), %dl
movq %r15, 0x10(%rsp)
movq 0x8(%r15), %rdi
movb (%rdi,%rsi), %sil
leal -0x21(%rsi), %edi
xorl %r8d, %r8d
cmpb $0x21, %sil
movzbl %dil, %r15d
cmovbl %r8d, %r15d
movl %r14d, 0xc(%rsp)
testl %r14d, %r14d
je 0x34ac2
movzbl %r15b, %esi
leaq 0x30052(%rip), %rdi     # 0x64b10
movb (%rdi,%rsi), %r15b
leaq 0x24(%rsp), %rsi
movw %cx, (%rsi)
movb %dl, 0x2(%rsi)
movb %al, 0x3(%rsi)
movq %rbx, %rdi
callq 0x37512
movq (%r13), %rax
movl %eax, %edx
shrl $0x10, %edx
cmpl $0xffff, %edx           # imm = 0xFFFF
je 0x34bc2
movl %ebp, %ecx
subl %edx, %ecx
shrq $0x32, %rax
andb $0x3, %al
movzwl %cx, %esi
movq 0x8(%r12), %rdx
movb (%rdx,%rsi), %dl
movq 0x10(%rsp), %rdi
movq 0x8(%rdi), %rdi
movb (%rdi,%rsi), %sil
leal -0x21(%rsi), %edi
xorl %r8d, %r8d
cmpb $0x21, %sil
movzbl %dil, %esi
cmovbl %r8d, %esi
cmpb $0x0, 0xc(%rsp)
je 0x34b37
movzbl %sil, %esi
leaq 0x2ffdd(%rip), %rdi     # 0x64b10
movb (%rdi,%rsi), %sil
addb %sil, %r15b
leaq 0x20(%rsp), %rsi
movw %cx, (%rsi)
movb %dl, 0x2(%rsi)
movb %al, 0x3(%rsi)
movq %rbx, %rdi
callq 0x37512
movq (%r13), %rax
movq %rax, %rcx
shrq $0x20, %rcx
cmpw $-0x1, %cx
je 0x34bc2
subl %ecx, %ebp
shrq $0x34, %rax
andb $0x3, %al
movzwl %bp, %edx
movq 0x8(%r12), %rcx
movb (%rcx,%rdx), %cl
movq 0x10(%rsp), %rsi
movq 0x8(%rsi), %rsi
movb (%rsi,%rdx), %dl
leal -0x21(%rdx), %esi
xorl %edi, %edi
cmpb $0x21, %dl
movzbl %sil, %r14d
cmovbl %edi, %r14d
cmpb $0x0, 0xc(%rsp)
je 0x34ba6
movzbl %r14b, %edx
leaq 0x2ff6e(%rip), %rsi     # 0x64b10
movb (%rsi,%rdx), %r14b
addb %r15b, %r14b
leaq 0x1c(%rsp), %rsi
movw %bp, (%rsi)
movb %cl, 0x2(%rsi)
movb %al, 0x3(%rsi)
movq %rbx, %rdi
callq 0x37512
movl %r14d, %r15d
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq