// File: chhylp123[P]hifiasm/gfa_ut.cpp
// Function: is_het_ulg_edge(ul_resolve_t*, unsigned int, unsigned int)
uint32_t is_het_ulg_edge(ul_resolve_t *uidx, uint32_t uv, uint32_t uw)
{
    ma_ug_t *iug = uidx->uovl.i_ug; bubble_type *bub = uidx->bub; uint32_t qid, tid;
    qid = iug->u.a[uv>>1].a[((uv&1)?(0):(iug->u.a[uv>>1].n-1))]>>33;
    tid = iug->u.a[uw>>1].a[((uw&1)?(iug->u.a[uw>>1].n-1):(0))]>>33;

    if(!ulg_type(uidx->uovl, qid)) return (!IF_HOM(ulg_id(uidx->uovl, qid), *bub));
    if(!ulg_type(uidx->uovl, tid)) return (!IF_HOM(ulg_id(uidx->uovl, tid), *bub));

    if(uidx->uovl.item_idx[qid] == (uint32_t)-1) return (uint32_t)-1;
    ul2ul_item_t *o = &(uidx->uovl.a[uidx->uovl.item_idx[qid]]); 
    ul2ul_t *z; uint64_t k, n_hom, n_het; ul_str_t *str;
    for (k = 0, z = NULL; k < o->cn; k++) {
        if(o->a[k].hid != tid) continue;
        z = &(o->a[k]);
        break;
    }
    if(!z) return (uint32_t)-1;
    str = &(uidx->pstr.str.a[ulg_id(uidx->uovl, qid)]);

    for (k = z->qs_k, n_hom = n_het = 0; k < z->qe_k; k++) {
        if(IF_HOM((((uint32_t)str->a[k])>>1), *bub)) {
            n_hom++;
        } else {
            n_het++; break;
        }
    }
    
    if(n_het) return 1;
    if(n_hom) return 0;
    return (uint32_t)-1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x230(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq %rax, -0x68(%rbp)
movl -0x14(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x342ead
xorl %eax, %eax
movl %eax, -0x6c(%rbp)
jmp 0x342ecc
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
subl $0x1, %eax
movl %eax, -0x6c(%rbp)
movq -0x68(%rbp), %rax
movl -0x6c(%rbp), %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x18(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq %rax, -0x78(%rbp)
movl -0x18(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x342f2a
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x18(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
subl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x342f31
xorl %eax, %eax
movl %eax, -0x7c(%rbp)
jmp 0x342f31
movq -0x78(%rbp), %rax
movl -0x7c(%rbp), %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq 0x208(%rax), %rsi
movl $0x1, %eax
xorl %ecx, %ecx
cmpq %rsi, %rdx
cmovael %ecx, %eax
cmpl $0x0, %eax
jne 0x342fdb
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x88(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpq 0x208(%rcx), %rax
jb 0x342f9c
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
subq 0x208(%rcx), %rax
movq %rax, -0x90(%rbp)
jmp 0x342fa6
movl -0x2c(%rbp), %eax
movq %rax, -0x90(%rbp)
movq -0x88(%rbp), %rax
movq -0x90(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x28(%rbp), %rcx
movq 0x80(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
seta %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x343232
movl -0x30(%rbp), %eax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq 0x208(%rax), %rsi
movl $0x1, %eax
xorl %ecx, %ecx
cmpq %rsi, %rdx
cmovael %ecx, %eax
cmpl $0x0, %eax
jne 0x343071
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x98(%rbp)
movl -0x30(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpq 0x208(%rcx), %rax
jb 0x343032
movl -0x30(%rbp), %eax
movq -0x10(%rbp), %rcx
subq 0x208(%rcx), %rax
movq %rax, -0xa0(%rbp)
jmp 0x34303c
movl -0x30(%rbp), %eax
movq %rax, -0xa0(%rbp)
movq -0x98(%rbp), %rax
movq -0xa0(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x28(%rbp), %rcx
movq 0x80(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
seta %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x343232
movq -0x10(%rbp), %rax
movq 0x220(%rax), %rax
movl -0x2c(%rbp), %ecx
cmpl $-0x1, (%rax,%rcx,4)
jne 0x343091
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x343232
movq -0x10(%rbp), %rax
movq 0x1f0(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x220(%rcx), %rcx
movl -0x2c(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x48(%rbp), %rax
movq -0x38(%rbp), %rcx
movl 0x1c(%rcx), %ecx
cmpq %rcx, %rax
jae 0x343113
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x48(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl -0x30(%rbp), %eax
je 0x3430f0
jmp 0x343105
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x48(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
jmp 0x343113
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x3430c8
cmpq $0x0, -0x40(%rbp)
jne 0x343126
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x343232
movq -0x10(%rbp), %rax
movq 0x1d0(%rax), %rax
movq %rax, -0xa8(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpq 0x208(%rcx), %rax
jb 0x34315f
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
subq 0x208(%rcx), %rax
movq %rax, -0xb0(%rbp)
jmp 0x343169
movl -0x2c(%rbp), %eax
movq %rax, -0xb0(%rbp)
movq -0xa8(%rbp), %rax
movq -0xb0(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x40(%rbp), %rax
movl 0x14(%rax), %eax
movq %rax, -0x48(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
movl 0x18(%rcx), %ecx
cmpq %rcx, %rax
jae 0x34320b
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x60(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x48(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movq -0x28(%rbp), %rcx
movq 0x80(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jbe 0x3431ed
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x3431fb
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x34320b
jmp 0x3431fd
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x34319d
cmpq $0x0, -0x58(%rbp)
je 0x34321b
movl $0x1, -0x4(%rbp)
jmp 0x343232
cmpq $0x0, -0x50(%rbp)
je 0x34322b
movl $0x0, -0x4(%rbp)
jmp 0x343232
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)