// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Purge_Dups.cpp
// Function: seed_uid(ma_utg_t*, unsigned long*, R_to_U*, ma_ug_t*)
uint32_t seed_uid(ma_utg_t *vu, uint64_t* ps_idx, R_to_U* ruIndex, ma_ug_t *rug)
{
    int64_t v_i, v, w, w_i, wb, we, vb, ve, k;
    uint32_t uid, is_u;
    ma_utg_t *wu = NULL;
    for (v_i = 0; v_i < vu->n; v_i++) {
        v = vu->a[v_i]>>32;
        get_R_to_U(ruIndex, v>>1, &uid, &is_u);
        if(is_u == 0 || uid == (uint32_t)-1 || ps_idx[v>>1] == (uint64_t)-1) continue;
        w_i = (uint32_t)ps_idx[v>>1];
        wu = &(rug->u.a[uid]);
        w = wu->a[w_i]>>32;
        if((v>>1)!=(w>>1)) continue;
        vb = 0; ve = vu->n; ///[vb, ve)
        if(v == w){ ///[wb, we)
            wb = w_i - v_i;
            we = wb + vu->n;
            if(wb < 0 || we > wu->n) continue;
            for (k = 0; k < vu->n; k++){
                if((vu->a[k+vb]>>32) != (wu->a[k+wb]>>32)) break;
            }
            if(k >= vu->n) return uid;
        } else {
            wb = w_i + 1 - (ve - v_i);
            we = wb + vu->n;
            if(wb < 0 || we > wu->n) continue;
            for (k = 0; k < vu->n; k++){
                if((vu->a[k+vb]>>32) != ((wu->a[we-k-1]>>32)^1)) break;
            }
            if(k >= vu->n) return uid;
        }
    }
    return (uint32_t)-1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, 0x10(%rsp)
movq %rdx, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
cmpl $0x0, 0x10(%rdi)
je 0x112903
movq %rdi, %r12
movl $0x1, %r13d
movl $0x8, %ebp
xorl %r15d, %r15d
movq 0x18(%r12), %rax
movq (%rax,%r15,8), %r14
movq %r14, %rbx
shrq $0x21, %rbx
movq 0x20(%rsp), %rdi
movl %ebx, %esi
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0xa306f
cmpl $0x0, 0x8(%rsp)
sete %cl
movl 0xc(%rsp), %eax
cmpl $-0x1, %eax
sete %dl
orb %cl, %dl
jne 0x1128eb
movq 0x18(%rsp), %rcx
movq (%rcx,%rbx,8), %rcx
cmpq $-0x1, %rcx
je 0x1128eb
movl %eax, %edx
movl %ecx, %esi
movq 0x10(%rsp), %rcx
movq 0x10(%rcx), %rcx
leaq (%rdx,%rdx,4), %rdi
movq 0x18(%rcx,%rdi,8), %rdx
movq (%rdx,%rsi,8), %r8
movq %r8, %r9
shrq $0x21, %r9
cmpl %r9d, %ebx
jne 0x1128eb
leaq (%rcx,%rdi,8), %rdi
movl 0x10(%r12), %ecx
xorq %r14, %r8
shrq $0x20, %r8
jne 0x112865
movq %rsi, %r8
subq %r15, %r8
js 0x1128eb
leaq (%r8,%rcx), %r9
movl 0x10(%rdi), %edi
cmpq %rdi, %r9
jg 0x1128eb
testq %rcx, %rcx
setne %r9b
je 0x112908
movq 0x18(%r12), %rdi
movq (%rdx,%r8,8), %r8
xorq (%rdi), %r8
shrq $0x20, %r8
jne 0x112857
leaq (,%rsi,8), %rsi
addq %rbp, %rsi
addq %rsi, %rdx
leaq -0x1(%rcx), %rsi
xorl %r8d, %r8d
cmpq %r8, %rsi
je 0x112908
movq (%rdx,%r8,8), %r9
xorq 0x8(%rdi,%r8,8), %r9
shrq $0x20, %r9
incq %r8
testq %r9, %r9
je 0x112832
cmpq %rcx, %r8
setb %r9b
testb %r9b, %r9b
jne 0x1128eb
jmp 0x112908
leaq (%rsi,%r15), %r9
incq %r9
cmpq %rcx, %r9
js 0x1128eb
movl 0x10(%rdi), %edi
cmpq %rdi, %r9
jg 0x1128eb
testq %rcx, %rcx
setne %r8b
je 0x112908
movq 0x18(%r12), %rdi
movq -0x8(%rdx,%r9,8), %r9
xorq (%rdi), %r9
shrq $0x20, %r9
cmpl $0x1, %r9d
jne 0x1128e6
addq %r13, %rsi
leaq (%rdx,%rsi,8), %rdx
addq $-0x10, %rdx
leaq -0x1(%rcx), %rsi
xorl %r8d, %r8d
movabsq $-0x100000000, %r10     # imm = 0xFFFFFFFF00000000
movabsq $0x100000000, %r11      # imm = 0x100000000
cmpq %r8, %rsi
je 0x112908
movq (%rdx), %r9
xorq 0x8(%rdi,%r8,8), %r9
andq %r10, %r9
addq $-0x8, %rdx
incq %r8
cmpq %r11, %r9
je 0x1128c3
cmpq %rcx, %r8
setb %r8b
testb %r8b, %r8b
je 0x112908
incq %r15
movl 0x10(%r12), %eax
incq %r13
addq $-0x8, %rbp
cmpq %rax, %r15
jb 0x11274f
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq