// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/hic.cpp
// Function: prt_bubble_gfa_adv(_IO_FILE*, bubble_type*, char const*, char const*, char const*)
void prt_bubble_gfa_adv(FILE *fp, bubble_type *bub, const char* utg_pre, const char* bub_pre, const char* chain_pre)
{
    uint32_t i, k, m, *a, n, beg, sink, x; ma_utg_t *p; uint64_t occ;
    ma_ug_t *b_ug = bub->b_ug; char name[32], bname[32]; uint8_t *f; CALLOC(f, bub->ug->u.n);
    for (i = 0; i < b_ug->u.n; i++) {
        p = &b_ug->u.a[i];
        if(p->n == 0) continue;
        for (k = occ = 0; k < p->n; k++){
            x = p->a[k]>>33;
            get_bubbles(bub, x, &beg, &sink, &a, &n, NULL);

            for (m = 0; m < n; m++) {
                occ += bub->ug->u.a[a[m]>>1].n; f[a[m]>>1] = 1;
            }
            if(beg != (uint32_t)-1 && f[beg>>1] == 0) {
                occ += bub->ug->u.a[beg>>1].n; f[beg>>1] = 1;
            }
            if(sink != (uint32_t)-1 && f[sink>>1] == 0) {
                occ += bub->ug->u.a[sink>>1].n; f[sink>>1] = 1;
            }
        }

        sprintf(name, "%s%.6d%c", chain_pre, i + 1, "lc"[p->circ]);
        fprintf(fp, "S\t%s\t*\tLN:i:%lu\n", name, occ);
        for (k = 0; k < p->n; k++) {
            x = p->a[k]>>33;
            sprintf(bname, "%s%.6d", bub_pre, x + 1);
            fprintf(fp, "B\t%s\t%c\tcid:i:%s\tsm:%c\n", bname, "+-"[(p->a[k]>>32)&1], name, "01"[x<bub->f_bub]);

            get_bubbles(bub, x, &beg, &sink, &a, &n, NULL);
            if(beg != (uint32_t)-1) {
                fprintf(fp, "U\t%s%.6d%c\t%c\tcid:i:%s\tbid:b:%s\thom:%c\n", 
                utg_pre, (beg>>1)+1, "lc"[bub->ug->u.a[(beg>>1)].circ], "+-"[beg&1], name, bname, "10"[IF_HOM((beg>>1), *bub)]);
            }

            if(sink != (uint32_t)-1) {
                fprintf(fp, "U\t%s%.6d%c\t%c\tcid:i:%s\tbid:s:%s\thom:%c\n", 
                utg_pre, (sink>>1)+1, "lc"[bub->ug->u.a[(sink>>1)].circ], "+-"[sink&1], name, bname, "10"[IF_HOM((sink>>1), *bub)]);
            }
            for (m = 0; m < n; m++) {
                occ += bub->ug->u.a[a[m]>>1].n;
                fprintf(fp, "U\t%s%.6d%c\t%c\tcid:i:%s\tbid:c:%s\thom:%c\n", 
                utg_pre, (a[m]>>1)+1, "lc"[bub->ug->u.a[(a[m]>>1)].circ], "+-"[a[m]&1], name, bname, "10"[IF_HOM((a[m]>>1), *bub)]);
            }
        }
    }

    asg_arc_t* au = NULL;
    uint32_t nu, u, v, j;
    for (i = 0; i < b_ug->u.n; ++i) {
        if(b_ug->u.a[i].m == 0) continue;
        if(b_ug->u.a[i].circ)
        {
            fprintf(fp, "L\t%s%.6dc\t+\t%s%.6dc\t+\t%dM\tL1:i:%d\n", 
            chain_pre, i+1, chain_pre, i+1, 0, 0);
            fprintf(fp, "L\t%s%.6dc\t-\t%s%.6dc\t-\t%dM\tL1:i:%d\n", 
            chain_pre, i+1, chain_pre, i+1, 0, 0);
        } 
        u = i<<1;
        au = asg_arc_a(b_ug->g, u);
        nu = asg_arc_n(b_ug->g, u);
        for (j = 0; j < nu; j++)
        {
            if(au[j].del) continue;
            v = au[j].v;
            fprintf(fp, "L\t%s%.6d%c\t%c\t%s%.6d%c\t%c\t%dM\tL1:i:%d\n", 
            chain_pre, (u>>1)+1, "lc"[b_ug->u.a[u>>1].circ], "+-"[u&1],
            chain_pre, (v>>1)+1, "lc"[b_ug->u.a[v>>1].circ], "+-"[v&1], 0, 0);
        }


        u = (i<<1) + 1;
        au = asg_arc_a(b_ug->g, u);
        nu = asg_arc_n(b_ug->g, u);
        for (j = 0; j < nu; j++)
        {
            if(au[j].del) continue;
            v = au[j].v;
            fprintf(fp, "L\t%s%.6d%c\t%c\t%s%.6d%c\t%c\t%dM\tL1:i:%d\n", 
            chain_pre, (u>>1)+1, "lc"[b_ug->u.a[u>>1].circ], "+-"[u&1],
            chain_pre, (v>>1)+1, "lc"[b_ug->u.a[v>>1].circ], "+-"[v&1], 0, 0);
        }
    }
    
    for (i = 0; i < bub->ug->u.n; i++) {
        if(f[i]) continue;
        fprintf(fp, "U\t%s%.6d%c\t+\tcid:i:*\tbid:c:*\thom:%c\n", 
                utg_pre, i+1, "lc"[bub->ug->u.a[i].circ], "10"[IF_HOM(i, *bub)]);
    }
    free(f);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %r8, 0x28(%rsp)
movq %rcx, 0x58(%rsp)
movq %rdx, 0x38(%rsp)
movq %rsi, %r13
movq %rdi, 0x8(%rsp)
movq 0xc0(%rsi), %r15
movq 0x10(%rsi), %rax
movq (%rax), %rdi
movl $0x1, %esi
callq 0x2120
movq %rax, %r14
cmpq $0x0, (%r15)
movq %r15, 0x30(%rsp)
movq %r13, 0x10(%rsp)
je 0x15b0ac
leaq 0x80(%rsp), %r12
xorl %eax, %eax
movq $0x0, 0x40(%rsp)
movq %r14, 0x50(%rsp)
movq 0x10(%r15), %rcx
leaq (%rax,%rax,4), %rdx
movl 0x10(%rcx,%rdx,8), %eax
testq %rax, %rax
je 0x15b08f
leaq (%rcx,%rdx,8), %rcx
movq %rcx, (%rsp)
movq 0x18(%rcx), %rcx
movq 0x28(%r13), %rdx
movq 0x40(%r13), %rsi
xorl %edi, %edi
xorl %ebp, %ebp
movq (%rcx,%rdi,8), %r9
shrq $0x21, %r9
movl (%rsi,%r9,4), %r8d
movl 0x4(%rsi,%r9,4), %r11d
subl %r8d, %r11d
addl $-0x2, %r11d
je 0x15ace8
leaq (%rdx,%r8,4), %r9
movq 0x10(%r13), %r10
movq 0x10(%r10), %r10
movl %r11d, %r11d
xorl %ebx, %ebx
movl 0x8(%r9,%rbx,4), %r15d
shrl %r15d
leaq (%r15,%r15,4), %r13
movl 0x10(%r10,%r13,8), %r13d
addq %r13, %rbp
movb $0x1, (%r14,%r15)
incq %rbx
cmpq %rbx, %r11
jne 0x15acc7
movl (%rdx,%r8,4), %r9d
cmpl $-0x1, %r9d
je 0x15ad1c
shrl %r9d
cmpb $0x0, (%r14,%r9)
movq 0x10(%rsp), %r13
jne 0x15ad21
movq 0x10(%r13), %r10
movq 0x10(%r10), %r10
leaq (%r9,%r9,4), %r11
movl 0x10(%r10,%r11,8), %r10d
addq %r10, %rbp
movb $0x1, (%r14,%r9)
jmp 0x15ad21
movq 0x10(%rsp), %r13
incl %r8d
movl (%rdx,%r8,4), %r8d
cmpl $-0x1, %r8d
je 0x15ad51
shrl %r8d
cmpb $0x0, (%r14,%r8)
jne 0x15ad51
movq 0x10(%r13), %r9
movq 0x10(%r9), %r9
leaq (%r8,%r8,4), %r10
movl 0x10(%r9,%r10,8), %r9d
addq %r9, %rbp
movb $0x1, (%r14,%r8)
incq %rdi
cmpq %rax, %rdi
jne 0x15ac9c
movq 0x40(%rsp), %rax
leal 0x1(%rax), %ecx
movq (%rsp), %rbx
movl (%rbx), %eax
shrl $0x1f, %eax
leaq 0xcd8b6(%rip), %rdx     # 0x22862b
movsbl (%rax,%rdx), %r8d
movq %r12, %rdi
leaq 0xcf466(%rip), %rsi     # 0x22a1ea
movq 0x28(%rsp), %rdx
xorl %eax, %eax
callq 0x2050
movq 0x8(%rsp), %rdi
leaq 0xd58de(%rip), %rsi     # 0x23067a
movq %r12, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x22b0
cmpl $0x0, 0x10(%rbx)
leaq 0x60(%rsp), %rbp
je 0x15b08f
xorl %edx, %edx
movq 0x18(%rbx), %rax
movq (%rax,%rdx,8), %rbx
shrq $0x21, %rbx
leal 0x1(%rbx), %ecx
movq %rbp, %r15
movq %rbp, %rdi
leaq 0xd58b5(%rip), %rsi     # 0x23068b
movq %rdx, %rbp
movq 0x58(%rsp), %rdx
xorl %eax, %eax
callq 0x2050
movq (%rsp), %rax
movq 0x18(%rax), %rax
movq %rbp, 0x48(%rsp)
btq $0x20, (%rax,%rbp,8)
leaq 0xcb3c4(%rip), %rax     # 0x2261c3
adcq $0x0, %rax
movsbl (%rax), %ecx
cmpq 0x80(%r13), %rbx
leaq 0xd496b(%rip), %rax     # 0x22f77f
adcq $0x0, %rax
movsbl (%rax), %r9d
movq 0x8(%rsp), %rdi
leaq 0xd586a(%rip), %rsi     # 0x230692
movq %r15, %rdx
movq %r12, %rbp
movq %r12, %r8
xorl %eax, %eax
callq 0x22b0
movq 0x28(%r13), %rdx
movq 0x40(%r13), %rax
movl (%rax,%rbx,4), %ecx
movl 0x4(%rax,%rbx,4), %r15d
movl (%rdx,%rcx,4), %eax
movq %rcx, 0x20(%rsp)
incl %ecx
movq %rdx, 0x18(%rsp)
movl (%rdx,%rcx,4), %ebx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
je 0x15aee8
movl %eax, %ecx
shrl %ecx
movq (%r13), %rdx
leaq (%rcx,%rcx,4), %rsi
movl (%rdx,%rcx,4), %edx
incl %ecx
movq 0x10(%r13), %rdi
movq 0x10(%rdi), %rdi
movl (%rdi,%rsi,8), %esi
shrl $0x1f, %esi
leaq 0xcd79d(%rip), %rdi     # 0x22862b
movsbl (%rsi,%rdi), %r8d
andl $0x1, %eax
leaq 0xcb326(%rip), %rsi     # 0x2261c3
movsbl (%rax,%rsi), %r9d
movq 0x80(%r13), %rax
incq %rax
cmpq %rdx, %rax
leaq 0xd581c(%rip), %rax     # 0x2306d2
adcq $0x0, %rax
movsbl (%rax), %r10d
subq $0x8, %rsp
movq 0x10(%rsp), %rdi
leaq 0xd57dc(%rip), %rsi     # 0x2306aa
movq 0x40(%rsp), %rdx
xorl %eax, %eax
pushq %r10
leaq 0x70(%rsp), %r10
pushq %r10
pushq %rbp
callq 0x22b0
addq $0x20, %rsp
cmpl $-0x1, %ebx
movq %rbp, %r12
movq 0x38(%rsp), %r14
movq 0x8(%rsp), %r13
je 0x15af81
movl %ebx, %eax
shrl %eax
movq 0x10(%rsp), %rdi
movq (%rdi), %rcx
leaq (%rax,%rax,4), %rdx
movl (%rcx,%rax,4), %esi
movl %eax, %ecx
incl %ecx
movq 0x10(%rdi), %rax
movq 0x10(%rax), %rax
movl (%rax,%rdx,8), %eax
shrl $0x1f, %eax
leaq 0xcd701(%rip), %rdx     # 0x22862b
movsbl (%rax,%rdx), %r8d
andl $0x1, %ebx
leaq 0xcb28a(%rip), %rax     # 0x2261c3
movsbl (%rbx,%rax), %r9d
movq 0x80(%rdi), %rax
incq %rax
cmpq %rsi, %rax
leaq 0xd5780(%rip), %rax     # 0x2306d2
adcq $0x0, %rax
movsbl (%rax), %r10d
subq $0x8, %rsp
movq %r13, %rdi
leaq 0xd576d(%rip), %rsi     # 0x2306d5
movq %r14, %rdx
xorl %eax, %eax
pushq %r10
leaq 0x70(%rsp), %r10
pushq %r10
pushq %r12
callq 0x22b0
addq $0x20, %rsp
movq 0x20(%rsp), %rcx
subl %ecx, %r15d
addl $-0x2, %r15d
movq %r13, %r11
movq 0x10(%rsp), %r13
leaq 0x60(%rsp), %rbp
leaq 0xd5731(%rip), %r10     # 0x2306d2
leaq 0xd5755(%rip), %rsi     # 0x2306fd
je 0x15b072
movq 0x18(%rsp), %rax
leaq (%rax,%rcx,4), %rax
movq %rax, 0x20(%rsp)
movl %r15d, %eax
movq %rax, 0x18(%rsp)
xorl %r15d, %r15d
movq (%r13), %rax
movq 0x10(%r13), %rcx
movq 0x10(%rcx), %rdx
movq 0x20(%rsp), %rcx
movl 0x8(%rcx,%r15,4), %ebx
movl %ebx, %ecx
shrl %ecx
leaq (%rcx,%rcx,4), %rdi
movl (%rax,%rcx,4), %eax
incl %ecx
movl (%rdx,%rdi,8), %edx
shrl $0x1f, %edx
leaq 0xcd634(%rip), %rdi     # 0x22862b
movsbl (%rdx,%rdi), %r8d
andl $0x1, %ebx
leaq 0xcb1bd(%rip), %rdx     # 0x2261c3
movsbl (%rbx,%rdx), %r9d
movq 0x80(%r13), %rdx
incq %rdx
cmpq %rax, %rdx
movq %r10, %rax
adcq $0x0, %rax
movsbl (%rax), %r10d
subq $0x8, %rsp
movq %r11, %rdi
movq 0x40(%rsp), %rdx
xorl %eax, %eax
pushq %r10
pushq %rbp
pushq %r12
movq %r13, %r14
movq %rsi, %r13
movq %rbp, %rbx
movq %r12, %rbp
movq %r11, %r12
callq 0x22b0
movq %r12, %r11
movq %rbp, %r12
movq %rbx, %rbp
movq %r13, %rsi
movq %r14, %r13
leaq 0xd5672(%rip), %r10     # 0x2306d2
addq $0x20, %rsp
incq %r15
cmpq %r15, 0x18(%rsp)
jne 0x15afc7
movq 0x48(%rsp), %rdx
incq %rdx
movq (%rsp), %rbx
movl 0x10(%rbx), %eax
cmpq %rax, %rdx
movq 0x50(%rsp), %r14
jb 0x15adba
movq 0x40(%rsp), %rcx
incl %ecx
movq %rcx, %rax
movq 0x30(%rsp), %r15
movq %rcx, 0x40(%rsp)
cmpq %rcx, (%r15)
ja 0x15ac6f
cmpq $0x0, (%r15)
je 0x15b330
xorl %eax, %eax
movq $0x0, (%rsp)
movq 0x10(%r15), %rcx
leaq (%rax,%rax,4), %rax
cmpl $0x0, 0xc(%rcx,%rax,8)
je 0x15b31a
leaq (%rcx,%rax,8), %rax
cmpl $0x0, (%rax)
jns 0x15b13d
movq (%rsp), %rax
leal 0x1(%rax), %ebp
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
leaq 0xd50d8(%rip), %rsi     # 0x2301ca
movq 0x28(%rsp), %r15
movq %r15, %rdx
movl %ebp, %ecx
movq %r15, %r8
movl %ebp, %r9d
xorl %eax, %eax
xorl %r12d, %r12d
pushq %r12
pushq %r12
callq 0x22b0
addq $0x10, %rsp
movq %rbx, %rdi
leaq 0xd50cf(%rip), %rsi     # 0x2301ed
movq %r15, %rdx
movl %ebp, %ecx
movq %r15, %r8
movq 0x30(%rsp), %r15
movl %ebp, %r9d
xorl %eax, %eax
pushq %r12
pushq %r12
callq 0x22b0
addq $0x10, %rsp
movq (%rsp), %rax
leal (%rax,%rax), %edx
movq 0x18(%r15), %rcx
movq 0x28(%rcx), %rax
movq %rdx, 0x48(%rsp)
movq (%rax,%rdx,8), %rax
testl %eax, %eax
je 0x15b232
movq 0x8(%rcx), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
movq (%rsp), %rsi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movq %rsi, 0x20(%rsp)
incl %esi
movl %esi, 0x18(%rsp)
movl %eax, %eax
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,8), %r13
addq $0xc, %r13
shlq $0x3, %rax
leaq (%rax,%rax,2), %rbp
xorl %ebx, %ebx
cmpl $0x0, (%r13,%rbx)
js 0x15b225
movl -0x4(%r13,%rbx), %eax
movq 0x10(%r15), %rcx
movq 0x20(%rsp), %rdx
leaq (%rdx,%rdx,4), %rdx
movl (%rcx,%rdx,8), %edx
shrl $0x1f, %edx
leaq 0xcd46b(%rip), %rsi     # 0x22862b
movsbl (%rdx,%rsi), %r8d
movl %eax, %r10d
shrl %r10d
leaq (%r10,%r10,4), %rdx
incl %r10d
movl (%rcx,%rdx,8), %ecx
shrl $0x1f, %ecx
movsbl (%rcx,%rsi), %r11d
andl $0x1, %eax
leaq 0xcafdc(%rip), %rcx     # 0x2261c3
movsbl (%rax,%rcx), %r15d
movq 0x8(%rsp), %rdi
leaq 0xd4f5a(%rip), %rsi     # 0x230152
movq 0x28(%rsp), %rdx
movl 0x18(%rsp), %ecx
movl $0x2b, %r9d
xorl %eax, %eax
xorl %r12d, %r12d
pushq %r12
pushq %r12
pushq %r15
movq 0x48(%rsp), %r15
pushq %r11
pushq %r10
pushq %rdx
callq 0x22b0
addq $0x30, %rsp
addq $0x18, %rbx
cmpq %rbx, %rbp
jne 0x15b195
movq 0x18(%r15), %rcx
movq 0x28(%rcx), %rax
movl 0x48(%rsp), %edx
movq 0x8(%rax,%rdx,8), %rax
testl %eax, %eax
je 0x15b31a
movq 0x8(%rcx), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
movq (%rsp), %rsi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
leal 0x1(%rsi), %edi
movl %edi, 0x20(%rsp)
movl %eax, %eax
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,8), %rbx
addq $0xc, %rbx
shlq $0x3, %rax
leaq (%rax,%rax,2), %r13
leaq (%rsi,%rsi,4), %rax
movq %rax, 0x18(%rsp)
xorl %ebp, %ebp
cmpl $0x0, (%rbx,%rbp)
js 0x15b30d
movl -0x4(%rbx,%rbp), %eax
movq 0x10(%r15), %rcx
movq 0x18(%rsp), %rdx
movl (%rcx,%rdx,8), %edx
shrl $0x1f, %edx
leaq 0xcd383(%rip), %rsi     # 0x22862b
movsbl (%rdx,%rsi), %r8d
movl %eax, %r10d
shrl %r10d
leaq (%r10,%r10,4), %rdx
incl %r10d
movl (%rcx,%rdx,8), %ecx
shrl $0x1f, %ecx
movsbl (%rcx,%rsi), %r11d
andl $0x1, %eax
leaq 0xcaef4(%rip), %rcx     # 0x2261c3
movsbl (%rax,%rcx), %r15d
movq 0x8(%rsp), %rdi
leaq 0xd4e72(%rip), %rsi     # 0x230152
movq 0x28(%rsp), %rdx
movl 0x20(%rsp), %ecx
movl $0x2d, %r9d
xorl %eax, %eax
xorl %r12d, %r12d
pushq %r12
pushq %r12
pushq %r15
movq 0x48(%rsp), %r15
pushq %r11
pushq %r10
pushq %rdx
callq 0x22b0
addq $0x30, %rsp
addq $0x18, %rbp
cmpq %rbp, %r13
jne 0x15b288
movq (%rsp), %rdx
incl %edx
movq %rdx, %rax
movq %rdx, (%rsp)
cmpq %rdx, (%r15)
ja 0x15b0c0
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rax
cmpq $0x0, (%rax)
je 0x15b3c4
movl $0x1, %ebp
leaq 0xcd2dc(%rip), %rbx     # 0x22862b
leaq 0xd537c(%rip), %r15     # 0x2306d2
leaq 0xd53c8(%rip), %r13     # 0x230725
xorl %ecx, %ecx
cmpb $0x0, (%r14,%rcx)
jne 0x15b3b2
movq 0x10(%rax), %rax
leaq (%rcx,%rcx,4), %rdx
movl (%rax,%rdx,8), %eax
shrl $0x1f, %eax
movsbl (%rax,%rbx), %r8d
movq 0x10(%rsp), %rdx
movq (%rdx), %rax
movq 0x80(%rdx), %rdx
movl (%rax,%rcx,4), %eax
incq %rdx
cmpq %rax, %rdx
movq %r15, %rax
adcq $0x0, %rax
movsbl (%rax), %r9d
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq 0x38(%rsp), %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x22b0
movl %ebp, %ecx
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rax
incl %ebp
cmpq %rcx, (%rax)
ja 0x15b35f
movq %r14, %rdi
callq 0x2220
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq