// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x24(%rbp)
movl $0xffffffff, -0x28(%rbp) # imm = 0xFFFFFFFF
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
cmpl $0x0, -0x24(%rbp)
jl 0xe775
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movzbl 0xc(%rax), %ecx
movb $0x1, %al
cmpl $0x1, %ecx
movb %al, -0x49(%rbp)
je 0xe4c6
movq -0x38(%rbp), %rax
movzbl 0xc(%rax), %eax
cmpl $0x0, %eax
sete %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0xe536
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xe4fe
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x58(%rbp)
jmp 0xe509
movl $0x2, %eax
movq %rax, -0x58(%rbp)
jmp 0xe509
movq -0x58(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rax
imulq $0xc, 0x8(%rax), %rsi
callq 0x2270
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rdx
movq (%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, (%rdx)
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rax
movb 0xc(%rax), %cl
movq -0x30(%rbp), %rax
movzbl %cl, %ecx
movw %cx, %dx
movw (%rax), %cx
andw $0xf, %dx
shlw $0x4, %dx
andw $0xff0f, %cx            # imm = 0xFF0F
orw %dx, %cx
movw %cx, (%rax)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
movslq 0x4(%rcx), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x38(%rbp), %rax
movzbl 0xc(%rax), %eax
cmpl $0x3, %eax
jne 0xe5b9
movl $0x4, %eax
movl %eax, -0x5c(%rbp)
jmp 0xe5c4
movq -0x38(%rbp), %rax
movzbl 0xd(%rax), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movzbl %cl, %ecx
movw %cx, %dx
movw (%rax), %cx
andw $0xf, %dx
andw $-0x10, %cx
orw %dx, %cx
movw %cx, (%rax)
cmpl $0x0, -0x3c(%rbp)
je 0xe637
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
movslq 0x4(%rcx), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movw (%rax), %ax
andw $0xf, %ax
movzbl %al, %eax
movq -0x38(%rbp), %rcx
movzbl 0xd(%rcx), %ecx
cmpl %ecx, %eax
jne 0xe637
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
movslq 0x4(%rcx), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movzbl 0x2(%rax), %eax
movl %eax, -0x60(%rbp)
jmp 0xe63e
xorl %eax, %eax
movl %eax, -0x60(%rbp)
jmp 0xe63e
movl -0x60(%rbp), %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0x2(%rax)
movq -0x38(%rbp), %rax
movzbl 0xc(%rax), %eax
cmpl $0x2, %eax
jne 0xe661
movl $0x4, %eax
movl %eax, -0x64(%rbp)
jmp 0xe689
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
movslq 0x4(%rcx), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movw (%rax), %ax
shrw $0x8, %ax
andw $0xf, %ax
movzbl %al, %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movzbl %cl, %ecx
movw %cx, %dx
movw (%rax), %cx
andw $0xf, %dx
shlw $0x8, %dx
andw $0xf0ff, %cx            # imm = 0xF0FF
orw %dx, %cx
movw %cx, (%rax)
movq -0x38(%rbp), %rax
movzbl 0xc(%rax), %eax
cmpl $0x2, %eax
jne 0xe6c2
xorl %eax, %eax
movl %eax, -0x68(%rbp)
jmp 0xe6e0
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
movslq 0x4(%rcx), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movzbl 0x3(%rax), %eax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0x3(%rax)
movq -0x38(%rbp), %rax
movzbl 0xc(%rax), %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movzbl %cl, %ecx
movw %cx, %dx
movw (%rax), %cx
andw $0xf, %dx
shlw $0xc, %dx
andw $0xfff, %cx             # imm = 0xFFF
orw %dx, %cx
movw %cx, (%rax)
cmpl $0x0, -0x3c(%rbp)
je 0xe747
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
movslq 0x4(%rcx), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movzbl 0x4(%rax), %eax
movl %eax, -0x6c(%rbp)
jmp 0xe751
movl $0xff, %eax
movl %eax, -0x6c(%rbp)
jmp 0xe751
movl -0x6c(%rbp), %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0x4(%rax)
movq -0x38(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x38(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x24(%rbp)
jmp 0xe482
cmpl $0x0, -0x28(%rbp)
jle 0xe77d
jmp 0xe79c
leaq 0x1e3f5(%rip), %rdi     # 0x2cb79
leaq 0x1dd70(%rip), %rsi     # 0x2c4fb
movl $0x284, %edx            # imm = 0x284
leaq 0x1e3eb(%rip), %rcx     # 0x2cb82
callq 0x2140
movl -0x28(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jl 0xe865
jmp 0xe7b1
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0xe816
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xe7de
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x78(%rbp)
jmp 0xe7e9
movl $0x2, %eax
movq %rax, -0x78(%rbp)
jmp 0xe7e9
movq -0x78(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rax
imulq $0xc, 0x8(%rax), %rsi
callq 0x2270
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rdx
movq (%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, (%rdx)
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movslq -0x24(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movl 0x8(%rcx), %ecx
movl %ecx, 0x8(%rax)
jmp 0xe857
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xe7a5
movl $0x0, -0x24(%rbp)
movslq -0x24(%rbp), %rax
movq -0x20(%rbp), %rcx
movq (%rcx), %rcx
shrq %rcx
cmpq %rcx, %rax
jae 0xe91f
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x48(%rbp)
movl 0x8(%rax), %eax
movl %eax, -0x40(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x20(%rbp), %rdx
movq (%rdx), %rdx
subq $0x1, %rdx
movslq -0x24(%rbp), %rsi
subq %rsi, %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movl 0x8(%rcx), %ecx
movl %ecx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rcx
movq (%rcx), %rcx
subq $0x1, %rcx
movslq -0x24(%rbp), %rdx
subq %rdx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x48(%rbp), %rcx
movq %rcx, (%rax)
movl -0x40(%rbp), %ecx
movl %ecx, 0x8(%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xe86c
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)