// File: 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
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq $0x0, -0x80(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x10(%rcx), %ecx
cmpq %rcx, %rax
jge 0x184642
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rax
sarq %rax
movl %eax, %esi
leaq -0x74(%rbp), %rdx
leaq -0x78(%rbp), %rcx
callq 0xd3d50
cmpl $0x0, -0x78(%rbp)
je 0x18442f
cmpl $-0x1, -0x74(%rbp)
je 0x18442f
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
sarq %rcx
cmpq $-0x1, (%rax,%rcx,8)
jne 0x184434
jmp 0x184631
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
sarq %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x74(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
sarq %rax
movq -0x40(%rbp), %rcx
sarq %rcx
cmpq %rcx, %rax
je 0x18448f
jmp 0x184631
movq $0x0, -0x60(%rbp)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0x184569
movq -0x48(%rbp), %rax
subq -0x30(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x10(%rcx), %ecx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x50(%rbp)
jl 0x1844e5
movq -0x58(%rbp), %rax
movq -0x80(%rbp), %rcx
movl 0x10(%rcx), %ecx
cmpq %rcx, %rax
jle 0x1844ea
jmp 0x184631
movq $0x0, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x10(%rcx), %ecx
cmpq %rcx, %rax
jge 0x184549
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x70(%rbp), %rcx
addq -0x60(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq -0x80(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq -0x70(%rbp), %rdx
addq -0x50(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
cmpq %rcx, %rax
je 0x184539
jmp 0x184549
jmp 0x18453b
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x1844f2
movq -0x70(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x10(%rcx), %ecx
cmpq %rcx, %rax
jl 0x184564
movl -0x74(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x184649
jmp 0x18462f
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq -0x68(%rbp), %rcx
subq -0x30(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x10(%rcx), %ecx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x50(%rbp)
jl 0x1845a9
movq -0x58(%rbp), %rax
movq -0x80(%rbp), %rcx
movl 0x10(%rcx), %ecx
cmpq %rcx, %rax
jle 0x1845ae
jmp 0x184631
movq $0x0, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x10(%rcx), %ecx
cmpq %rcx, %rax
jge 0x184615
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x70(%rbp), %rcx
addq -0x60(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq -0x80(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq -0x58(%rbp), %rdx
subq -0x70(%rbp), %rdx
subq $0x1, %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
xorq $0x1, %rcx
cmpq %rcx, %rax
je 0x184605
jmp 0x184615
jmp 0x184607
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x1845b6
movq -0x70(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x10(%rcx), %ecx
cmpq %rcx, %rax
jl 0x18462d
movl -0x74(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x184649
jmp 0x18462f
jmp 0x184631
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x1843cb
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)