// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Purge_Dups.cpp
// Function: push_hap_can(asg_arc_t_offset*, kvec_hap_candidates*, int*, long long, long long, long long)
inline void push_hap_can(asg_arc_t_offset* x, kvec_hap_candidates* u_can, int32_t* Results, 
long long chainLen, long long x_readLen, long long y_readLen)
{
    if(chainLen <= 0) return;
    hap_candidates hap_can;
    hap_can.rev = x[Results[0]].x.el;
    hap_can.x_beg_pos = hap_can.x_end_pos = (uint32_t)(x[Results[0]].Off>>32);
    hap_can.y_beg_pos = hap_can.y_end_pos = (uint32_t)(x[Results[0]].Off);
    hap_can.weight = 0;
    long long i = 0;
    uint64_t totalWeigth = 0;
    ///fprintf(stderr, "^^^chainLen: %lld\n", chainLen);
    for (i = 0; i < chainLen; i++)
    {
        ///fprintf(stderr, "i: %lld, Results[i]: %d\n", i, Results[i]);
        hap_can.x_beg_pos = (uint32_t)(x[Results[i]].Off>>32);
        hap_can.y_beg_pos = (uint32_t)(x[Results[i]].Off);
        hap_can.weight += x[Results[i]].weight;
    }

    for (i = 0; i < chainLen; i++)
    {
        totalWeigth += x[Results[i]].weight;
        if(totalWeigth >= (hap_can.weight/2)) break;
    }

    if(i >= chainLen) i = chainLen-1;
    ///Get_total(hap_can) = Results[i];
    hap_can.t = x[Results[i]].x;
    Get_type(hap_can) = classify_hap_overlap(hap_can.x_beg_pos, hap_can.x_end_pos, 
    x_readLen, hap_can.y_beg_pos, hap_can.y_end_pos, y_readLen, NULL, NULL, NULL, NULL);
    kv_push(hap_candidates, u_can->a, hap_can);
    if(hap_can.x_beg_pos > hap_can.x_end_pos || hap_can.y_beg_pos > hap_can.y_end_pos)
    {
        fprintf(stderr, "ERROR\n");
    }
}

// Assembly:
testq %rcx, %rcx
jle 0x1188f8
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %r14
movslq (%rdx), %rax
leaq (%rax,%rax,4), %rax
movb 0x12(%rdi,%rax,8), %sil
movb %sil, 0x2f(%rsp)
movq 0x18(%rdi,%rax,8), %r11
movq %r11, %rbx
shrq $0x20, %rbx
xorl %eax, %eax
xorl %r13d, %r13d
movslq (%rdx,%rax,4), %rsi
leaq (%rsi,%rsi,4), %rsi
addq 0x20(%rdi,%rsi,8), %r13
incq %rax
cmpq %rax, %rcx
jne 0x118794
leaq (%rdi,%rsi,8), %rax
movq 0x18(%rax), %r12
movq %r12, %r15
shrq $0x20, %r15
movq %r13, %rsi
shrq %rsi
movslq (%rdx), %rax
leaq (%rax,%rax,4), %rax
movq 0x20(%rdi,%rax,8), %r10
cmpq %rsi, %r10
jae 0x1187fa
movq %r11, %rbp
movl $0x1, %eax
movq %rax, %r11
cmpq %rax, %rcx
je 0x118801
movslq (%rdx,%r11,4), %rax
leaq (%rax,%rax,4), %rax
addq 0x20(%rdi,%rax,8), %r10
leaq 0x1(%r11), %rax
cmpq %rsi, %r10
jb 0x1187d7
decq %rax
jmp 0x118804
movb $0x1, %sil
xorl %eax, %eax
jmp 0x11880e
movq %rcx, %rax
cmpq %rcx, %r11
setl %sil
movq %rbp, %r11
decq %rcx
testb %sil, %sil
cmovneq %rax, %rcx
movslq (%rdx,%rcx,4), %rax
leaq (%rax,%rax,4), %rax
movq 0x10(%rdi,%rax,8), %rcx
movq %rcx, 0x50(%rsp)
movups (%rdi,%rax,8), %xmm0
movups %xmm0, 0x40(%rsp)
movl %r12d, %ecx
movq %r11, 0x30(%rsp)
movl %r11d, %eax
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r15, %rdi
movq %rbx, %rsi
movq %r8, %rdx
movq %rax, %r8
callq 0x10a6e3
movl %eax, %ebp
movq (%r14), %rcx
cmpq 0x8(%r14), %rcx
jne 0x118894
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %ecx
cmovneq %rax, %rcx
movq %rcx, 0x8(%r14)
movq 0x10(%r14), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,8), %rsi
callq 0x2370
movq %rax, 0x10(%r14)
movq (%r14), %rcx
jmp 0x118898
movq 0x10(%r14), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, (%r14)
leaq (%rcx,%rcx,8), %rcx
movq %r13, (%rax,%rcx,8)
movl %r15d, 0x8(%rax,%rcx,8)
movl %ebx, 0xc(%rax,%rcx,8)
movl %r12d, 0x10(%rax,%rcx,8)
movq 0x30(%rsp), %rdx
movl %edx, 0x14(%rax,%rcx,8)
movl %ebp, 0x1c(%rax,%rcx,8)
movb 0x2f(%rsp), %sil
movb %sil, 0x28(%rax,%rcx,8)
movups 0x39(%rsp), %xmm0
movups 0x48(%rsp), %xmm1
movups %xmm0, 0x29(%rax,%rcx,8)
movups %xmm1, 0x38(%rax,%rcx,8)
cmpl %ebx, %r15d
ja 0x1188f9
cmpl %edx, %r12d
ja 0x1188f9
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x13385
jmp 0x1188ea