// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Correct.cpp
// Function: update_ol_track(overlap_region_alloc*, Candidates_list*, hpc_t*, ul_idx_t const*, unsigned int, unsigned long, char*, kvec_t_u32_warp*)
uint64_t update_ol_track(overlap_region_alloc* ol, Candidates_list *cl, hpc_t *hpc_g, const ul_idx_t *udb, uint32_t apend_be, uint64_t qlen, 
char *qstr, kvec_t_u32_warp* q_idx)
{
    uint64_t cln = cl->length, i, k, l, m = 0; overlap_region *r; 
    if(hpc_g) {
        if(ol->length) {
            q_idx->a.n = 0; kv_resize(uint32_t, q_idx->a, qlen); m = 0;
            for (l = 0, k = 1; k <= qlen; k++) {
                if((k == qlen) || (qstr[k] != qstr[l]) || (seq_nt4_table[(uint8_t)qstr[l]] >= 4)) {
                    for (i = l; i < k; i++) q_idx->a.a[i] = m;
                    l = k; m++;
                }
            }
    
            for (i = k = 0; i < ol->length; ++i) {
                r = &(ol->list[i]); k = r->non_homopolymer_errors;
                update_ov_track_hpc_0(&(r->f_cigar), r, apend_be, m, q_idx->a.a, 
                (uint32_t)hpc_g->mm->idx[r->y_id], hpc_g->mm->a + (hpc_g->mm->idx[r->y_id]>>32), 
                hpc_g, cl->list+k, cln-k);
            }
        }
    } else {
        if(ol->length) {
            for (i = k = 0; i < ol->length; ++i) {
                r = &(ol->list[i]); k = r->non_homopolymer_errors;
                update_ov_track_0(&(r->f_cigar), r, apend_be, qlen, udb->ug->u.a[r->y_id].len, cl->list+k, cln-k);
            }
        }
    }
    return m;///hpc length
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r12
movq %rdx, %rbx
movq %rsi, %rdx
movq %rdi, %r14
movq 0x8(%rsi), %rbp
movq 0x10(%rdi), %rax
testq %rbx, %rbx
je 0x59357
testq %rax, %rax
je 0x593f9
movl %r8d, 0x8(%rsp)
movq 0x68(%rsp), %r13
movq $0x0, (%r13)
cmpq %r12, 0x8(%r13)
movq %rdx, 0x18(%rsp)
jae 0x59401
leaq -0x1(%r12), %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x8(%r13)
movq 0x10(%r13), %rdi
leaq 0x4(,%rcx,4), %rsi
callq 0x2370
movq %rax, 0x10(%r13)
jmp 0x5940a
testq %rax, %rax
je 0x593f9
movl %r8d, %eax
movq %rax, 0x10(%rsp)
movl $0x38, %ebx
xorl %r15d, %r15d
xorl %r13d, %r13d
movq %r12, 0x20(%rsp)
movq %rcx, 0x8(%rsp)
movq (%r14), %rdi
leaq (%rdi,%rbx), %rsi
addq $-0x38, %rsi
addq %rbx, %rdi
movl 0x10(%rsi), %eax
movl 0x30(%rsi), %r9d
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq 0x10(%rcx), %rcx
leaq (%rax,%rax,4), %rax
movl (%rcx,%rax,8), %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movq %rbp, %rax
subq %r9, %rax
shlq $0x4, %r9
addq (%rdx), %r9
subq $0x8, %rsp
movq %rbp, %r12
movq %r14, %rbp
movq %rdx, %r14
movq 0x18(%rsp), %rdx
movq 0x28(%rsp), %rcx
pushq %rax
callq 0x58d23
movq %r14, %rdx
movq %rbp, %r14
movq %r12, %rbp
addq $0x10, %rsp
incq %r13
addq $0xa8, %rbx
cmpq 0x10(%r14), %r13
jb 0x5937d
jmp 0x59609
xorl %r15d, %r15d
jmp 0x59609
testq %r12, %r12
je 0x5961b
movq 0x60(%rsp), %rax
leaq 0x1(%r12), %rdx
cmpq $0x3, %rdx
movl $0x2, %ecx
cmovaeq %rdx, %rcx
movl $0x1, %edx
movl $0x4, %esi
xorl %r15d, %r15d
movdqa 0x1d7e8a(%rip), %xmm0   # 0x2312c0
movdqa 0x1d7e92(%rip), %xmm1   # 0x2312d0
movdqa 0x1d7e9a(%rip), %xmm2   # 0x2312e0
pcmpeqd %xmm3, %xmm3
leaq 0x1e07cf(%rip), %rdi    # 0x239c20
xorl %r9d, %r9d
cmpq %r12, %rdx
je 0x5946f
movzbl (%rax,%rdx), %r8d
cmpb (%rax,%r9), %r8b
jne 0x5946f
cmpb $0x4, (%rdi,%r8)
jb 0x59565
cmpq %r9, %rdx
jbe 0x5955f
movq 0x10(%r13), %r10
movq %r9, %r8
notq %r8
addq %rdx, %r8
movq %r8, %xmm4
pshufd $0x44, %xmm4, %xmm4     # xmm4 = xmm4[0,1,0,1]
movq %rsi, %r8
subq %r9, %r8
andq $-0x4, %r8
leaq (%r10,%r9,4), %r9
addq $0xc, %r9
pxor %xmm2, %xmm4
xorl %r10d, %r10d
movq %r10, %xmm5
pshufd $0x44, %xmm5, %xmm5     # xmm5 = xmm5[0,1,0,1]
movdqa %xmm5, %xmm6
por %xmm1, %xmm6
pxor %xmm2, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm4, %xmm7
pcmpeqd %xmm4, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %r11d
notl %r11d
testb $0x1, %r11b
je 0x594f2
movl %r15d, -0xc(%r9,%r10,4)
pxor %xmm3, %xmm6
pextrw $0x4, %xmm6, %r11d
testb $0x1, %r11b
je 0x59507
movl %r15d, -0x8(%r9,%r10,4)
por %xmm0, %xmm5
pxor %xmm2, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm4, %xmm6
pcmpeqd %xmm4, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
pxor %xmm3, %xmm5
pextrw $0x0, %xmm5, %r11d
testb $0x1, %r11b
je 0x59542
movl %r15d, -0x4(%r9,%r10,4)
pextrw $0x4, %xmm5, %r11d
testb $0x1, %r11b
je 0x59552
movl %r15d, (%r9,%r10,4)
addq $0x4, %r10
cmpq %r10, %r8
jne 0x594a8
incq %r15
movq %rdx, %r9
incq %rdx
incq %rsi
cmpq %rcx, %rdx
jne 0x59454
cmpq $0x0, 0x10(%r14)
je 0x59609
movl 0x8(%rsp), %eax
movq %rax, 0x8(%rsp)
movq %rbp, 0x10(%rsp)
movl $0x38, %ebp
movq %rbx, %r13
xorl %ebx, %ebx
movq 0x18(%rsp), %r12
movq (%r14), %rdi
leaq (%rdi,%rbp), %rsi
addq $-0x38, %rsi
addq %rbp, %rdi
movl 0x10(%rsi), %eax
movl 0x30(%rsi), %r10d
movq 0x68(%rsp), %rcx
movq 0x10(%rcx), %r8
movq 0x20(%r13), %rcx
movq 0x18(%rcx), %rdx
movq (%rdx,%rax,8), %rax
movl %eax, %r9d
shrq $0x20, %rax
addq 0x10(%rcx), %rax
movq 0x10(%rsp), %r11
subq %r10, %r11
shlq $0x4, %r10
addq (%r12), %r10
movq 0x8(%rsp), %rdx
movq %r15, %rcx
pushq %r11
pushq %r10
pushq %r13
pushq %rax
callq 0x58f89
addq $0x20, %rsp
incq %rbx
addq $0xa8, %rbp
cmpq 0x10(%r14), %rbx
jb 0x5959c
movq %r15, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
jmp 0x59574