// File: /workspace/github_c_makefile_star2_O1/lh3[P]fermi2/correct.c
// Function: path_backtrack
static void path_backtrack(const ecstack_t *a, int start, const ecseq_t *o, ecseq_t *s)
{
	int i = start, last = -1;
	s->n = 0;
	while (i >= 0) {
		ecbase_t *c;
		ecstack1_t *p = &a->a[i];
		int is_match = (p->state == STATE_M || p->state == STATE_N);
		kv_pushp(ecbase_t, *s, &c);
		c->state = p->state;
		c->i = o->a[p->i].i;
		c->b = p->state == STATE_D? 4 : p->base;
		c->q = is_match && o->a[p->i].b == p->base? o->a[p->i].q : 0; // if we make a correction, reduce the base quality to 0.
		c->ob = p->state == STATE_I? 4 : o->a[p->i].ob; // no ob/oq for inserted bases
		c->oq = p->state == STATE_I? 0 : o->a[p->i].oq;
		c->f = (p->state != STATE_N);
		c->min_diff = is_match? o->a[p->i].min_diff : 0xff;
		last = p->i;
		i = p->parent;
	}
	assert(last > 0);
	for (i = last - 1; i >= 0; --i)
		kv_push(ecbase_t, *s, o->a[i]);
	for (i = 0; i < s->n>>1; ++i) { // reverse
		ecbase_t tmp = s->a[i];
		s->a[i] = s->a[s->n - 1 - i];
		s->a[s->n - 1 - i] = tmp;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq $0x0, (%rcx)
testl %esi, %esi
js 0xb148
movq %rdi, %r15
movl $0xffffff0f, %r9d       # imm = 0xFFFFFF0F
movq 0x10(%r15), %r13
movl %esi, %ebp
shlq $0x4, %rbp
movb 0xc(%r13,%rbp), %r12b
movq 0x8(%rbx), %rax
cmpq %rax, (%rbx)
jne 0xb021
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x8(%rbx)
movq 0x10(%rbx), %rdi
shlq $0x2, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2260
movl $0xffffff0f, %r9d       # imm = 0xFFFFFF0F
movq %rax, 0x10(%rbx)
addq %rbp, %r13
movq (%rbx), %rcx
movq 0x10(%rbx), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
leaq (%rcx,%rcx,2), %rcx
movb 0xc(%r13), %dl
shlb $0x4, %dl
movzbl %dl, %esi
movl (%rax,%rcx,4), %edx
andl %r9d, %edx
orl %esi, %edx
movw %dx, (%rax,%rcx,4)
movq 0x10(%r14), %rsi
movslq 0x4(%r13), %rdi
leaq (%rdi,%rdi,2), %rdi
movl 0x8(%rsi,%rdi,4), %esi
movl %esi, 0x8(%rax,%rcx,4)
movw $0x4, %si
cmpb $0x3, 0xc(%r13)
je 0xb073
movzbl 0xd(%r13), %esi
andl $0xf, %esi
leaq (%rax,%rcx,4), %rax
andl $-0x10, %edx
movzwl %si, %ecx
orl %edx, %ecx
movw %cx, (%rax)
cmpb $0x1, %r12b
ja 0xb0af
movq 0x10(%r14), %rdx
movslq 0x4(%r13), %rsi
leaq (%rsi,%rsi,2), %rsi
movzwl (%rdx,%rsi,4), %edi
andl $0xf, %edi
movzbl 0xd(%r13), %r8d
cmpw %r8w, %di
jne 0xb0af
leaq (%rdx,%rsi,4), %rdx
movb 0x2(%rdx), %dl
jmp 0xb0b1
xorl %edx, %edx
movb %dl, 0x2(%rax)
movw $0x400, %dx             # imm = 0x400
cmpb $0x2, 0xc(%r13)
je 0xb0d5
movq 0x10(%r14), %rdx
movslq 0x4(%r13), %rsi
leaq (%rsi,%rsi,2), %rsi
movzwl (%rdx,%rsi,4), %edx
andl $0xf00, %edx            # imm = 0xF00
andl $0xfffff0ff, %ecx       # imm = 0xFFFFF0FF
movzwl %dx, %edx
orl %ecx, %edx
movw %dx, (%rax)
movb 0xc(%r13), %sil
cmpb $0x2, %sil
jne 0xb0f1
xorl %ecx, %ecx
jmp 0xb101
movq 0x10(%r14), %rcx
movslq 0x4(%r13), %rdi
leaq (%rdi,%rdi,2), %rdi
movb 0x3(%rcx,%rdi,4), %cl
xorl %edi, %edi
testb %sil, %sil
setne %dil
shll $0xc, %edi
andl $0xfff, %edx            # imm = 0xFFF
orl %edi, %edx
movb %cl, 0x3(%rax)
movw %dx, (%rax)
movb $-0x1, %cl
cmpb $0x1, %r12b
ja 0xb133
movq 0x10(%r14), %rcx
movslq 0x4(%r13), %rdx
leaq (%rdx,%rdx,2), %rdx
movb 0x4(%rcx,%rdx,4), %cl
movb %cl, 0x4(%rax)
movl (%r13), %esi
testl %esi, %esi
jns 0xafda
movl 0x4(%r13), %eax
jmp 0xb14d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %eax, %eax
jle 0xb259
movl %eax, %r15d
leaq (%r15,%r15,2), %rax
incq %r15
leaq -0xc(,%rax,4), %r12
movl $0x2, %r13d
movq 0x8(%rbx), %rax
cmpq %rax, (%rbx)
jne 0xb19a
leaq (%rax,%rax), %rcx
testq %rax, %rax
cmoveq %r13, %rcx
movq %rcx, 0x8(%rbx)
movq 0x10(%rbx), %rdi
shlq $0x2, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2260
movq %rax, 0x10(%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rbx)
leaq (%rax,%rax,2), %rax
movq 0x10(%r14), %rdx
movq (%rdx,%r12), %rsi
movq %rsi, (%rcx,%rax,4)
movl 0x8(%rdx,%r12), %edx
movl %edx, 0x8(%rcx,%rax,4)
decq %r15
addq $-0xc, %r12
cmpq $0x1, %r15
jg 0xb16d
movq (%rbx), %rsi
cmpq $0x2, %rsi
jb 0xb24a
movq $-0xc, %rax
xorl %ecx, %ecx
xorl %edx, %edx
movq 0x10(%rbx), %rdi
movl 0x8(%rdi,%rcx), %r8d
movl %r8d, 0x10(%rsp)
movq (%rdi,%rcx), %r8
movq %r8, 0x8(%rsp)
leaq (%rsi,%rsi,2), %rsi
leaq (%rdi,%rsi,4), %rsi
movq (%rax,%rsi), %r8
movq %r8, (%rdi,%rcx)
movl 0x8(%rax,%rsi), %esi
movl %esi, 0x8(%rdi,%rcx)
movq (%rbx), %rsi
leaq (%rsi,%rsi,2), %rsi
shlq $0x2, %rsi
addq 0x10(%rbx), %rsi
movl 0x10(%rsp), %edi
movl %edi, 0x8(%rax,%rsi)
movq 0x8(%rsp), %rdi
movq %rdi, (%rax,%rsi)
incq %rdx
movq (%rbx), %rsi
movq %rsi, %rdi
shrq %rdi
addq $-0xc, %rax
addq $0xc, %rcx
cmpq %rdx, %rdi
ja 0xb1e2
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11971(%rip), %rdi     # 0x1cbd1
leaq 0x112ec(%rip), %rsi     # 0x1c553
leaq 0x1196c(%rip), %rcx     # 0x1cbda
movl $0x284, %edx            # imm = 0x284
callq 0x2120