// File: /workspace/github_cpp_makefile_star2_O2/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 0x102d7c
orq $-0x1, (%rdx)
testq %rcx, %rcx
je 0x102d85
orq $-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
movabsq $-0x1, %rax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %r9
cmpq %rbx, %r11
je 0x102e34
testl %r8d, %r8d
je 0x102e1e
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 0x102df7
shrl %ebx
movq (%rdi), %r14
movq 0x80(%rdi), %r15
movl (%r14,%rbx,4), %ebx
incq %r15
cmpq %rbx, %r15
jne 0x102e31
cmpl $-0x1, %r9d
je 0x102e19
shrl %r9d
movq (%rdi), %rbx
movq 0x80(%rdi), %r14
movl (%rbx,%r9,4), %ebx
incq %r14
movq %r11, %r9
cmpq %rbx, %r14
jne 0x102e34
movq %rax, %r9
jmp 0x102e34
movq %rsi, %rdi
shrq $0x20, %rdi
cmpq %r10, %rsi
cmovbeq %rdi, %rax
movq %r11, %r9
jmp 0x102e9e
movq %r11, %r9
cmpq %r10, %rsi
ja 0x102e9e
shrq $0x20, %rsi
testl %r8d, %r8d
je 0x102e9b
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 0x102e7c
shrl %r10d
movq (%rdi), %r11
movq 0x80(%rdi), %rbx
movl (%r11,%r10,4), %r10d
incq %rbx
cmpq %r10, %rbx
jne 0x102e9b
cmpl $-0x1, %r8d
je 0x102e9e
shrl %r8d
movq (%rdi), %r10
movq 0x80(%rdi), %rdi
movl (%r10,%r8,4), %r8d
incq %rdi
cmpq %r8, %rdi
je 0x102e9e
movq %rsi, %rax
cmpq $-0x1, %r9
movq %rax, %rsi
cmoveq %r9, %rsi
testq %rdx, %rdx
popq %rbx
popq %r14
popq %r15
je 0x102ec6
cmpq $-0x1, %rax
cmoveq %r9, %rax
cmpq $-0x1, %r9
cmovneq %r9, %rax
movq %rax, (%rdx)
testq %rcx, %rcx
je 0x102ece
movq %rsi, (%rcx)
retq