// File: /workspace/github_cpp_makefile_star2_O1/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, %r12
movq %rsi, %r15
movq %rdi, %r13
cmpq $0x0, 0x8(%rcx)
jne 0x3ede7
movq $0x4, 0x10(%rbx)
movl $0x10, %edi
callq 0x9030
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl (%rbx), %ecx
movl %ecx, 0x4(%rbx)
movq %rax, 0x8(%rbx)
movl $0x4, %esi
movq %rbx, %rdi
callq 0x41f1e
movl 0x20(%r15), %ebp
movq (%r13), %rax
decl %ebp
movl %ebp, %ecx
subl %eax, %ecx
shrq $0x30, %rax
andb $0x3, %al
movzwl %cx, %esi
movq 0x8(%r15), %rdx
movb (%rdx,%rsi), %dl
movq %r12, 0x10(%rsp)
movq 0x8(%r12), %rdi
movb (%rdi,%rsi), %sil
leal -0x21(%rsi), %edi
xorl %r8d, %r8d
cmpb $0x21, %sil
movzbl %dil, %r12d
cmovbl %r8d, %r12d
testb %r14b, %r14b
movl %r14d, 0xc(%rsp)
je 0x3ee4b
movzbl %r12b, %esi
leaq 0x2ecb9(%rip), %rdi     # 0x6db00
movb (%rdi,%rsi), %r12b
leaq 0x24(%rsp), %rsi
movw %cx, (%rsi)
movb %dl, 0x2(%rsi)
movb %al, 0x3(%rsi)
movq %rbx, %rdi
callq 0x41eba
movq (%r13), %rax
movl %eax, %edx
shrl $0x10, %edx
cmpl $0xffff, %edx           # imm = 0xFFFF
je 0x3ef49
movl %ebp, %ecx
subl %edx, %ecx
shrq $0x32, %rax
andb $0x3, %al
movzwl %cx, %esi
movq 0x8(%r15), %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 0x3eebf
movzbl %sil, %esi
leaq 0x2ec45(%rip), %rdi     # 0x6db00
movb (%rdi,%rsi), %sil
addb %sil, %r12b
leaq 0x20(%rsp), %rsi
movw %cx, (%rsi)
movb %dl, 0x2(%rsi)
movb %al, 0x3(%rsi)
movq %rbx, %rdi
callq 0x41eba
movq (%r13), %rax
movq %rax, %rcx
shrq $0x20, %rcx
cmpw $-0x1, %cx
je 0x3ef49
subl %ecx, %ebp
shrq $0x34, %rax
andb $0x3, %al
movzwl %bp, %edx
movq 0x8(%r15), %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 0x3ef2d
movzbl %r14b, %edx
leaq 0x2ebd7(%rip), %rsi     # 0x6db00
movb (%rsi,%rdx), %r14b
addb %r12b, %r14b
leaq 0x1c(%rsp), %rsi
movw %bp, (%rsi)
movb %cl, 0x2(%rsi)
movb %al, 0x3(%rsi)
movq %rbx, %rdi
callq 0x41eba
movl %r14d, %r12d
movl %r12d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop