// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap2/align.c
// Function: mm_update_cigar_eqx
static void mm_update_cigar_eqx(mm_reg1_t *r, const uint8_t *qseq, const uint8_t *tseq) // written by @armintoepfer
{
	uint32_t n_EQX = 0;
	uint32_t k, l, m, cap, toff = 0, qoff = 0, n_M = 0;
	mm_extra_t *p;
	if (r->p == 0) return;
	for (k = 0; k < r->p->n_cigar; ++k) {
		uint32_t op = r->p->cigar[k]&0xf, len = r->p->cigar[k]>>4;
		if (op == MM_CIGAR_MATCH) {
			while (len > 0) {
				for (l = 0; l < len && qseq[qoff + l] == tseq[toff + l]; ++l) {} // run of "="; TODO: N<=>N is converted to "="
				if (l > 0) { ++n_EQX; len -= l; toff += l; qoff += l; }

				for (l = 0; l < len && qseq[qoff + l] != tseq[toff + l]; ++l) {} // run of "X"
				if (l > 0) { ++n_EQX; len -= l; toff += l; qoff += l; }
			}
			++n_M;
		} else if (op == MM_CIGAR_INS) {
			qoff += len;
		} else if (op == MM_CIGAR_DEL) {
			toff += len;
		} else if (op == MM_CIGAR_N_SKIP) {
			toff += len;
		}
	}
	// update in-place if we can
	if (n_EQX == n_M) {
		for (k = 0; k < r->p->n_cigar; ++k) {
			uint32_t op = r->p->cigar[k]&0xf, len = r->p->cigar[k]>>4;
			if (op == MM_CIGAR_MATCH) r->p->cigar[k] = len << 4 | MM_CIGAR_EQ_MATCH;
		}
		return;
	}
	// allocate new storage
	cap = r->p->n_cigar + (n_EQX - n_M) + sizeof(mm_extra_t);
	kroundup32(cap);
	p = (mm_extra_t*)calloc(cap, 4);
	memcpy(p, r->p, sizeof(mm_extra_t));
	p->capacity = cap;
	// update cigar while copying
	toff = qoff = m = 0;
	for (k = 0; k < r->p->n_cigar; ++k) {
		uint32_t op = r->p->cigar[k]&0xf, len = r->p->cigar[k]>>4;
		if (op == MM_CIGAR_MATCH) {
			while (len > 0) {
				// match
				for (l = 0; l < len && qseq[qoff + l] == tseq[toff + l]; ++l) {}
				if (l > 0) p->cigar[m++] = l << 4 | MM_CIGAR_EQ_MATCH;
				len -= l;
				toff += l, qoff += l;
				// mismatch
				for (l = 0; l < len && qseq[qoff + l] != tseq[toff + l]; ++l) {}
				if (l > 0) p->cigar[m++] = l << 4 | MM_CIGAR_X_MISMATCH;
				len -= l;
				toff += l, qoff += l;
			}
			continue;
		} else if (op == MM_CIGAR_INS) {
			qoff += len;
		} else if (op == MM_CIGAR_DEL) {
			toff += len;
		} else if (op == MM_CIGAR_N_SKIP) {
			toff += len;
		}
		p->cigar[m++] = r->p->cigar[k];
	}
	p->n_cigar = m;
	free(r->p);
	r->p = p;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jne 0x296f0
jmp 0x29bed
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x48(%rcx), %rcx
cmpl 0x18(%rcx), %eax
jae 0x2989e
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x20(%rbp), %ecx
movl 0x1c(%rax,%rcx,4), %eax
andl $0xf, %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x20(%rbp), %ecx
movl 0x1c(%rax,%rcx,4), %eax
shrl $0x4, %eax
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0x29857
jmp 0x29741
cmpl $0x0, -0x48(%rbp)
jbe 0x2984c
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %ecx
xorl %eax, %eax
cmpl -0x48(%rbp), %ecx
movb %al, -0x59(%rbp)
jae 0x29787
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
addl -0x24(%rbp), %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movq -0x18(%rbp), %rcx
movl -0x30(%rbp), %edx
addl -0x24(%rbp), %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
sete %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0x29790
jmp 0x2979d
jmp 0x29792
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x29752
cmpl $0x0, -0x24(%rbp)
jbe 0x297c9
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %ecx
movl -0x48(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x48(%rbp)
movl -0x24(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x24(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %ecx
xorl %eax, %eax
cmpl -0x48(%rbp), %ecx
movb %al, -0x5a(%rbp)
jae 0x29805
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
addl -0x24(%rbp), %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movq -0x18(%rbp), %rcx
movl -0x30(%rbp), %edx
addl -0x24(%rbp), %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
setne %al
movb %al, -0x5a(%rbp)
movb -0x5a(%rbp), %al
testb $0x1, %al
jne 0x2980e
jmp 0x2981b
jmp 0x29810
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x297d0
cmpl $0x0, -0x24(%rbp)
jbe 0x29847
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %ecx
movl -0x48(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x48(%rbp)
movl -0x24(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x24(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x29741
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x2988e
cmpl $0x1, -0x44(%rbp)
jne 0x29868
movl -0x48(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x2988c
cmpl $0x2, -0x44(%rbp)
jne 0x29879
movl -0x48(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x2988a
cmpl $0x3, -0x44(%rbp)
jne 0x29888
movl -0x48(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x2988a
jmp 0x2988c
jmp 0x2988e
jmp 0x29890
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x296f7
movl -0x1c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jne 0x29917
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x48(%rcx), %rcx
cmpl 0x18(%rcx), %eax
jae 0x29912
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x20(%rbp), %ecx
movl 0x1c(%rax,%rcx,4), %eax
andl $0xf, %eax
movl %eax, -0x4c(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x20(%rbp), %ecx
movl 0x1c(%rax,%rcx,4), %eax
shrl $0x4, %eax
movl %eax, -0x50(%rbp)
cmpl $0x0, -0x4c(%rbp)
jne 0x29905
movl -0x50(%rbp), %edx
shll $0x4, %edx
orl $0x7, %edx
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x20(%rbp), %ecx
movl %edx, 0x1c(%rax,%rcx,4)
jmp 0x29907
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x298ad
jmp 0x29bed
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movl 0x18(%rax), %eax
movl -0x1c(%rbp), %ecx
subl -0x38(%rbp), %ecx
addl %ecx, %eax
movl %eax, %eax
addq $0x1c, %rax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
shrl %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
shrl $0x2, %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
shrl $0x4, %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
shrl $0x8, %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
shrl $0x10, %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, %edi
movl $0x4, %esi
callq 0x2220
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x48(%rcx), %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movl 0x18(%rcx), %ecx
movl %ecx, 0x18(%rax)
movl -0x2c(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x48(%rcx), %rcx
cmpl 0x18(%rcx), %eax
jae 0x29bca
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x20(%rbp), %ecx
movl 0x1c(%rax,%rcx,4), %eax
andl $0xf, %eax
movl %eax, -0x54(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x20(%rbp), %ecx
movl 0x1c(%rax,%rcx,4), %eax
shrl $0x4, %eax
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x54(%rbp)
jne 0x29b61
jmp 0x29a2a
cmpl $0x0, -0x58(%rbp)
jbe 0x29b5f
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %ecx
xorl %eax, %eax
cmpl -0x58(%rbp), %ecx
movb %al, -0x5b(%rbp)
jae 0x29a70
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
addl -0x24(%rbp), %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movq -0x18(%rbp), %rcx
movl -0x30(%rbp), %edx
addl -0x24(%rbp), %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
sete %al
movb %al, -0x5b(%rbp)
movb -0x5b(%rbp), %al
testb $0x1, %al
jne 0x29a79
jmp 0x29a86
jmp 0x29a7b
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x29a3b
cmpl $0x0, -0x24(%rbp)
jbe 0x29aaa
movl -0x24(%rbp), %edx
shll $0x4, %edx
orl $0x7, %edx
movq -0x40(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x28(%rbp)
movl %ecx, %ecx
movl %edx, 0x1c(%rax,%rcx,4)
movl -0x24(%rbp), %ecx
movl -0x58(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x58(%rbp)
movl -0x24(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x24(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %ecx
xorl %eax, %eax
cmpl -0x58(%rbp), %ecx
movb %al, -0x5c(%rbp)
jae 0x29b03
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
addl -0x24(%rbp), %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movq -0x18(%rbp), %rcx
movl -0x30(%rbp), %edx
addl -0x24(%rbp), %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
setne %al
movb %al, -0x5c(%rbp)
movb -0x5c(%rbp), %al
testb $0x1, %al
jne 0x29b0c
jmp 0x29b19
jmp 0x29b0e
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x29ace
cmpl $0x0, -0x24(%rbp)
jbe 0x29b3d
movl -0x24(%rbp), %edx
shll $0x4, %edx
orl $0x8, %edx
movq -0x40(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x28(%rbp)
movl %ecx, %ecx
movl %edx, 0x1c(%rax,%rcx,4)
movl -0x24(%rbp), %ecx
movl -0x58(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x58(%rbp)
movl -0x24(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x24(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x29a2a
jmp 0x29bbc
cmpl $0x1, -0x54(%rbp)
jne 0x29b72
movl -0x58(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x29b96
cmpl $0x2, -0x54(%rbp)
jne 0x29b83
movl -0x58(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x29b94
cmpl $0x3, -0x54(%rbp)
jne 0x29b92
movl -0x58(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x29b94
jmp 0x29b96
jmp 0x29b98
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x20(%rbp), %ecx
movl 0x1c(%rax,%rcx,4), %edx
movq -0x40(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x28(%rbp)
movl %ecx, %ecx
movl %edx, 0x1c(%rax,%rcx,4)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x299e0
movl -0x28(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x2040
movq -0x40(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x48(%rax)
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)