// File: chhylp123[P]hifiasm/Purge_Dups.cpp
// Function: init_hap_alignment_struct_pip(hap_alignment_struct_pip*, unsigned int, unsigned int, ma_ug_t*, asg_t*, ma_hit_t_alloc*, ma_hit_t_alloc*, R_to_U*, ma_sub_t*, unsigned long*, float, int, int, float, hap_overlaps_list*, hap_cov_t*)
void init_hap_alignment_struct_pip(hap_alignment_struct_pip* x, uint32_t num_threads, uint32_t n_seq,
ma_ug_t *ug, asg_t *read_g,  ma_hit_t_alloc* sources, ma_hit_t_alloc* reverse_sources, R_to_U* ruIndex, ma_sub_t *coverage_cut, 
uint64_t* position_index, float Hap_rate, int max_hang, int min_ovlp, float chain_rate, hap_overlaps_list* all_ovlp, hap_cov_t *cov)
{
    uint32_t i;
    x->num_threads = num_threads;
    x->buf = (hap_alignment_struct*)malloc(sizeof(hap_alignment_struct)*x->num_threads);
    for (i = 0; i < x->num_threads; i++)
    {
        init_hap_alignment_struct(&(x->buf[i]), n_seq);
    }

    x->ug = ug;
    x->read_g = read_g;
    x->sources = sources;
    x->reverse_sources = reverse_sources;
    x->ruIndex = ruIndex;
    x->coverage_cut = coverage_cut;
    x->position_index = position_index;
    x->Hap_rate = Hap_rate;
    x->max_hang = max_hang;
    x->min_ovlp = min_ovlp;
    x->chain_rate = chain_rate;
    x->all_ovlp = all_ovlp;
    x->cov = cov;
    long long sc = -1;
    if(asm_opt.hom_global_coverage_set) {
        sc = asm_opt.hom_global_coverage*1.75;
    }
    else {
        if(asm_opt.hom_global_coverage > 0){
            sc = ((int)(((double)asm_opt.hom_global_coverage)/((double)HOM_PEAK_RATE)))*1.75;
        }
    }
    if(sc <= 0) sc = -1;
    x->hh = init_pip_hh(read_g, reverse_sources, coverage_cut, sc);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movl 0x38(%rbp), %eax
movl 0x30(%rbp), %eax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movss %xmm0, -0x2c(%rbp)
movss %xmm1, -0x30(%rbp)
movl -0xc(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
imulq $0xf0, %rax, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jae 0x16fda7
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movl -0x34(%rbp), %eax
imulq $0xf0, %rax, %rax
addq %rax, %rdi
movl -0x10(%rbp), %esi
callq 0x16f940
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x16fd74
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x28(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x28(%rax)
movq 0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x30(%rax)
movq 0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x38(%rax)
movq 0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x40(%rax)
movq 0x28(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x48(%rax)
movss -0x2c(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x50(%rax)
movl 0x30(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x54(%rax)
movl 0x38(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x58(%rax)
movss -0x30(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x5c(%rax)
movq 0x40(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x60(%rax)
movq 0x48(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x70(%rax)
movq $-0x1, -0x40(%rbp)
leaq 0x2549a6(%rip), %rax    # 0x3c47f8
cmpl $0x0, 0x148(%rax)
je 0x16fe81
leaq 0x254996(%rip), %rax    # 0x3c47f8
cvtsi2sdl 0x144(%rax), %xmm0
movsd 0x21a43e(%rip), %xmm1   # 0x38a2b0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x40(%rbp)
jmp 0x16fecb
leaq 0x254970(%rip), %rax    # 0x3c47f8
cmpl $0x0, 0x144(%rax)
jle 0x16fec9
leaq 0x254960(%rip), %rax    # 0x3c47f8
cvtsi2sdl 0x144(%rax), %xmm0
movsd 0x216998(%rip), %xmm1   # 0x386840
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
cvtsi2sd %eax, %xmm0
movsd 0x21a3f4(%rip), %xmm1   # 0x38a2b0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x40(%rbp)
jmp 0x16fecb
cmpq $0x0, -0x40(%rbp)
jg 0x16feda
movq $-0x1, -0x40(%rbp)
movq -0x20(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq 0x20(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0x16fb70
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
addq $0x40, %rsp
popq %rbp
retq