// File: /workspace/github_cpp_makefile_star2_O2/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 $0x68, %rsp
movq %rcx, 0x10(%rsp)
movq %rdx, 0x20(%rsp)
movq %rsi, %r15
movq %rdi, %r12
movq 0xc0(%rdi), %r14
xorl %edx, %edx
movl %edx, %edx
movq (%r14), %rax
cmpq %rdx, %rax
jbe 0x1168bb
movq 0x10(%r14), %rbp
imulq $0x28, %rdx, %rcx
movl 0x10(%rbp,%rcx), %eax
testl %eax, %eax
je 0x1168b4
movq %rdx, 0x8(%rsp)
addq %rcx, %rbp
xorl %ebx, %ebx
xorl %r13d, %r13d
movl %eax, %eax
cmpq %rax, %rbx
jae 0x11677a
movq 0x18(%rbp), %rax
movq (%rax,%rbx,8), %rsi
shrq $0x21, %rsi
subq $0x8, %rsp
movq %r12, %rdi
leaq 0x24(%rsp), %rdx
leaq 0x20(%rsp), %rcx
leaq 0x40(%rsp), %r8
leaq 0xc(%rsp), %r9
pushq $0x0
callq 0xf6ab5
popq %rax
popq %rcx
addl 0x4(%rsp), %r13d
incq %rbx
movl 0x10(%rbp), %eax
jmp 0x116736
movq 0x8(%rsp), %r9
incl %r9d
movl (%rbp), %eax
shrl $0x1f, %eax
leaq 0xcfefc(%rip), %rcx     # 0x1e668b
movsbl (%rax,%rcx), %r8d
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
leaq 0xd1b37(%rip), %rsi     # 0x1e82da
movq 0x20(%rsp), %rdx
movq %r9, 0x8(%rsp)
movl %r9d, %ecx
xorl %eax, %eax
callq 0x2050
movq 0x10(%rsp), %rdi
leaq 0xd7ae0(%rip), %rsi     # 0x1ee2a3
movq %rbx, %rdx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x22b0
xorl %r13d, %r13d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl 0x10(%rbp), %eax
cmpq %rax, %r13
jae 0x1168aa
movq 0x18(%rbp), %rax
movq (%rax,%r13,8), %rsi
shrq $0x21, %rsi
subq $0x8, %rsp
movq %r12, %rdi
leaq 0x24(%rsp), %rdx
leaq 0x20(%rsp), %rcx
leaq 0x40(%rsp), %r8
leaq 0xc(%rsp), %r9
pushq $0x0
callq 0xf6ab5
popq %rax
popq %rcx
movl 0x1c(%rsp), %eax
cmpq %rbx, %rax
je 0x11685b
shrl %eax
movl %eax, %edx
incl %edx
movq 0x10(%r15), %rcx
imulq $0x28, %rax, %rax
movl (%rcx,%rax), %eax
shrl $0x1f, %eax
leaq 0xcfe53(%rip), %rcx     # 0x1e668b
movsbl (%rax,%rcx), %ecx
movl 0x4(%rsp), %r8d
movq 0x10(%rsp), %rdi
leaq 0xd7a66(%rip), %rsi     # 0x1ee2b3
leaq 0xd79ed(%rip), %r9      # 0x1ee241
xorl %eax, %eax
callq 0x22b0
movl 0x18(%rsp), %eax
cmpq %rbx, %rax
je 0x1168a2
shrl %eax
movl %eax, %edx
incl %edx
movq 0x10(%r15), %rcx
imulq $0x28, %rax, %rax
movl (%rcx,%rax), %eax
shrl $0x1f, %eax
leaq 0xcfe0c(%rip), %rcx     # 0x1e668b
movsbl (%rax,%rcx), %ecx
movl 0x4(%rsp), %r8d
movq 0x10(%rsp), %rdi
leaq 0xd7a1f(%rip), %rsi     # 0x1ee2b3
leaq 0xd79aa(%rip), %r9      # 0x1ee245
xorl %eax, %eax
callq 0x22b0
incq %r13
jmp 0x1167d8
movq 0x8(%rsp), %rdx
jmp 0x116707
incl %edx
jmp 0x116707
xorl %r12d, %r12d
movq %r14, 0x8(%rsp)
movl %r12d, %r12d
cmpq %r12, %rax
jbe 0x116ae8
movq 0x10(%r14), %rcx
imulq $0x28, %r12, %rdx
cmpl $0x0, 0xc(%rcx,%rdx)
je 0x116ae0
addq %rdx, %rcx
cmpl $0x0, (%rcx)
jns 0x116944
leal 0x1(%r12), %r13d
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
leaq 0xd79c8(%rip), %rsi     # 0x1ee2c6
movq 0x20(%rsp), %r14
movq %r14, %rdx
movl %r13d, %ecx
movq %r14, %r8
movl %r13d, %r9d
xorl %eax, %eax
pushq $0x0
pushq $0x0
callq 0x22b0
popq %rcx
popq %rdx
movq %rbx, %rdi
leaq 0xd79c3(%rip), %rsi     # 0x1ee2e9
movq %r14, %rdx
movl %r13d, %ecx
movq %r14, %r8
movq 0x8(%rsp), %r14
movl %r13d, %r9d
xorl %eax, %eax
pushq $0x0
pushq $0x0
callq 0x22b0
popq %rcx
popq %rdx
leal (%r12,%r12), %edx
movq 0x18(%r14), %rax
movq 0x8(%rax), %rcx
movq 0x28(%rax), %rax
movq %rdx, 0x28(%rsp)
movq (%rax,%rdx,8), %rax
movl %eax, %edx
shrq $0x20, %rax
movq %r12, 0x30(%rsp)
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
leal 0x1(%r12), %r13d
imulq $0x18, %rdx, %rbp
imulq $0x18, %rax, %rax
leaq (%rcx,%rax), %r15
addq $0xc, %r15
xorl %ebx, %ebx
cmpq %rbx, %rbp
je 0x116a18
cmpl $0x0, (%r15,%rbx)
js 0x116a0f
movl -0x4(%r15,%rbx), %eax
movq 0x10(%r14), %rcx
imulq $0x28, %r12, %rdx
movl (%rcx,%rdx), %edx
shrl $0x1f, %edx
leaq 0xcfcdb(%rip), %rsi     # 0x1e668b
movsbl (%rdx,%rsi), %r8d
movl %eax, %r10d
shrl %r10d
imulq $0x28, %r10, %rdx
incl %r10d
movl (%rcx,%rdx), %ecx
shrl $0x1f, %ecx
movsbl (%rcx,%rsi), %r11d
andl $0x1, %eax
leaq 0xcd84c(%rip), %rcx     # 0x1e4223
movsbl (%rax,%rcx), %r14d
movq 0x10(%rsp), %rdi
leaq 0xd7866(%rip), %rsi     # 0x1ee24e
movq 0x20(%rsp), %rdx
movl %r13d, %ecx
pushq $0x2b
popq %r9
xorl %eax, %eax
pushq $0x0
pushq $0x0
pushq %r14
movq 0x20(%rsp), %r14
pushq %r11
pushq %r10
pushq %rdx
callq 0x22b0
addq $0x30, %rsp
addq $0x18, %rbx
jmp 0x116986
movq 0x18(%r14), %rax
movq 0x8(%rax), %rcx
movq 0x28(%rax), %rax
movl 0x28(%rsp), %edx
movq 0x8(%rax,%rdx,8), %rax
movl %eax, %edx
shrq $0x20, %rax
imulq $0x18, %rdx, %rbp
imulq $0x18, %rax, %rax
leaq (%rcx,%rax), %r15
addq $0xc, %r15
imulq $0x28, %r12, %r12
xorl %ebx, %ebx
cmpq %rbx, %rbp
je 0x116ad8
cmpl $0x0, (%r15,%rbx)
js 0x116acf
movl -0x4(%r15,%rbx), %eax
movq 0x10(%r14), %rcx
movl (%rcx,%r12), %edx
shrl $0x1f, %edx
leaq 0xcfc1b(%rip), %rsi     # 0x1e668b
movsbl (%rdx,%rsi), %r8d
movl %eax, %r10d
shrl %r10d
imulq $0x28, %r10, %rdx
incl %r10d
movl (%rcx,%rdx), %ecx
shrl $0x1f, %ecx
movsbl (%rcx,%rsi), %r11d
andl $0x1, %eax
leaq 0xcd78c(%rip), %rcx     # 0x1e4223
movsbl (%rax,%rcx), %r14d
movq 0x10(%rsp), %rdi
leaq 0xd77a6(%rip), %rsi     # 0x1ee24e
movq 0x20(%rsp), %rdx
movl %r13d, %ecx
pushq $0x2d
popq %r9
xorl %eax, %eax
pushq $0x0
pushq $0x0
pushq %r14
movq 0x20(%rsp), %r14
pushq %r11
pushq %r10
pushq %rdx
callq 0x22b0
addq $0x30, %rsp
addq $0x18, %rbx
jmp 0x116a49
movq (%r14), %rax
movq 0x30(%rsp), %r12
incl %r12d
jmp 0x1168c3
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq