// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: append_trans_check(flex_asg_t*, unsigned long*, unsigned long)
uint32_t append_trans_check(flex_asg_t *fg, uint64_t *a, uint64_t a_n)
{
    ma_hit_t_alloc* src = fg->src; int32_t idx, r; 
    uint32_t i, k, v, w; ma_hit_t_alloc *z; asg_arc_t t0, t1; 
    for (i = 0; i < a_n; i++) {
        v = a[i]; 
        z = &(src[v>>1]);
        for (k = i + 1; k < a_n; k++) {
            w = a[k]^1;
            idx = get_specific_overlap(z, v>>1, w>>1);
            if(idx < 0 || z->buffer[idx].del) return 0;
            r = ma_hit2arc(&(z->buffer[idx]), Get_READ_LENGTH(R_INF, v>>1), Get_READ_LENGTH(R_INF, w>>1),
                        fg->max_hang, fg->max_hang_rate, fg->min_ovlp, &t0);
            if(r < 0) return 0;
            if((t0.ul>>32) != v || t0.v != w) return 0;
            t0.ou = ((z->buffer[idx].bl>OU_MASK)?OU_MASK:z->buffer[idx].bl);
            // if((v>>1) == 8340 && (w>>1) == 8352) {
            //     fprintf(stderr, "[M::%s] v>>1::%u(%c), w>>1::%u(%c), t0.ou::%u\n", 
            //     __func__, (v>>1), "+-"[v&1], (w>>1), "+-"[w&1], t0.ou);
            // }


            idx = get_specific_overlap(&(src[w>>1]), w>>1, v>>1);
            if(idx < 0 || src[w>>1].buffer[idx].del) return 0;
            r = ma_hit2arc(&(src[w>>1].buffer[idx]), Get_READ_LENGTH(R_INF, w>>1), Get_READ_LENGTH(R_INF, v>>1),
                        fg->max_hang, fg->max_hang_rate, fg->min_ovlp, &t1);
            if(r < 0) return 0;
            if((t1.ul>>32) != (w^1) || t1.v != (v^1)) return 0;
            t1.ou = ((src[w>>1].buffer[idx].bl>OU_MASK)?OU_MASK:src[w>>1].buffer[idx].bl);
        }
    }
    return 1;
}

// Assembly:
testq %rdx, %rdx
je 0x1f6454
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r13
movq (%rdi), %rax
movq %rax, 0x8(%rsp)
xorl %eax, %eax
movl $0x2, %edi
xorl %r8d, %r8d
movq %rdx, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
incl %r8d
cmpq %rdx, %r8
jae 0x1f643b
movq (%rsi,%rax,8), %rax
movl %eax, %ecx
movq %rcx, 0x48(%rsp)
movq %rax, 0x40(%rsp)
movl %eax, %ebx
shrl %ebx
leaq (%rbx,%rbx,2), %rax
movq 0x8(%rsp), %rcx
leaq (%rcx,%rax,8), %r14
movl %edi, (%rsp)
movl %edi, %ebp
movq %r8, 0x20(%rsp)
movq %r8, %rax
movq %rbx, 0x10(%rsp)
movq %r14, 0x38(%rsp)
movq (%rsi,%rax,8), %rcx
movq %rcx, 0x18(%rsp)
movl %ecx, %r15d
shrl %r15d
movq %r14, %rdi
movl %ebx, %esi
movl %r15d, %edx
callq 0xa0c99
xorl %esi, %esi
testl %eax, %eax
js 0x1f6444
movq (%r14), %rdx
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
leaq (%rax,%rax,4), %rax
movq 0x18(%rdx,%rax,8), %rcx
testq %rcx, %rcx
js 0x1f6444
leaq (%rdx,%rax,8), %rax
leaq 0xa0118(%rip), %rdx     # 0x296230
movq 0x18(%rdx), %rsi
movl %r15d, %edi
movl (%rsi,%rdi,8), %edx
testl %ecx, %ecx
movl %ebp, 0x4(%rsp)
movq %rdi, 0x50(%rsp)
js 0x1f6141
movl 0x10(%rax), %r14d
movl 0x14(%rax), %r10d
subl %r10d, %edx
movl %edx, %edi
movl %r14d, %edx
jmp 0x1f614f
movl 0x10(%rax), %r14d
movl 0x14(%rax), %r10d
subl %r10d, %edx
movl %r14d, %edi
movl (%rsi,%rbx,8), %r12d
movq %r13, %rbp
movl 0x10(%r13), %r13d
movq (%rax), %rsi
cmpl %esi, %edx
movl %esi, %ebx
cmovll %edx, %ebx
movl 0x8(%rax), %r9d
movl %r12d, %r8d
subl %r9d, %r8d
cmpl %edi, %r8d
movl %edi, %r11d
cmovll %r8d, %r11d
cmpl %r13d, %ebx
jg 0x1f6442
cmpl %r13d, %r11d
jg 0x1f6442
cvtsi2ssq 0x18(%rbp), %xmm0
movl %r9d, %r13d
subl %esi, %r13d
cvtsi2ss %r13, %xmm1
addl %ebx, %r13d
addl %r11d, %r13d
cvtsi2ss %r13, %xmm2
mulss %xmm0, %xmm2
ucomiss %xmm1, %xmm2
ja 0x1f6442
subl %r14d, %r10d
xorps %xmm1, %xmm1
cvtsi2ss %r10, %xmm1
addl %ebx, %r11d
addl %r10d, %r11d
xorps %xmm2, %xmm2
cvtsi2ss %r11, %xmm2
mulss %xmm2, %xmm0
ucomiss %xmm1, %xmm0
ja 0x1f6442
cmpl %edi, %r8d
setl %r8b
setg %bl
cmpl %edx, %esi
setg %r14b
setl %r10b
orb %bl, %r14b
cmpb $0x1, %r14b
jne 0x1f6442
orb %r8b, %r10b
je 0x1f6442
movl 0x8(%rbp), %r8d
cmpl %r8d, %r13d
jl 0x1f6442
cmpl %r8d, %r11d
jl 0x1f6442
addl %r9d, %edi
subl %edi, %r12d
movl %esi, %edi
subl %edx, %edi
cmovlel %r12d, %edi
testl %edi, %edi
js 0x1f6442
xorl %edi, %edi
cmpl %edx, %esi
setg %dl
setle %dil
testl %ecx, %ecx
setns %cl
shrq $0x1f, %rsi
andl $-0x2, %esi
orl %esi, %edi
cmpl 0x48(%rsp), %edi
jne 0x1f6442
movl 0xc(%rax), %eax
xorb %dl, %cl
movzbl %cl, %ecx
leal (%rcx,%rax,2), %eax
xorl 0x18(%rsp), %eax
cmpl $0x1, %eax
jne 0x1f6442
movq 0x50(%rsp), %r12
leaq (%r12,%r12,2), %rax
movq 0x8(%rsp), %rcx
leaq (%rcx,%rax,8), %r14
movq %r14, %rdi
movl %r15d, %esi
movq 0x10(%rsp), %rbx
movl %ebx, %edx
callq 0xa0c99
testl %eax, %eax
js 0x1f6442
movq (%r14), %rdx
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
leaq (%rax,%rax,4), %rax
movq 0x18(%rdx,%rax,8), %rcx
testq %rcx, %rcx
js 0x1f6442
leaq (%rdx,%rax,8), %rax
leaq 0x9ff75(%rip), %rdx     # 0x296230
movq 0x18(%rdx), %rsi
movl (%rsi,%rbx,8), %edx
testl %ecx, %ecx
js 0x1f62d8
movl 0x10(%rax), %r14d
movl 0x14(%rax), %r10d
subl %r10d, %edx
movl %edx, %edi
movl %r14d, %edx
jmp 0x1f62e6
movl 0x10(%rax), %r14d
movl 0x14(%rax), %r10d
subl %r10d, %edx
movl %r14d, %edi
movq %rbp, %r13
movl (%rsi,%r12,8), %r8d
movl 0x10(%rbp), %ebx
movq (%rax), %rsi
cmpl %esi, %edx
movl %esi, %r12d
cmovll %edx, %r12d
movl 0x8(%rax), %r9d
movl %r8d, %r15d
subl %r9d, %r15d
cmpl %edi, %r15d
movl %edi, %r11d
cmovll %r15d, %r11d
cmpl %ebx, %r12d
jg 0x1f6442
cmpl %ebx, %r11d
jg 0x1f6442
cvtsi2ssq 0x18(%r13), %xmm0
movl %r9d, %ebx
subl %esi, %ebx
cvtsi2ss %rbx, %xmm1
addl %r12d, %ebx
addl %r11d, %ebx
cvtsi2ss %rbx, %xmm2
mulss %xmm0, %xmm2
ucomiss %xmm1, %xmm2
ja 0x1f6442
subl %r14d, %r10d
xorps %xmm1, %xmm1
cvtsi2ss %r10, %xmm1
addl %r12d, %r11d
addl %r10d, %r11d
xorps %xmm2, %xmm2
cvtsi2ss %r11, %xmm2
mulss %xmm2, %xmm0
ucomiss %xmm1, %xmm0
ja 0x1f6442
cmpl %edi, %r15d
setl %r10b
setg %r15b
cmpl %edx, %esi
setg %r12b
setl %r14b
orb %r15b, %r12b
cmpb $0x1, %r12b
jne 0x1f6442
orb %r10b, %r14b
je 0x1f6442
movl 0x8(%r13), %r10d
cmpl %r10d, %ebx
jl 0x1f6442
cmpl %r10d, %r11d
jl 0x1f6442
addl %r9d, %edi
subl %edi, %r8d
movl %esi, %edi
subl %edx, %edi
cmovlel %r8d, %edi
testl %edi, %edi
js 0x1f6442
movl 0x18(%rsp), %edi
xorl %r8d, %r8d
cmpl %edx, %esi
setg %dl
setle %r8b
testl %ecx, %ecx
setns %cl
shrq $0x1f, %rsi
andl $-0x2, %esi
orl %esi, %r8d
cmpl %edi, %r8d
jne 0x1f6442
movl 0xc(%rax), %eax
xorb %dl, %cl
movzbl %cl, %ecx
leal (%rcx,%rax,2), %eax
xorl 0x40(%rsp), %eax
cmpl $0x1, %eax
movl $0x0, %esi
movl 0x4(%rsp), %ebp
jne 0x1f6444
movl %ebp, %eax
incl %ebp
movq 0x30(%rsp), %rdx
cmpq %rdx, %rax
movq 0x28(%rsp), %rsi
movq 0x10(%rsp), %rbx
movq 0x38(%rsp), %r14
jb 0x1f60cd
movl (%rsp), %edi
incl %edi
movq 0x20(%rsp), %r8
movq %r8, %rax
cmpq %rdx, %r8
jb 0x1f6089
movl $0x1, %esi
jmp 0x1f6444
xorl %esi, %esi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1f6459
movl $0x1, %esi
movl %esi, %eax
retq