// File: 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
movq %rsp, %rbp
subq $0xc0, %rsp
movq 0x60(%rbp), %rax
movq 0x58(%rbp), %rax
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq 0x18(%rbp), %rax
movq $0x0, (%rax)
movq 0x60(%rbp), %rax
movq $0x0, (%rax)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl -0x24(%rbp), %ecx
cmpq %rcx, %rax
jae 0x12c137
movq 0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
movl -0x24(%rbp), %edx
subq -0x48(%rbp), %rdx
subq $0x1, %rdx
movl (%rcx,%rdx,4), %ecx
movzbl (%rax,%rcx), %eax
cmpq 0x48(%rbp), %rax
jne 0x12c124
movq 0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
movl -0x24(%rbp), %edx
subq -0x48(%rbp), %rdx
subq $0x1, %rdx
movl (%rcx,%rdx,4), %ecx
cmpb $0x0, (%rax,%rcx)
je 0x12c124
movq 0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
movl -0x24(%rbp), %edx
subq -0x48(%rbp), %rdx
subq $0x1, %rdx
movl (%rcx,%rdx,4), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
cmpb $0x0, (%rax,%rcx)
jne 0x12c124
jmp 0x12c07e
movq 0x18(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x12c0ef
movq 0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x12c0ae
movq 0x18(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0xa0(%rbp)
jmp 0x12c0bc
movl $0x2, %eax
movq %rax, -0xa0(%rbp)
jmp 0x12c0bc
movq -0xa0(%rbp), %rcx
movq 0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x18(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x18(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x24(%rbp), %eax
subq -0x48(%rbp), %rax
subq $0x1, %rax
movl %eax, %edx
movq 0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movl %edx, (%rax,%rcx,4)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x12c126
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x12c003
cmpq $0x0, -0x50(%rbp)
jne 0x12c14b
movq $-0x1, -0x8(%rbp)
jmp 0x12c48d
movq $0x0, -0x60(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
movl 0x10(%rbp), %ecx
cmpq %rcx, %rax
jae 0x12c273
movq 0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
movq -0x58(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movzbl (%rax,%rcx), %eax
cmpq 0x50(%rbp), %rax
jne 0x12c260
movq 0x30(%rbp), %rax
movq -0x30(%rbp), %rcx
movq -0x58(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
cmpb $0x0, (%rax,%rcx)
jne 0x12c260
movq 0x30(%rbp), %rax
movq -0x30(%rbp), %rcx
movq -0x58(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
cmpb $0x0, (%rax,%rcx)
je 0x12c260
jmp 0x12c1c1
movq 0x18(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x12c232
movq 0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x12c1f1
movq 0x18(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0xa8(%rbp)
jmp 0x12c1ff
movl $0x2, %eax
movq %rax, -0xa8(%rbp)
jmp 0x12c1ff
movq -0xa8(%rbp), %rcx
movq 0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x18(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x18(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x58(%rbp), %rax
movl %eax, %edx
movq 0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movl %edx, (%rax,%rcx,4)
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x12c262
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x12c15b
cmpq $0x0, -0x60(%rbp)
jne 0x12c287
movq $-0x1, -0x8(%rbp)
jmp 0x12c48d
movq 0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x90(%rbp)
movq 0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x50(%rbp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x98(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x12c485
movq -0x18(%rbp), %rax
movq -0x90(%rbp), %rcx
movq -0x48(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %eax
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rax
movq -0x90(%rbp), %rcx
movq -0x48(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %eax
movq %rax, -0x70(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
jae 0x12c472
movq -0x30(%rbp), %rax
movq -0x98(%rbp), %rcx
movq -0x58(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %eax
movq %rax, -0x78(%rbp)
movq -0x38(%rbp), %rax
movq -0x98(%rbp), %rcx
movq -0x58(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %eax
movq %rax, -0x80(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq 0x28(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x12c37a
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x40(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movb $0x0, (%rax,%rcx)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x12c348
movq -0x10(%rbp), %rdi
movq -0x68(%rbp), %rax
movl %eax, %esi
movq -0x78(%rbp), %rax
movl %eax, %edx
movq 0x20(%rbp), %rcx
movq 0x28(%rbp), %r8
movq 0x30(%rbp), %r9
movq 0x40(%rbp), %r10
movq 0x58(%rbp), %rax
addq -0x70(%rbp), %rax
addq -0x80(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x12b680
movq %rax, -0x88(%rbp)
cmpq $-0x1, -0x88(%rbp)
je 0x12c45f
movq -0x88(%rbp), %rax
movq 0x58(%rbp), %rcx
addq -0x70(%rbp), %rcx
addq -0x80(%rbp), %rcx
cmpq %rcx, %rax
ja 0x12c45f
movq 0x40(%rbp), %rax
movq -0x68(%rbp), %rcx
shrq %rcx
cmpb $0x0, (%rax,%rcx)
je 0x12c418
movq 0x40(%rbp), %rax
movq -0x78(%rbp), %rcx
shrq %rcx
cmpb $0x0, (%rax,%rcx)
je 0x12c418
movq 0x60(%rbp), %rax
movq $0x1, (%rax)
movq $0x0, -0x8(%rbp)
jmp 0x12c48d
movq -0x88(%rbp), %rax
movq -0x70(%rbp), %rcx
addq -0x80(%rbp), %rcx
cmpq %rcx, %rax
jb 0x12c447
movq -0x88(%rbp), %rax
movq -0x70(%rbp), %rcx
addq -0x80(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0xb0(%rbp)
jmp 0x12c452
xorl %eax, %eax
movq %rax, -0xb0(%rbp)
jmp 0x12c452
movq -0xb0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x12c48d
jmp 0x12c461
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x12c300
jmp 0x12c474
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x12c2b8
movq $-0x1, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
nopw (%rax,%rax)