// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/hic.cpp
// Function: print_bubble_utg(bubble_type*, ma_ug_t*, char const*, _IO_FILE*)
void print_bubble_utg(bubble_type* bub, ma_ug_t* unitig_ug, const char* prefix, FILE *fp)
{
    uint32_t i, k, *a, n, beg, sink, x, occ;
    ma_ug_t *b_ug = bub->b_ug;
    char name[32];
    for (i = 0; i < b_ug->u.n; i++)
    {
        ma_utg_t *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);
            occ += n;
        }
        sprintf(name, "%s%.6d%c", prefix, i + 1, "lc"[p->circ]);
        fprintf(fp, "S\t%s\t*\tLN:i:%u\n", name, occ);
        for (k = 0; k < p->n; k++)
        {
            x = p->a[k]>>33;
            get_bubbles(bub, x, &beg, &sink, &a, &n, NULL);
            if(beg != (uint32_t)-1) fprintf(fp, "A\tutg%.6d%c\t%u\t%s\n", (beg>>1)+1, "lc"[unitig_ug->u.a[(beg>>1)].circ], n, "beg");
            if(sink != (uint32_t)-1) fprintf(fp, "A\tutg%.6d%c\t%u\t%s\n", (sink>>1)+1, "lc"[unitig_ug->u.a[(sink>>1)].circ], n, "sink");
        }
    }

    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", 
            prefix, i+1, prefix, i+1, 0, 0);
            fprintf(fp, "L\t%s%.6dc\t-\t%s%.6dc\t-\t%dM\tL1:i:%d\n", 
            prefix, i+1, prefix, 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", 
            prefix, (u>>1)+1, "lc"[b_ug->u.a[u>>1].circ], "+-"[u&1],
            prefix, (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", 
            prefix, (u>>1)+1, "lc"[b_ug->u.a[u>>1].circ], "+-"[u&1],
            prefix, (v>>1)+1, "lc"[b_ug->u.a[v>>1].circ], "+-"[v&1], 0, 0);
        }
    }

    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, 0x10(%rsp)
