// File: /workspace/github_c_makefile_star2_O3/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 $0x0, (%rcx)
testl %esi, %esi
js 0xb723
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r15
movl $0xffffff0f, %r9d       # imm = 0xFFFFFF0F
movq 0x10(%r15), %rax
movl %esi, %ecx
shlq $0x4, %rcx
leaq (%rax,%rcx), %r13
movb 0xc(%rax,%rcx), %r12b
movq (%rbx), %rcx
movq 0x10(%rbx), %rax
cmpq 0x8(%rbx), %rcx
jne 0xb4f7
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rdx
movq %rdx, 0x8(%rbx)
shlq $0x2, %rdx
leaq (%rdx,%rdx,2), %rsi
movq %rax, %rdi
callq 0x2260
movl $0xffffff0f, %r9d       # imm = 0xFFFFFF0F
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
movb 0xc(%r13), %dl
jmp 0xb4fa
movl %r12d, %edx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rbx)
leaq (%rcx,%rcx,2), %rcx
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 0xb53e
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 0xb57a
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 0xb57a
leaq (%rdx,%rsi,4), %rdx
movb 0x2(%rdx), %dl
jmp 0xb57c
xorl %edx, %edx
movb %dl, 0x2(%rax)
movw $0x400, %dx             # imm = 0x400
cmpb $0x2, 0xc(%r13)
je 0xb5a0
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 0xb5bc
xorl %ecx, %ecx
jmp 0xb5cc
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)
movslq 0x4(%r13), %rbp
movb $-0x1, %cl
cmpb $0x1, %r12b
ja 0xb605
movq 0x10(%r14), %rcx
leaq (,%rbp,2), %rdx
addq %rbp, %rdx
movb 0x4(%rcx,%rdx,4), %cl
movb %cl, 0x4(%rax)
movl (%r13), %esi
testl %esi, %esi
jns 0xb4a0
testl %ebp, %ebp
jle 0xb723
leaq (,%rbp,2), %rax
addq %rbp, %rax
incq %rbp
leaq -0xc(,%rax,4), %r15
movl $0x2, %r12d
movq (%rbx), %rcx
movq 0x10(%rbx), %rax
cmpq 0x8(%rbx), %rcx
jne 0xb66b
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
cmoveq %r12, %rdx
movq %rdx, 0x8(%rbx)
shlq $0x2, %rdx
leaq (%rdx,%rdx,2), %rsi
movq %rax, %rdi
callq 0x2260
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
leaq (%rcx,%rcx,2), %rcx
movq 0x10(%r14), %rdx
movl 0x8(%rdx,%r15), %esi
movl %esi, 0x8(%rax,%rcx,4)
movq (%rdx,%r15), %rdx
movq %rdx, (%rax,%rcx,4)
decq %rbp
addq $-0xc, %r15
cmpq $0x1, %rbp
ja 0xb638
movq (%rbx), %rsi
cmpq $0x2, %rsi
jb 0xb714
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 0xb6ac
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1261f(%rip), %rdi     # 0x1dd49
leaq 0x11f9a(%rip), %rsi     # 0x1d6cb
leaq 0x1261a(%rip), %rcx     # 0x1dd52
movl $0x284, %edx            # imm = 0x284
callq 0x2120