// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/hic.cpp
// Function: get_bub_id(bubble_type*, unsigned int, unsigned long*, unsigned long*, unsigned int)
void get_bub_id(bubble_type* bub, uint32_t root, uint64_t* id0, uint64_t* id1, uint32_t check_het)
{
    if(id0) (*id0) = (uint64_t)-1;
    if(id1) (*id1) = (uint64_t)-1;
    uint64_t b_id0 = (uint64_t)-1, b_id1 = (uint64_t)-1;
    uint32_t beg, sink;

    if((bub->b_s_idx.a[root]&0xffffffff) != 0xffffffff)
    {
        b_id0 = bub->b_s_idx.a[root]&0xffffffff;
        if(check_het)
        {
            get_bubbles(bub, b_id0, &beg, &sink, NULL, NULL, NULL);
            if(((beg == (uint32_t)-1) || IF_HET(beg>>1, *bub)) && ((sink == (uint32_t)-1) || IF_HET(sink>>1, *bub))) b_id0 = (uint64_t)-1;
        } 
    }

    if((bub->b_s_idx.a[root]&0xffffffff00000000) != 0xffffffff00000000)
    {
        b_id1 = bub->b_s_idx.a[root]&0xffffffff00000000; b_id1 >>= 32;
        if(check_het)
        {
            get_bubbles(bub, b_id1, &beg, &sink, NULL, NULL, NULL);
            if(((beg == (uint32_t)-1) || IF_HET(beg>>1, *bub)) && ((sink == (uint32_t)-1) || IF_HET(sink>>1, *bub))) b_id1 = (uint64_t)-1;
        }        
    }

    if(b_id0 == (uint64_t)-1 && b_id1 != (uint64_t)-1)
    {
        b_id0 = b_id1;
        b_id1 = (uint64_t)-1;
    }

    if(id0) (*id0) = b_id0;
    if(id1) (*id1) = b_id1;
}

// Assembly:
testq %rdx, %rdx
je 0x14ac13
movq $-0x1, (%rdx)
testq %rcx, %rcx
je 0x14ac1f
movq $-0x1, (%rcx)
pushq %r15
pushq %r14
pushq %rbx
movabsq $-0x100000001, %r10     # imm = 0xFFFFFFFEFFFFFFFF
movq 0x70(%rdi), %rax
movl %esi, %esi
movq (%rax,%rsi,8), %rsi
movl %esi, %r11d
movq $-0x1, %rax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq $-0x1, %r9
cmpq %rbx, %r11
je 0x14acd7
testl %r8d, %r8d
je 0x14acc1
movq 0x28(%rdi), %r9
movq 0x40(%rdi), %rbx
movl (%rbx,%r11,4), %r14d
movl (%r9,%r14,4), %ebx
incl %r14d
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl (%r9,%r14,4), %r9d
cmpq %r15, %rbx
je 0x14ac96
shrl %ebx
movq (%rdi), %r14
movq 0x80(%rdi), %r15
movl (%r14,%rbx,4), %ebx
incq %r15
cmpq %rbx, %r15
jne 0x14acd4
cmpl $-0x1, %r9d
je 0x14acb8
shrl %r9d
movq (%rdi), %rbx
movq 0x80(%rdi), %r14
movl (%rbx,%r9,4), %ebx
incq %r14
movq %r11, %r9
cmpq %rbx, %r14
jne 0x14acd7
movq $-0x1, %r9
jmp 0x14acd7
movq %rsi, %rdi
shrq $0x20, %rdi
cmpq %r10, %rsi
cmovbeq %rdi, %rax
movq %r11, %r9
jmp 0x14ad41
movq %r11, %r9
cmpq %r10, %rsi
ja 0x14ad41
shrq $0x20, %rsi
testl %r8d, %r8d
je 0x14ad3e
movq 0x28(%rdi), %r8
movq 0x40(%rdi), %r10
movl (%r10,%rsi,4), %r11d
movl (%r8,%r11,4), %r10d
incl %r11d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl (%r8,%r11,4), %r8d
cmpq %rbx, %r10
je 0x14ad1f
shrl %r10d
movq (%rdi), %r11
movq 0x80(%rdi), %rbx
movl (%r11,%r10,4), %r10d
incq %rbx
cmpq %r10, %rbx
jne 0x14ad3e
cmpl $-0x1, %r8d
je 0x14ad41
shrl %r8d
movq (%rdi), %r10
movq 0x80(%rdi), %rdi
movl (%r10,%r8,4), %r8d
incq %rdi
cmpq %r8, %rdi
je 0x14ad41
movq %rsi, %rax
cmpq $-0x1, %r9
movq %rax, %rsi
cmoveq %r9, %rsi
testq %rdx, %rdx
popq %rbx
popq %r14
popq %r15
je 0x14ad69
cmpq $-0x1, %rax
cmoveq %r9, %rax
cmpq $-0x1, %r9
cmovneq %r9, %rax
movq %rax, (%rdx)
testq %rcx, %rcx
je 0x14ad71
movq %rsi, (%rcx)
retq