// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: select_unqiue_path_on_fly(usg_t*, unsigned long, unsigned long, asg64_v*, asg64_v*, unsigned long*, unsigned int*, unsigned long*, unsigned char*, unsigned long, asg64_v*)
void select_unqiue_path_on_fly(usg_t *g, uint64_t s, uint64_t e, asg64_v *b64, asg64_v *ub64,
uint64_t *integer_seq, uint32_t *ng_occ, uint64_t *is_reli, uint8_t *f, uint64_t max_ext, asg64_v *res)
{
    uint64_t k, sk = (uint64_t)-1, ek = (uint64_t)-1, *p = NULL; ub64->n = 0;
    assert(occ_m(ng_occ[integer_seq[s]]) == 1);
    assert(occ_m(ng_occ[integer_seq[e]^1]) == 1);
    
    if(reli_pass(is_reli[integer_seq[s]])) {
        sk = s; 
    } else {
        for (k = s + 1; k < e; k++) {
            if((reli_pass(is_reli[integer_seq[k]])) && (occ_m(ng_occ[integer_seq[k]]) == 1)) {
                sk = k;
                break;
            }
        }
    }
    if((sk == ((uint64_t)-1)) || (sk >= e)) return;

    for (k = sk + 1; k <= e; k++) {
        if(sk != ((uint64_t)-1)) {
            if(reli_pass(is_reli[(integer_seq[k]^1)])) {
                if(occ_m((ng_occ[integer_seq[k]]^1)) == 1) {
                    ek = k; ///check and extend [sk, ek]
                    if((ek > sk) && (get_ext_tip(g, integer_seq, sk, ek, b64, ub64, f, max_ext) < max_ext)) {
                        p = ((res->n > 0)? (&(res->a[res->n-1])):NULL);
                        if(p && (((uint32_t)(*p)) == sk)) {
                            (*p) >>= 32; (*p) <<= 32; (*p) |= ek;
                        } else {
                            kv_pushp(uint64_t, *res, &p); *p = sk; (*p) <<= 32; (*p) |= ek;
                        }
                    }
                    sk = ek = ((uint64_t)-1);
                }
            } else {
                sk = ek = ((uint64_t)-1);
            }
        }

        ///case2: sk != (uint64_t)-1 && ek == (uint64_t)-1 -> wait for an available ek
        ///case3: sk == (uint64_t)-1 && ek == (uint64_t)-1 -> not available
        if(k < e) {
            if((!(reli_pass(is_reli[integer_seq[k]])))) {
                sk = ek = (uint64_t)-1; continue;
            }
            if((sk == (uint64_t)-1) && (occ_m(ng_occ[integer_seq[k]]) == 1)) {
                sk = k;
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %rbx
movq %r8, %r9
movq %rcx, %r8
movq %rdx, %r12
movq 0x50(%rsp), %r11
andq $0x0, (%r9)
movq (%rbx,%rsi,8), %rax
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl (%r11,%rax,4), %edx
andl %ecx, %edx
cmpl $0x1, %edx
jne 0x1ccb1e
movq (%rbx,%r12,8), %rdx
xorq $0x1, %rdx
andl (%r11,%rdx,4), %ecx
cmpl $0x1, %ecx
jne 0x1ccb3d
movq %rsi, %r15
movq 0x58(%rsp), %r14
cmpq $0x0, (%r14,%rax,8)
js 0x1ccae3
cmpq %r12, %r15
jae 0x1ccb0f
leaq 0x1(%r15), %rbp
pushq $-0x1
popq %r13
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq %r9, 0x10(%rsp)
movq %r8, 0x8(%rsp)
movq %rdi, (%rsp)
cmpq %r12, %rbp
ja 0x1ccb0f
movq %r13, %rcx
cmpq $-0x1, %r15
jne 0x1cc9d9
cmpq %r12, %rbp
jae 0x1cc9d1
movq (%rbx,%rbp,8), %rax
cmpq $0x0, (%r14,%rax,8)
movq %r13, %r15
js 0x1cc9d4
movq %rcx, %r15
cmpq $-0x1, %rcx
jne 0x1cc9d4
movl (%r11,%rax,4), %eax
andl %edx, %eax
movq %rbp, %r15
cmpl $0x1, %eax
je 0x1cc9d4
movq %r13, %r15
jmp 0x1cc9d4
movq %rcx, %r15
incq %rbp
jmp 0x1cc990
movq (%rbx,%rbp,8), %rax
movq %rax, %rcx
xorq $0x1, %rcx
cmpq $0x0, (%r14,%rcx,8)
movq %r13, %rcx
js 0x1cc9a2
testl $0x7fffffff, (%r11,%rax,4) # imm = 0x7FFFFFFF
je 0x1cc9fd
movq %r15, %rcx
jmp 0x1cc9a2
movq %r13, %rcx
cmpq %r15, %rbp
jbe 0x1cc9a2
movq %rbx, %rsi
movq %r15, %rdx
movq %rbp, %rcx
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %r9
movq 0x68(%rsp), %rax
pushq %rax
pushq 0x68(%rsp)
callq 0x1cc43b
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq 0x80(%rsp), %r10
movq 0x60(%rsp), %r11
movq 0x10(%rsp), %rdi
addq $0x10, %rsp
movq %r13, %rcx
cmpq 0x68(%rsp), %rax
jae 0x1cc9a2
movq (%r10), %rcx
movq 0x10(%r10), %rax
testq %rcx, %rcx
je 0x1cca88
leaq (%rax,%rcx,8), %rdx
addq $-0x8, %rdx
je 0x1cca88
movq (%rdx), %rsi
movl %esi, %r10d
cmpq %r15, %r10
movq 0x70(%rsp), %r10
jne 0x1cca88
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
andq %rax, %rsi
movq %rsi, %r15
jmp 0x1ccad0
cmpq 0x8(%r10), %rcx
jne 0x1ccac1
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r10)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x70(%rsp), %r10
movq 0x50(%rsp), %r11
movq (%rsp), %rdi
movq %rax, 0x10(%r10)
movq (%r10), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r10)
leaq (%rax,%rcx,8), %rdx
shlq $0x20, %r15
orq %rbp, %r15
movq %r15, (%rdx)
movq %r13, %rcx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
jmp 0x1cc9a2
incq %r15
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpq %r12, %r15
jae 0x1ccb0f
movq (%rbx,%r15,8), %rcx
cmpq $0x0, (%r14,%rcx,8)
js 0x1ccb0a
movl (%r11,%rcx,4), %ecx
andl %eax, %ecx
cmpl $0x1, %ecx
je 0x1cc96c
incq %r15
jmp 0x1ccaeb
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2e104(%rip), %rdi     # 0x1fac29
leaq 0x2a9ad(%rip), %rsi     # 0x1f74d9
leaq 0x2e119(%rip), %rcx     # 0x1fac4c
movl $0x3267, %edx           # imm = 0x3267
callq 0x2110
leaq 0x2e19e(%rip), %rdi     # 0x1face2
leaq 0x2a98e(%rip), %rsi     # 0x1f74d9
leaq 0x2e0fa(%rip), %rcx     # 0x1fac4c
movl $0x3268, %edx           # imm = 0x3268
callq 0x2110