// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Overlaps.cpp
// Function: trace_back_tangle_dis(asg_t*, unsigned int*, unsigned int*, unsigned int, unsigned int*, unsigned int*, unsigned int, asg32_v*, asg32_v*, asg32_v*, unsigned char*, unsigned char*, unsigned char*, unsigned long, unsigned long, unsigned long, unsigned long*)
uint64_t trace_back_tangle_dis(asg_t *g, uint32_t *s, uint32_t *sd, uint32_t sn, uint32_t *e, uint32_t *ed, uint32_t en, asg32_v *b, asg32_v *b1, asg32_v *b2, uint8_t *f, uint8_t *fs, uint8_t *fsk, uint64_t sf, uint64_t ef, uint64_t max_path, uint64_t *is_dip)
{
    uint64_t k, sk, sm, ek, em, s0, slen, e0, elen, tot; b->n = 0; (*is_dip) = 0;
    for (sk = sm = 0; sk < sn; sk++) {
        if((fs[s[sn-sk-1]] == sf) && (f[s[sn-sk-1]]) && (!f[s[sn-sk-1]^1])) {///a potiential 
            kv_push(uint32_t, *b, sn-sk-1); sm++;
        }
    }
    if(!sm) return ((uint64_t)-1);

    for (ek = em = 0; ek < en; ek++) {
        if((fs[e[ek]] == ef) && (!f[e[ek]]) && (f[e[ek]^1])) {///a potiential 
            kv_push(uint32_t, *b, ek); em++;
        }
    }
    if(!em) return ((uint64_t)-1);

    uint32_t *si = b->a, *ei = b->a + sm;
    for (sk = 0; sk < sm; sk++) {
        s0 = s[si[sk]]; slen = sd[si[sk]];
        for (ek = 0; ek < em; ek++) {
            e0 = e[ei[ek]]; elen = ed[ei[ek]];   
            for (k = 0; k < b2->n; k++) f[b2->a[k]] = 0;
            
            tot = cal_self_close_tang_flank1(g, s0, e0, b1, b2, f, fsk, max_path + slen + elen);
            if((tot != ((uint64_t)-1)) && (tot <= (max_path + slen + elen))) {
                if(fsk[s0>>1] && fsk[e0>>1]) {
                    (*is_dip) = 1;
                    return 0;
                } else {
                    return ((tot>=(slen + elen))?(tot-(slen + elen)):(0));
                }
            }
        }
    }
    return ((uint64_t)-1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, 0x70(%rsp)
movq %r8, 0x8(%rsp)
movq %rdx, 0x40(%rsp)
movq %rdi, 0x68(%rsp)
movq 0x100(%rsp), %rax
movq 0xd8(%rsp), %r15
movq 0xd0(%rsp), %rbp
movq 0xb8(%rsp), %r9
xorl %r14d, %r14d
movq %r14, (%r9)
movq %r14, (%rax)
testl %ecx, %ecx
movq %rsi, 0x18(%rsp)
je 0xdca36
movq 0xe8(%rsp), %r12
movl %ecx, %r13d
xorl %r14d, %r14d
movl $0x2, %ebx
movl -0x4(%rsi,%r13,4), %eax
movzbl (%r15,%rax), %ecx
cmpq %r12, %rcx
jne 0xdca31
cmpb $0x0, (%rbp,%rax)
je 0xdca31
xorq $0x1, %rax
cmpb $0x0, (%rbp,%rax)
jne 0xdca31
movq 0x8(%r9), %rax
cmpq %rax, (%r9)
jne 0xdca19
leaq (%rax,%rax), %rsi
testq %rax, %rax
cmoveq %rbx, %rsi
movq %rsi, 0x8(%r9)
movq 0x10(%r9), %rdi
shlq $0x2, %rsi
callq 0x2370
movq 0xb8(%rsp), %r9
movq 0x18(%rsp), %rsi
movq %rax, 0x10(%r9)
leal -0x1(%r13), %eax
movq (%r9), %rcx
movq 0x10(%r9), %rdx
leaq 0x1(%rcx), %rdi
movq %rdi, (%r9)
movl %eax, (%rdx,%rcx,4)
incq %r14
decq %r13
jne 0xdc9c2
movq $-0x1, %rax
testq %r14, %r14
je 0xdcc6e
movl 0xb0(%rsp), %eax
testl %eax, %eax
je 0xdcaf2
movq 0xf0(%rsp), %rbx
movl %eax, %r13d
xorl %r12d, %r12d
movq $0x0, 0x10(%rsp)
movq 0x8(%rsp), %rdi
movl (%rdi,%r12,4), %eax
movzbl (%r15,%rax), %ecx
cmpq %rbx, %rcx
jne 0xdcae8
cmpb $0x0, (%rbp,%rax)
jne 0xdcae8
xorq $0x1, %rax
cmpb $0x0, (%rbp,%rax)
je 0xdcae8
movq 0x8(%r9), %rax
cmpq %rax, (%r9)
jne 0xdcad1
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r9)
movq 0x10(%r9), %rdi
shlq $0x2, %rsi
callq 0x2370
movq 0x8(%rsp), %rdi
movq 0xb8(%rsp), %r9
movq 0x18(%rsp), %rsi
movq %rax, 0x10(%r9)
movq (%r9), %rax
movq 0x10(%r9), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r9)
movl %r12d, (%rcx,%rax,4)
incq 0x10(%rsp)
incq %r12
cmpq %r12, %r13
jne 0xdca71
jmp 0xdcb00
movq $0x0, 0x10(%rsp)
movq 0x8(%rsp), %rdi
cmpq $0x0, 0x10(%rsp)
je 0xdcc22
movq 0xf8(%rsp), %rdx
movq 0xe0(%rsp), %r10
movq 0xc8(%rsp), %r15
movq 0x10(%r9), %rax
leaq (%rax,%r14,4), %rcx
movq %rcx, 0x58(%rsp)
cmpq $0x1, %r14
adcq $0x0, %r14
xorl %ecx, %ecx
movq %r14, 0x28(%rsp)
movq %rax, 0x20(%rsp)
movq %rcx, 0x38(%rsp)
movl (%rax,%rcx,4), %eax
movl (%rsi,%rax,4), %ecx
movq %rcx, 0x8(%rsp)
movq 0x40(%rsp), %rcx
movl (%rcx,%rax,4), %eax
movq %rax, 0x30(%rsp)
addq %rdx, %rax
movq %rax, 0x60(%rsp)
xorl %r13d, %r13d
movq 0x58(%rsp), %rax
movl (%rax,%r13,4), %eax
movq %rdi, %r14
movl (%rdi,%rax,4), %edx
movq 0x70(%rsp), %rcx
movl (%rcx,%rax,4), %esi
cmpq $0x0, (%r15)
je 0xdcba0
xorl %eax, %eax
movq 0x10(%r15), %rcx
movl (%rcx,%rax,4), %ecx
movb $0x0, (%rbp,%rcx)
incq %rax
cmpq (%r15), %rax
jb 0xdcb8c
movq %rsi, 0x48(%rsp)
movq 0x60(%rsp), %rax
leaq (%rax,%rsi), %r12
movq 0x68(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %rdx, 0x50(%rsp)
movq 0xc0(%rsp), %rcx
movq %r15, %r8
movq %rbp, %r9
pushq %r12
movq %r10, %rbx
pushq %r10
callq 0xdc451
addq $0x10, %rsp
cmpq $-0x1, %rax
je 0xdcbe6
cmpq %r12, %rax
jbe 0xdcc2b
incq %r13
cmpq 0x10(%rsp), %r13
movq %r14, %rdi
movq %rbx, %r10
jne 0xdcb6d
movq 0x38(%rsp), %rcx
incq %rcx
movq 0x28(%rsp), %r14
cmpq %r14, %rcx
movq 0x18(%rsp), %rsi
movq 0xf8(%rsp), %rdx
movq 0x20(%rsp), %rax
jne 0xdcb45
movq $-0x1, %rax
jmp 0xdcc6e
movq 0x8(%rsp), %rcx
shrl %ecx
cmpb $0x0, (%rbx,%rcx)
je 0xdcc58
movq 0x50(%rsp), %rcx
shrl %ecx
cmpb $0x0, (%rbx,%rcx)
je 0xdcc58
movq 0x100(%rsp), %rax
movq $0x1, (%rax)
xorl %eax, %eax
jmp 0xdcc6e
movq 0x48(%rsp), %rdx
addq 0x30(%rsp), %rdx
xorl %ecx, %ecx
subq %rdx, %rax
cmovaeq %rax, %rcx
movq %rcx, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq