// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: push_scaf_bases(unsigned char*, unsigned long**, All_reads*, all_ul_t*, usc_t*, long, long, long, UC_Read*, unsigned long*, ma_ug_t*)
int64_t push_scaf_bases(uint8_t *des, uint64_t** N_site, All_reads* rdb, all_ul_t *x, usc_t *z, int64_t min_arc_len, int64_t scaf_len, int64_t nlen, UC_Read *tu, 
uint64_t *rmap, ma_ug_t *raw_g)
{   
    int64_t nlen0, ff, Nocc, i; char *da = NULL;
    ff = reset_scaf_node_uinfo_srt_t(z, min_arc_len, scaf_len, &nlen0); assert(nlen0 == nlen);
    if(ff == 1) {///has an overlap longer than min_arc_len between z->raw_sid and z->raw_eid
        memset(des, 0, sizeof((*(des)))*(nlen/4+1));
        return ff;
    }
    uint32_t uv, uw, sv, sw; int64_t s, e, ul;
    uv = z->raw_sid; uw = z->raw_eid;

    sv = (uv&1?((raw_g->u.a[uv>>1].a[0]>>32)^1):(raw_g->u.a[uv>>1].a[raw_g->u.a[uv>>1].n-1]>>32));
    sw = (uw&1?((raw_g->u.a[uw>>1].a[raw_g->u.a[uw>>1].n-1]>>32)^1):(raw_g->u.a[uw>>1].a[0]>>32));
    resize_UC_Read(tu, nlen); da = tu->seq;
    assert((Get_READ_LENGTH((*rdb), (sv>>1))) > ((uint32_t)min_arc_len));
    assert((Get_READ_LENGTH((*rdb), (sw>>1))) > ((uint32_t)min_arc_len));
    ///need introduce some UL bases; 
    ///or the overlap length between sv and sw is shorter than min_arc_len
    if(ff == 2) {
        s = z->raw_sof; e = z->raw_eof; ul = e - s;
        assert(ul>=(-min_arc_len));
        // assert((Get_READ_LENGTH((*rdb), (sv>>1))) > ul);
        // assert((Get_READ_LENGTH((*rdb), (sw>>1))) > ul);
        get_end_hifi(da, sv, rdb, min_arc_len, 1);
        get_end_hifi(da+min_arc_len+ul, sw, rdb, min_arc_len, 0);    
        if(ul > 0) {///need UL
            // fprintf(stderr, "[M::%s] ulid::%u(%c), s::%ld, e::%ld, nlen::%ld, min_arc_len::%ld\n", __func__, 
            // z->ulid>>1, "+-"[z->ulid&1], s, e, nlen, min_arc_len);
            get_ul_subregion(x, da+min_arc_len, z->ulid>>1, z->ulid&1, s, e, 1);
        }
    } else {///no UL found; ff = 0
        get_end_hifi(da, sv, rdb, min_arc_len, 1);
        memset(da+min_arc_len, 'A', scaf_len);
        get_end_hifi(da+min_arc_len+scaf_len, sw, rdb, min_arc_len, 0);        
    }
    for (i = Nocc = 0; i < nlen; i++) {
        if(seq_nt6_table[(uint8_t)da[i]] >= 4) Nocc++;
    }
    ha_compress_base(des, da, nlen, N_site, Nocc);
    return ff;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, %r13
movq %r8, %r15
movq %rcx, 0x48(%rsp)
movq %rdx, 0x10(%rsp)
movq %rsi, %rbp
movq %rdi, %r12
movq 0x98(%rsp), %rbx
movq 0x90(%rsp), %rdx
leaq 0x50(%rsp), %r14
movq %r8, %rdi
movq %r9, %rsi
movq %r14, %rcx
callq 0x1d223d
movq %rbx, %r8
cmpq %rbx, (%r14)
jne 0x1d272c
movq %rax, %rbx
cmpl $0x1, %ebx
jne 0x1d2525
pushq $0x4
popq %rcx
movq %r8, %rax
cqto
idivq %rcx
leaq 0x1(%rax), %rdx
movq %r12, %rdi
xorl %esi, %esi
callq 0x20e0
jmp 0x1d271a
movq %r12, 0x40(%rsp)
movq 0xb0(%rsp), %rax
movl 0x8(%r15), %esi
movl 0xc(%r15), %ecx
movl %esi, %edx
shrl %edx
movq 0x10(%rax), %rax
imulq $0x28, %rdx, %rdx
testb $0x1, %sil
jne 0x1d255e
movq 0x18(%rax,%rdx), %rsi
movl 0x10(%rax,%rdx), %edx
decl %edx
movl 0x4(%rsi,%rdx,8), %r12d
jmp 0x1d256b
movq 0x18(%rax,%rdx), %rdx
movl 0x4(%rdx), %r12d
xorq $0x1, %r12
movq %rbp, 0x38(%rsp)
movq 0xa0(%rsp), %r14
movl %ecx, %edx
shrl %edx
testb $0x1, %cl
jne 0x1d258f
imulq $0x28, %rdx, %rcx
movq 0x18(%rax,%rcx), %rax
movl 0x4(%rax), %ebp
jmp 0x1d25a6
imulq $0x28, %rdx, %rcx
movq 0x18(%rax,%rcx), %rdx
movl 0x10(%rax,%rcx), %eax
decl %eax
movl 0x4(%rdx,%rax,8), %ebp
xorq $0x1, %rbp
movq %r14, %rdi
movq %r8, %rsi
callq 0x562fa
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movl %r12d, %edx
shrl %edx
movl %r13d, %ecx
cmpq %rcx, (%rax,%rdx,8)
jbe 0x1d274b
movl %ebp, %edx
shrl %edx
cmpq %rcx, (%rax,%rdx,8)
jbe 0x1d276a
movq (%r14), %r14
cmpl $0x2, %ebx
movq %rbp, 0x18(%rsp)
jne 0x1d2680
movq %rbx, 0x30(%rsp)
movl 0x10(%r15), %eax
movl 0x14(%r15), %ebx
movq %rbx, 0x20(%rsp)
movq %rax, 0x28(%rsp)
subq %rax, %rbx
movq %r13, %rax
negq %rax
cmpq %rax, %rbx
jl 0x1d2789
pushq $0x1
popq %r8
movq %r14, %rdi
movl %r12d, %esi
movq 0x10(%rsp), %rbp
movq %rbp, %rdx
movl %r13d, %ecx
callq 0x1d2270
movq %r13, %r12
addq %r14, %r12
leaq (%r12,%rbx), %rdi
movq 0x18(%rsp), %rsi
movq %rbp, %rdx
movl %r13d, %ecx
xorl %r8d, %r8d
callq 0x1d2270
testq %rbx, %rbx
movq 0x30(%rsp), %rbx
jle 0x1d26cf
movl 0x4(%r15), %ecx
movl %ecx, %edx
shrl %edx
andl $0x1, %ecx
movl $0x1, (%rsp)
movq 0x48(%rsp), %rdi
movq %r12, %rsi
movq 0x28(%rsp), %r8
movq 0x20(%rsp), %r9
callq 0x1d22bd
jmp 0x1d26cf
pushq $0x1
popq %r8
movq %r14, %rdi
movl %r12d, %esi
movq 0x10(%rsp), %r12
movq %r12, %rdx
movl %r13d, %ecx
callq 0x1d2270
movq %r13, %r15
addq %r14, %r15
pushq $0x41
popq %rsi
movq %r15, %rdi
movq 0x90(%rsp), %rbp
movq %rbp, %rdx
callq 0x20e0
addq %rbp, %r15
movq %r15, %rdi
movq 0x18(%rsp), %rsi
movq %r12, %rdx
movl %r13d, %ecx
xorl %r8d, %r8d
callq 0x1d2270
xorl %eax, %eax
movq 0x98(%rsp), %rdx
testq %rdx, %rdx
movl $0x0, %r9d
cmovgq %rdx, %r9
leaq 0x80f43(%rip), %r10     # 0x253630
xorl %r8d, %r8d
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rcx
cmpq %rax, %r9
je 0x1d2712
movzbl (%r14,%rax), %esi
cmpb $0x4, (%r10,%rsi)
sbbq $-0x1, %r8
incq %rax
jmp 0x1d26fa
movq %r14, %rsi
callq 0x733a
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x29159(%rip), %rdi     # 0x1fb88c
leaq 0x24d9f(%rip), %rsi     # 0x1f74d9
leaq 0x29159(%rip), %rcx     # 0x1fb89a
movl $0x3920, %edx           # imm = 0x3920
callq 0x2110
leaq 0x291d7(%rip), %rdi     # 0x1fb929
leaq 0x24d80(%rip), %rsi     # 0x1f74d9
leaq 0x2913a(%rip), %rcx     # 0x1fb89a
movl $0x392b, %edx           # imm = 0x392B
callq 0x2110
leaq 0x291f5(%rip), %rdi     # 0x1fb966
leaq 0x24d61(%rip), %rsi     # 0x1f74d9
leaq 0x2911b(%rip), %rcx     # 0x1fb89a
movl $0x392c, %edx           # imm = 0x392C
callq 0x2110
leaq 0x29213(%rip), %rdi     # 0x1fb9a3
leaq 0x24d42(%rip), %rsi     # 0x1f74d9
leaq 0x290fc(%rip), %rcx     # 0x1fb89a
movl $0x3931, %edx           # imm = 0x3931
callq 0x2110