// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: append_integer_seq_frag(ma_ug_t*, uc_block_t*, poa_g_t*, long, long, unsigned long*, long, unsigned long, long, long)
void append_integer_seq_frag(ma_ug_t *ug, uc_block_t *raw, poa_g_t *g, int64_t g_beg, int64_t g_end, uint64_t *str, int64_t str_occ, uint64_t is_rev, int64_t str_id, int64_t str_off)
{
    // if(str_occ <= 0) return;
    uint32_t nid; 
    // if((g_beg >= 0 || g_end >= 0) && str_occ < 2) return;
    if(g_beg < 0 && g_end < 0) {//add new nodes
        insert_poa_nodes_0(ug, raw, g, str, str_occ, is_rev, str_id, str_off);
        return;
    }

    if(g_beg < 0 && g_end >= 0) {///add nodes to the left end
        assert(str_occ >= 1);
        update_poa_nid_occ(ug, raw, g, g_end, str, (is_rev?(0):(str_occ-1)), is_rev);
        if(str_occ < 2) return;
        insert_poa_nodes_0(ug, raw, g, (is_rev?(str+1):(str)), str_occ-1, is_rev, str_id, str_off+(is_rev?(1):(0)));
        
        push_poa_arch_0(g, g->seq.n-1, g_end, str_id, str_off + (is_rev?(1):(str_occ-2)), 
                                                                str_off + (is_rev?(0):(str_occ-1)));
        return;
    }

    if(g_beg >= 0 && g_end < 0) {///add nodes to the right end
        assert(str_occ >= 1);
        update_poa_nid_occ(ug, raw, g, g_beg, str, (is_rev?(str_occ-1):(0)), is_rev);
        if(str_occ < 2) return;
        nid = g->seq.n;///backup
        insert_poa_nodes_0(ug, raw, g, (is_rev?(str):(str+1)), str_occ-1, is_rev, str_id, str_off+(is_rev?(0):(1)));
        push_poa_arch_0(g, g_beg, nid, str_id, str_off + (is_rev?(str_occ-1):(0)), 
                                                        str_off + (is_rev?(str_occ-2):(1)));
        return;
    }

    if(g_beg >= 0 && g_end >= 0) {///add nodes to the middle
        assert(str_occ >= 2);
        update_poa_nid_occ(ug, raw, g, g_beg, str, (is_rev?(str_occ-1):(0)), is_rev);
        update_poa_nid_occ(ug, raw, g, g_end, str, (is_rev?(0):(str_occ-1)), is_rev);
        if(str_occ > 2) {///insert new nodes
            nid = g->seq.n;///backup
            insert_poa_nodes_0(ug, raw, g, str+1, str_occ-2, is_rev, str_id, str_off+1);
            push_poa_arch_0(g, g_beg, nid, str_id, str_off + (is_rev?(str_occ-1):(0)),
                                                            str_off + (is_rev?(str_occ-2):(1))); 
            push_poa_arch_0(g, g->seq.n-1, g_end, str_id, str_off + (is_rev?(1):(str_occ-2)),
                                                            str_off + (is_rev?(0):(str_occ-1)));
        } else {
            ///add an edge between g_beg and g_end
            update_poa_arch_0(g, g_beg, g_end, str_id, str_off + (is_rev?(str_occ-1):(0)), 
                                                        str_off + (is_rev?(0):(str_occ-1)));
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, %rbx
movq 0x98(%rsp), %r14
movq 0x90(%rsp), %rax
movq 0x88(%rsp), %r13
movq 0x80(%rsp), %r15
testq %rcx, %r8
js 0x1b6eb5
movq %r8, %r12
movq %rcx, %rbp
movq %rax, 0x18(%rsp)
testq %rcx, %rcx
setns %al
testq %r8, %r8
sets %cl
orb %al, %cl
movq %r14, 0x38(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdi, 0x20(%rsp)
jne 0x1b6ecf
testq %r15, %r15
jle 0x1b70e3
leaq -0x1(%r15), %rax
xorl %ebp, %ebp
testq %r13, %r13
movq %rax, 0x8(%rsp)
cmoveq %rax, %rbp
subq $0x8, %rsp
movq %rdx, %r14
movq %r12, %rcx
movq %rbx, %r8
movq %rbp, %r9
pushq %r13
callq 0x1b6796
popq %rax
popq %rcx
cmpq $0x1, %r15
je 0x1b703a
addq $-0x2, %r15
xorl %eax, %eax
testq %r13, %r13
setne %al
leaq (%rbx,%rax,8), %rcx
pushq $0x1
popq %rbx
cmoveq %r15, %rbx
movq 0x38(%rsp), %r15
addq %r15, %rax
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq %r14, %rdx
movq 0x8(%rsp), %r8
movq %r13, %r9
pushq %rax
movq 0x20(%rsp), %r13
pushq %r13
callq 0x1b6825
popq %rax
popq %rcx
movl (%r14), %esi
decl %esi
addq %r15, %rbx
addq %r15, %rbp
movq %r14, %rdi
movl %r12d, %edx
movq %r13, %rcx
movq %rbx, %r8
movq %rbp, %r9
jmp 0x1b70d0
movq %rbx, %rcx
movq %r15, %r8
movq %r13, %r9
pushq %r14
pushq %rax
callq 0x1b6825
addq $0x58, %rsp
jmp 0x1b703e
testq %r12, %r12
setns %al
testq %rbp, %rbp
sets %cl
orb %al, %cl
jne 0x1b6f86
testq %r15, %r15
jle 0x1b7102
leaq -0x1(%r15), %r12
testq %r13, %r13
movq %r12, 0x8(%rsp)
cmoveq %r13, %r12
subq $0x8, %rsp
movq %rdx, %r14
movq %rbp, %rcx
movq %rbx, %r8
movq %r12, %r9
pushq %r13
callq 0x1b6796
popq %rax
popq %rcx
cmpq $0x1, %r15
je 0x1b703a
addq $-0x2, %r15
xorl %eax, %eax
testq %r13, %r13
sete %al
movl (%r14), %ecx
movl %ecx, 0x10(%rsp)
leaq (%rbx,%rax,8), %rcx
pushq $0x1
popq %rbx
cmovneq %r15, %rbx
movq 0x38(%rsp), %r15
addq %r15, %rax
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq %r14, %rdx
movq 0x8(%rsp), %r8
movq %r13, %r9
pushq %rax
movq 0x20(%rsp), %r13
pushq %r13
callq 0x1b6825
popq %rax
popq %rcx
addq %r15, %r12
addq %r15, %rbx
movq %r14, %rdi
movl %ebp, %esi
movl 0x10(%rsp), %edx
movq %r13, %rcx
movq %r12, %r8
movq %rbx, %r9
jmp 0x1b70d0
movq %r12, %rax
orq %rbp, %rax
js 0x1b703a
cmpq $0x1, %r15
jle 0x1b7121
movq %rdx, %r14
leaq -0x1(%r15), %rax
subq $0x8, %rsp
xorl %edx, %edx
testq %r13, %r13
movq %rax, %r9
cmoveq %r13, %r9
cmoveq %rax, %rdx
movq %rdx, 0x10(%rsp)
movq %r14, %rdx
movq %rbp, %rcx
movq %rbx, %r8
movq %r9, 0x18(%rsp)
pushq %r13
callq 0x1b6796
popq %rax
popq %rcx
subq $0x8, %rsp
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq %r14, 0x38(%rsp)
movq %r14, %rdx
movq %r12, %rcx
movq %rbx, %r8
movq 0x10(%rsp), %r9
pushq %r13
callq 0x1b6796
popq %rax
popq %rcx
cmpq $0x2, %r15
movq 0x38(%rsp), %r14
jne 0x1b7049
movq 0x10(%rsp), %r8
addq %r14, %r8
movq 0x8(%rsp), %r9
addq %r14, %r9
movq 0x30(%rsp), %rdi
movl %ebp, %esi
movl %r12d, %edx
movq 0x18(%rsp), %rcx
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1b6c4b
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x30(%rsp), %rdx
movl (%rdx), %eax
movl %eax, 0x44(%rsp)
addq $0x8, %rbx
addq $-0x2, %r15
leaq 0x1(%r14), %rax
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq %rbx, %rcx
movq %r15, %r8
movq %r13, %r9
pushq %rax
movq 0x20(%rsp), %rbx
pushq %rbx
callq 0x1b6825
popq %rax
popq %rcx
movq 0x10(%rsp), %r8
addq %r14, %r8
testq %r13, %r13
pushq $0x1
popq %rax
movq %r15, %r9
cmoveq %rax, %r9
cmovneq %rax, %r15
addq %r14, %r9
movq 0x30(%rsp), %r13
movq %r13, %rdi
movl %ebp, %esi
movl 0x44(%rsp), %edx
movq %rbx, %rcx
callq 0x1b6aca
movl (%r13), %esi
decl %esi
addq %r14, %r15
movq 0x8(%rsp), %r9
addq %r14, %r9
movq %r13, %rdi
movl %r12d, %edx
movq %rbx, %rcx
movq %r15, %r8
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1b6aca
leaq 0x41bf5(%rip), %rdi     # 0x1f8cdf
leaq 0x403e8(%rip), %rsi     # 0x1f74d9
leaq 0x41bf4(%rip), %rcx     # 0x1f8cec
movl $0x15c7, %edx           # imm = 0x15C7
callq 0x2110
leaq 0x41bd6(%rip), %rdi     # 0x1f8cdf
leaq 0x403c9(%rip), %rsi     # 0x1f74d9
leaq 0x41bd5(%rip), %rcx     # 0x1f8cec
movl $0x15d2, %edx           # imm = 0x15D2
callq 0x2110
leaq 0x41c48(%rip), %rdi     # 0x1f8d70
leaq 0x403aa(%rip), %rsi     # 0x1f74d9
leaq 0x41bb6(%rip), %rcx     # 0x1f8cec
movl $0x15dd, %edx           # imm = 0x15DD
callq 0x2110