// File: /workspace/github_cpp_makefile_star2_O1/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 0x112e05
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 0x112ca3
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 0x112d09
movq %r11, %rbp
movl $0x1, %eax
movq %rax, %r11
cmpq %rax, %rcx
je 0x112d10
movslq (%rdx,%r11,4), %rax
leaq (%rax,%rax,4), %rax
addq 0x20(%rdi,%rax,8), %r10
leaq 0x1(%r11), %rax
cmpq %rsi, %r10
jb 0x112ce6
decq %rax
jmp 0x112d13
movb $0x1, %sil
xorl %eax, %eax
jmp 0x112d1d
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 0x105f44
movl %eax, %ebp
movq 0x8(%r14), %rax
cmpq %rax, (%r14)
jne 0x112d9e
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmovneq %rcx, %rax
movq %rax, 0x8(%r14)
movq 0x10(%r14), %rdi
shlq $0x3, %rax
leaq (%rax,%rax,8), %rsi
callq 0x2370
movq %rax, 0x10(%r14)
movq (%r14), %rax
movq 0x10(%r14), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r14)
leaq (%rax,%rax,8), %rax
movq %r13, (%rcx,%rax,8)
movl %r15d, 0x8(%rcx,%rax,8)
movl %ebx, 0xc(%rcx,%rax,8)
movl %r12d, 0x10(%rcx,%rax,8)
movq 0x30(%rsp), %rdx
movl %edx, 0x14(%rcx,%rax,8)
movl %ebp, 0x1c(%rcx,%rax,8)
movb 0x2f(%rsp), %sil
movb %sil, 0x28(%rcx,%rax,8)
movups 0x39(%rsp), %xmm0
movups 0x48(%rsp), %xmm1
movups %xmm0, 0x29(%rcx,%rax,8)
movups %xmm1, 0x38(%rcx,%rax,8)
cmpl %ebx, %r15d
ja 0x112e06
cmpl %edx, %r12d
ja 0x112e06
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x13a2f
jmp 0x112df7
nopl (%rax)