// File: 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:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
cmpq $0x0, -0x20(%rbp)
jg 0x185d5f
jmp 0x186003
movq -0x8(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq (%rcx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movb 0x12(%rax), %al
movb %al, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq (%rcx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
movl %eax, -0x6c(%rbp)
movl %eax, -0x70(%rbp)
movq -0x8(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq (%rcx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movl %eax, -0x64(%rbp)
movl %eax, -0x68(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
movq $0x0, -0x88(%rbp)
movq $0x0, -0x80(%rbp)
movq -0x80(%rbp), %rax
cmpq -0x20(%rbp), %rax
jge 0x185e51
movq -0x8(%rbp), %rax
movq -0x18(%rbp), %rcx
movq -0x80(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
movl %eax, -0x70(%rbp)
movq -0x8(%rbp), %rax
movq -0x18(%rbp), %rcx
movq -0x80(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movl %eax, -0x68(%rbp)
movq -0x8(%rbp), %rax
movq -0x18(%rbp), %rcx
movq -0x80(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rax
addq -0x78(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0x185dd6
movq $0x0, -0x80(%rbp)
movq -0x80(%rbp), %rax
cmpq -0x20(%rbp), %rax
jge 0x185eb1
movq -0x8(%rbp), %rax
movq -0x18(%rbp), %rcx
movq -0x80(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rax
addq -0x88(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq -0x78(%rbp), %rcx
shrq %rcx
cmpq %rcx, %rax
jb 0x185ea1
jmp 0x185eb1
jmp 0x185ea3
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0x185e59
movq -0x80(%rbp), %rax
cmpq -0x20(%rbp), %rax
jl 0x185ec7
movq -0x20(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x80(%rbp)
movq -0x8(%rbp), %rax
movq -0x18(%rbp), %rcx
movq -0x80(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x48(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x40(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movl -0x70(%rbp), %eax
movl %eax, %edi
movl -0x6c(%rbp), %eax
movl %eax, %esi
movq -0x28(%rbp), %rdx
movl -0x68(%rbp), %eax
movl %eax, %ecx
movl -0x64(%rbp), %eax
movl %eax, %r8d
movq -0x30(%rbp), %r9
xorl %eax, %eax
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
callq 0x170800
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x185fad
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x185f6f
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x90(%rbp)
jmp 0x185f7d
movl $0x2, %eax
movq %rax, -0x90(%rbp)
jmp 0x185f7d
movq -0x90(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rax
imulq $0x48, 0x8(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rcx
movq (%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, (%rcx)
imulq $0x48, %rax, %rax
addq %rax, %rdi
leaq -0x78(%rbp), %rsi
movl $0x48, %edx
callq 0x2180
movl -0x70(%rbp), %eax
cmpl -0x6c(%rbp), %eax
ja 0x185feb
movl -0x68(%rbp), %eax
cmpl -0x64(%rbp), %eax
jbe 0x186003
movq 0x23dfee(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x203ab3(%rip), %rsi    # 0x389aaf
movb $0x0, %al
callq 0x22a0
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax)