// File: chhylp123[P]hifiasm/gfa_ut.cpp
// Function: poa_cns_chain(poa_g_t*, all_ul_t*, ma_ug_t*, ul_str_t*, ul_chain_t*, long, long, integer_t*, unsigned int*)
void poa_cns_chain(poa_g_t *g, all_ul_t *ul_idx, ma_ug_t *ug, ul_str_t *str, ul_chain_t *idx, int64_t idx_n, int64_t qid, integer_t *buf, uint32_t *is_circle)
{
    (*is_circle) = 0;
    int64_t k, tid, is_rev; 
    reset_poa_g_t(g); 

    append_unmatch_integer_seq(g, ug, ul_idx->a[qid].bb.a, &(str[qid]), 0, str[qid].cn, 0, qid);
    clean_poa_g_t(g); (*is_circle) = 1 - topo_srt_gen(g, qid, ug);
    if((*is_circle)) return;

    for (k = 0; k < idx_n; k++) {
        tid = idx[k].v>>1; is_rev = idx[k].v&1;
        // fprintf(stderr, "\n[M::%s::] k::%ld, tid::%ld, is_rev::%ld\n", __func__, k, tid, is_rev);
        // print_integer_seq(ug, str, tid, 1);
        poa_chain_0(g, ug, ul_idx->a[tid].bb.a, &(str[tid]), idx[k].t_sidx, idx[k].t_eidx, is_rev, buf, tid, qid, is_circle);
        if((*is_circle)) return;
        // print_integer_g(g, ug, 1);
    }

    gen_cns_by_poa(g);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x70, %rsp
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movq %r9, -0x40(%rbp)
movq 0x20(%rbp), %rax
movl $0x0, (%rax)
movq -0x18(%rbp), %rdi
callq 0x32ec80
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
imulq $0x58, 0x10(%rbp), %rcx
addq %rcx, %rax
movq 0x30(%rax), %rdx
movq -0x30(%rbp), %rcx
movq 0x10(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rcx
movq -0x30(%rbp), %rax
movq 0x10(%rbp), %r8
shlq $0x5, %r8
addq %r8, %rax
movl 0x18(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %r9d
movq 0x10(%rbp), %rax
xorl %r8d, %r8d
movq $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x32f010
movq -0x18(%rbp), %rdi
callq 0x32ece0
movq -0x18(%rbp), %rdi
movq 0x10(%rbp), %rax
movl %eax, %esi
movq -0x28(%rbp), %rdx
callq 0x331070
movl $0x1, %ecx
subl %eax, %ecx
movq 0x20(%rbp), %rax
movl %ecx, (%rax)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x3342a9
jmp 0x334395
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x40(%rbp), %rax
jge 0x33438c
movq -0x38(%rbp), %rax
imulq $0x28, -0x48(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
shrl %eax
movl %eax, %eax
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rax
imulq $0x28, -0x48(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
andl $0x1, %eax
movl %eax, %eax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
imulq $0x58, -0x50(%rbp), %rcx
addq %rcx, %rax
movq 0x30(%rax), %rdx
movq -0x30(%rbp), %rcx
movq -0x50(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rcx
movq -0x38(%rbp), %rax
imulq $0x28, -0x48(%rbp), %r8
addq %r8, %rax
movl 0x20(%rax), %eax
movl %eax, %r8d
movq -0x38(%rbp), %rax
imulq $0x28, -0x48(%rbp), %r9
addq %r9, %rax
movl 0x24(%rax), %eax
movl %eax, %r9d
movq -0x58(%rbp), %r14
movq 0x18(%rbp), %rbx
movq -0x50(%rbp), %r11
movq 0x10(%rbp), %r10
movq 0x20(%rbp), %rax
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x333060
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x334379
jmp 0x334395
jmp 0x33437b
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x3342b1
movq -0x18(%rbp), %rdi
callq 0x333940
addq $0x70, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop