// File: chhylp123[P]hifiasm/gfa_ut.cpp
// Function: select_unqiue_path_on_fly_raw(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_raw(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);
    sk = s; ek = e;
    if(get_ext_tip(g, integer_seq, sk, ek, b64, ub64, f, max_ext) < max_ext) {
        kv_pushp(uint64_t, *res, &p); *p = sk; (*p) <<= 32; (*p) |= ek;
        // fprintf(stderr, "+ext_k::[%lu, %lu]\ts::%lu\te::%lu\n", sk, ek, s, e);
        // fprintf(stderr, "occ[sk]::%u\tocc[ek]::%u\tocc[s]::%u\tocc[e]::%u\n", 
        // occ_m(ng_occ[integer_seq[sk]]), occ_m(ng_occ[integer_seq[ek]^1]), 
        // occ_m(ng_occ[integer_seq[s]]), occ_m(ng_occ[integer_seq[e]^1]));
    }
    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
movq %rsp, %rbp
subq $0x70, %rsp
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $-0x1, -0x40(%rbp)
movq $-0x1, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movq 0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movl (%rax,%rcx,4), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpl $0x1, %eax
jne 0x35ba46
jmp 0x35ba65
leaq 0x3df0d(%rip), %rdi     # 0x39995a
leaq 0x3a765(%rip), %rsi     # 0x3961b9
movl $0x329b, %edx           # imm = 0x329B
leaq 0x3dfd8(%rip), %rcx     # 0x399a38
callq 0x2130
movq 0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
xorq $0x1, %rcx
movl (%rax,%rcx,4), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpl $0x1, %eax
jne 0x35ba88
jmp 0x35baa7
leaq 0x3df84(%rip), %rdi     # 0x399a13
leaq 0x3a723(%rip), %rsi     # 0x3961b9
movl $0x329c, %edx           # imm = 0x329C
leaq 0x3df96(%rip), %rcx     # 0x399a38
callq 0x2130
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x20(%rbp), %r8
movq -0x28(%rbp), %r9
movq 0x20(%rbp), %r10
movq 0x28(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x35aa50
cmpq 0x28(%rbp), %rax
jae 0x35bba4
jmp 0x35baf1
movq 0x30(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x35bb59
movq 0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x35bb1e
movq 0x30(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x58(%rbp)
jmp 0x35bb29
movl $0x2, %eax
movq %rax, -0x58(%rbp)
jmp 0x35bb29
movq -0x58(%rbp), %rcx
movq 0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x30(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x30(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq 0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x30(%rbp), %rdx
movq (%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, (%rdx)
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, (%rax)
movq -0x50(%rbp), %rax
movq (%rax), %rcx
shlq $0x20, %rcx
movq %rcx, (%rax)
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %rax
orq (%rax), %rcx
movq %rcx, (%rax)
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)