movq %rdx, 0x18(%rsp)
movq 0xc0(%rdi), %r14
cmpq $0x0, (%r14)
movq %r14, 0x20(%rsp)
je 0x156321
movq %rsi, %r15
movq %rdi, %r12
xorl %eax, %eax
movq $0x0, (%rsp)
movq 0x10(%r14), %rcx
leaq (%rax,%rax,4), %rdx
movl 0x10(%rcx,%rdx,8), %eax
testq %rax, %rax
je 0x156306
leaq (%rcx,%rdx,8), %r13
movq 0x18(%r13), %rcx
movq 0x40(%r12), %rdx
xorl %esi, %esi
xorl %ebp, %ebp
movq (%rcx,%rsi,8), %rdi
shrq $0x21, %rdi
subl (%rdx,%rdi,4), %ebp
movl 0x4(%rdx,%rdi,4), %edi
addl %edi, %ebp
addl $-0x2, %ebp
incq %rsi
cmpq %rsi, %rax
jne 0x1561ca
movq (%rsp), %rax
leal 0x1(%rax), %ecx
movl (%r13), %eax
shrl $0x1f, %eax
leaq 0xd2430(%rip), %rdx     # 0x22862b
movsbl (%rax,%rdx), %r8d
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
leaq 0xd3fdb(%rip), %rsi     # 0x22a1ea
movq 0x18(%rsp), %rdx
xorl %eax, %eax
callq 0x2050
movq 0x10(%rsp), %rdi
leaq 0xd9f80(%rip), %rsi     # 0x2301a7
movq %rbx, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x22b0
cmpl $0x0, 0x10(%r13)
je 0x156306
xorl %ebx, %ebx
movq 0x18(%r13), %rax
movq (%rax,%rbx,8), %rax
movq 0x28(%r12), %rcx
movq 0x40(%r12), %rdx
shrq $0x21, %rax
movl (%rdx,%rax,4), %esi
movl 0x4(%rdx,%rax,4), %ebp
subl %esi, %ebp
addl $-0x2, %ebp
movl (%rcx,%rsi,4), %eax
leal 0x1(%rsi), %edx
movl (%rcx,%rdx,4), %r14d
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
je 0x1562b2
shrl %eax
movl %eax, %edx
incl %edx
movq 0x10(%r15), %rcx
leaq (%rax,%rax,4), %rax
movl (%rcx,%rax,8), %eax
shrl $0x1f, %eax
leaq 0xd239a(%rip), %rcx     # 0x22862b
movsbl (%rax,%rcx), %ecx
movq 0x10(%rsp), %rdi
leaq 0xd9f16(%rip), %rsi     # 0x2301b7
movl %ebp, %r8d
leaq 0xd9e9a(%rip), %r9      # 0x230145
xorl %eax, %eax
callq 0x22b0
cmpl $-0x1, %r14d
je 0x1562f6
shrl %r14d
movl %r14d, %edx
incl %edx
movq 0x10(%r15), %rax
leaq (%r14,%r14,4), %rcx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
leaq 0xd2356(%rip), %rcx     # 0x22862b
movsbl (%rax,%rcx), %ecx
movq 0x10(%rsp), %rdi
leaq 0xd9ed2(%rip), %rsi     # 0x2301b7
movl %ebp, %r8d
leaq 0xd9e5a(%rip), %r9      # 0x230149
xorl %eax, %eax
callq 0x22b0
incq %rbx
movl 0x10(%r13), %eax
cmpq %rax, %rbx
jb 0x156240
movq (%rsp), %rcx
incl %ecx
movq %rcx, %rax
movq 0x20(%rsp), %r14
movq %rcx, (%rsp)
cmpq %rcx, (%r14)
ja 0x1561a4
cmpq $0x0, (%r14)
je 0x156590
xorl %eax, %eax
movq $0x0, 0x8(%rsp)
movq 0x10(%r14), %rcx
leaq (%rax,%rax,4), %rax
cmpl $0x0, 0xc(%rcx,%rax,8)
je 0x156578
leaq (%rcx,%rax,8), %rax
cmpl $0x0, (%rax)
jns 0x1563b4
movq 0x8(%rsp), %rax
leal 0x1(%rax), %ebp
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
leaq 0xd9e61(%rip), %rsi     # 0x2301ca
movq 0x18(%rsp), %r14
movq %r14, %rdx
movl %ebp, %ecx
movq %r14, %r8
movl %ebp, %r9d
xorl %eax, %eax
xorl %r15d, %r15d
pushq %r15
pushq %r15
callq 0x22b0
addq $0x10, %rsp
movq %rbx, %rdi
leaq 0xd9e58(%rip), %rsi     # 0x2301ed
movq %r14, %rdx
movl %ebp, %ecx
movq %r14, %r8
movq 0x20(%rsp), %r14
movl %ebp, %r9d
xorl %eax, %eax
pushq %r15
pushq %r15
callq 0x22b0
addq $0x10, %rsp
movq 0x8(%rsp), %rax
leal (%rax,%rax), %edx
movq 0x18(%r14), %rcx
movq 0x28(%rcx), %rax
movq %rdx, 0x28(%rsp)
movq (%rax,%rdx,8), %rax
testl %eax, %eax
je 0x15649a
movq 0x8(%rcx), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
movq 0x8(%rsp), %rbx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
leal 0x1(%rbx), %esi
movl %esi, (%rsp)
movl %eax, %eax
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,8), %r13
addq $0xc, %r13
shlq $0x3, %rax
leaq (%rax,%rax,2), %r15
xorl %r12d, %r12d
cmpl $0x0, (%r13,%r12)
js 0x15648d
movl -0x4(%r13,%r12), %eax
movq 0x10(%r14), %rcx
leaq (%rbx,%rbx,4), %rdx
movl (%rcx,%rdx,8), %edx
shrl $0x1f, %edx
leaq 0xd21ff(%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 0xcfd70(%rip), %rcx     # 0x2261c3
movsbl (%rax,%rcx), %r14d
movq 0x10(%rsp), %rdi
leaq 0xd9cee(%rip), %rsi     # 0x230152
movq 0x18(%rsp), %rdx
movl (%rsp), %ecx
movl $0x2b, %r9d
xorl %eax, %eax
xorl %ebp, %ebp
pushq %rbp
pushq %rbp
pushq %r14
movq 0x38(%rsp), %r14
pushq %r11
pushq %r10
pushq %rdx
callq 0x22b0
addq $0x30, %rsp
addq $0x18, %r12
cmpq %r12, %r15
jne 0x15640a
movq 0x18(%r14), %rcx
movq 0x28(%rcx), %rax
movl 0x28(%rsp), %edx
movq 0x8(%rax,%rdx,8), %rax
testl %eax, %eax
je 0x156578
movq 0x8(%rcx), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
movq 0x8(%rsp), %rsi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
leal 0x1(%rsi), %edi
movl %edi, (%rsp)
movl %eax, %eax
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,8), %rbx
addq $0xc, %rbx
shlq $0x3, %rax
leaq (%rax,%rax,2), %r15
leaq (%rsi,%rsi,4), %r13
xorl %r12d, %r12d
cmpl $0x0, (%rbx,%r12)
js 0x15656b
movl -0x4(%rbx,%r12), %eax
movq 0x10(%r14), %rcx
movl (%rcx,%r13,8), %edx
shrl $0x1f, %edx
leaq 0xd2121(%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 0xcfc92(%rip), %rcx     # 0x2261c3
movsbl (%rax,%rcx), %r14d
movq 0x10(%rsp), %rdi
leaq 0xd9c10(%rip), %rsi     # 0x230152
movq 0x18(%rsp), %rdx
movl (%rsp), %ecx
movl $0x2d, %r9d
xorl %eax, %eax
xorl %ebp, %ebp
pushq %rbp
pushq %rbp
pushq %r14
movq 0x38(%rsp), %r14
pushq %r11
pushq %r10
pushq %rdx
callq 0x22b0
addq $0x30, %rsp
addq $0x18, %r12
cmpq %r12, %r15
jne 0x1564ec
movq 0x8(%rsp), %rdx
incl %edx
movq %rdx, %rax
movq %rdx, 0x8(%rsp)
cmpq %rdx, (%r14)
ja 0x156336
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq