// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
testq %rdx, %rdx
je 0x1eb600
movq %rdx, %rbp
movq %rsi, %rbx
movq %rdi, %r15
movq (%rdi), %rax
movq %rax, 0x28(%rsp)
xorl %eax, %eax
movl $0x2, 0xc(%rsp)
xorl %ecx, %ecx
movq %rdx, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
incl %ecx
movq %rcx, 0x20(%rsp)
cmpq %rbp, %rcx
jae 0x1eb5eb
movq (%rbx,%rax,8), %rax
movl %eax, %ecx
movq %rcx, 0x50(%rsp)
movq %rax, 0x48(%rsp)
shrl %eax
movq %rax, 0x10(%rsp)
leaq (%rax,%rax,2), %rax
movq 0x28(%rsp), %rcx
leaq (%rcx,%rax,8), %r13
movl 0xc(%rsp), %edi
movq 0x20(%rsp), %rax
movq %r13, 0x40(%rsp)
movl %edi, 0x1c(%rsp)
movq (%rbx,%rax,8), %r12
movl %r12d, %r14d
shrl %r14d
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movl %r14d, %edx
callq 0xa04f9
testl %eax, %eax
js 0x1eb61e
movl $0x0, 0x8(%rsp)
movq %r13, %rcx
movq %r15, %r13
movq (%rcx), %rbx
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
leaq (%rax,%rax,4), %r15
cmpq $0x0, 0x18(%rbx,%r15,8)
js 0x1eb608
leaq (%rbx,%r15,8), %rdi
leaq 0x9fdc3(%rip), %rax     # 0x28b230
movq 0x18(%rax), %rax
movq 0x10(%rsp), %rcx
movl (%rax,%rcx,8), %esi
movl %r14d, %ebp
movl (%rax,%rbp,8), %edx
movl 0x8(%r13), %r8d
movl 0x10(%r13), %ecx
xorps %xmm0, %xmm0
cvtsi2ssq 0x18(%r13), %xmm0
leaq 0x70(%rsp), %r9
callq 0x1eb21b
testl %eax, %eax
js 0x1eb608
movq 0x50(%rsp), %rax
cmpl %eax, 0x74(%rsp)
jne 0x1eb608
movl 0x78(%rsp), %eax
xorl %r12d, %eax
cmpl $0x1, %eax
jne 0x1eb608
movq 0x18(%rbx,%r15,8), %rax
movq %rax, %rcx
shrq $0x20, %rcx
movl $0x3fff, %esi           # imm = 0x3FFF
andl %esi, %ecx
movabsq $0x7fffc00000000000, %rdx # imm = 0x7FFFC00000000000
testq %rdx, %rax
cmovnel %esi, %ecx
movl 0x80(%rsp), %eax
movl $0xffffc000, %edx       # imm = 0xFFFFC000
andl %edx, %eax
orl %ecx, %eax
movw %ax, 0x80(%rsp)
leaq (,%rbp,2), %rax
addq %rbp, %rax
movq 0x28(%rsp), %rcx
leaq (%rcx,%rax,8), %rbx
movq %rbx, %rdi
movl %r14d, %esi
movq 0x10(%rsp), %rdx
callq 0xa04f9
testl %eax, %eax
js 0x1eb608
movq (%rbx), %rbx
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
leaq (%rax,%rax,4), %r14
cmpq $0x0, 0x18(%rbx,%r14,8)
js 0x1eb608
leaq (%rbx,%r14,8), %rdi
leaq 0x9fce5(%rip), %rax     # 0x28b230
movq 0x18(%rax), %rax
movl (%rax,%rbp,8), %esi
movq 0x10(%rsp), %rcx
movl (%rax,%rcx,8), %edx
movq %r13, %r15
movl 0x8(%r13), %r8d
movl 0x10(%r13), %ecx
xorps %xmm0, %xmm0
cvtsi2ssq 0x18(%r13), %xmm0
leaq 0x58(%rsp), %r9
callq 0x1eb21b
testl %eax, %eax
js 0x1eb608
movl %r12d, %eax
cmpl %eax, 0x5c(%rsp)
jne 0x1eb608
movl 0x60(%rsp), %eax
xorl 0x48(%rsp), %eax
cmpl $0x1, %eax
movl 0x1c(%rsp), %edi
jne 0x1eb608
movq 0x18(%rbx,%r14,8), %rax
movq %rax, %rcx
shrq $0x20, %rcx
movl $0x3fff, %esi           # imm = 0x3FFF
andl %esi, %ecx
movabsq $0x7fffc00000000000, %rdx # imm = 0x7FFFC00000000000
testq %rdx, %rax
cmovnel %esi, %ecx
movl 0x68(%rsp), %eax
movl $0xffffc000, %edx       # imm = 0xFFFFC000
andl %edx, %eax
orl %ecx, %eax
movw %ax, 0x68(%rsp)
movl %edi, %eax
incl %edi
movq 0x38(%rsp), %rbp
cmpq %rbp, %rax
movq 0x30(%rsp), %rbx
movq 0x40(%rsp), %r13
jb 0x1eb416
incl 0xc(%rsp)
movq 0x20(%rsp), %rcx
movq %rcx, %rax
cmpq %rbp, %rcx
jb 0x1eb3d4
movl $0x1, 0x8(%rsp)
movl 0x8(%rsp), %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x0, 0x8(%rsp)
jmp 0x1eb608