// File: chhylp123[P]hifiasm/Correct.cpp
// Function: cigar_gen(overlap_region*, Candidates_list*, ul_ov_t*, unsigned long, unsigned long, unsigned long, ul_idx_t const*, hpc_t*, All_reads*, char*, UC_Read*, bit_extz_t*, double, long, unsigned long, ul_ov_t*)
uint64_t cigar_gen(overlap_region *z, Candidates_list *cl, ul_ov_t *ov, uint64_t on, uint64_t qn, uint64_t wl,  
const ul_idx_t *uref, hpc_t *hpc_g, All_reads *rref, char* qstr, UC_Read *tu, bit_extz_t *exz, double e_rate, 
int64_t ql, uint64_t rid, ul_ov_t *des)
{
    if(on <= 0) return 0;
    uint64_t i; 
    // des[0] = ov[0]; 
    // for (i = m = 1; i < on; i++) {
    //     fusion_merge();
    // }
    

    for (i = 0; i < on; i++) {
        assert((i<=0)||(ov[i].qs > ov[i-1].qe));
        sub_ciagar_gen(z, cl, ov[i].qs, ov[i].qe, wl, uref, hpc_g, rref, qstr, tu, exz, e_rate, ql, rid);
    }
    return on;
    // uint64_t i, qs = (uint64_t)-1, qe = (uint64_t)-1;
    // for (i = 0; i < on && ov[i].qn == qn; i++) {
    //     assert((i<=0)||(ov[i].qs >= ov[i-1].qe));
    //     if(ov[i].qs <= qe && qe != (uint64_t)-1) {
    //         qe = ov[i].qe;
    //     } else {
    //         if(qs != (uint64_t)-1) sub_ciagar_gen(z, cl, qs, qe, wl, uref, hpc_g, rref, qstr, tu, exz, e_rate, ql, rid);
    //         qs = ov[i].qs; qe = ov[i].qe;
    //     }
    // }
    // if(qs != (uint64_t)-1) sub_ciagar_gen(z, cl, qs, qe, wl, uref, hpc_g, rref, qstr, tu, exz, e_rate, ql, rid);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x90, %rsp
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdx, -0x40(%rbp)
movq %rcx, -0x48(%rbp)
movq %r8, -0x50(%rbp)
movq %r9, -0x58(%rbp)
movsd %xmm0, -0x60(%rbp)
cmpq $0x0, -0x48(%rbp)
ja 0x59e57
movq $0x0, -0x28(%rbp)
jmp 0x59f61
movq $0x0, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x48(%rbp), %rax
jae 0x59f59
movb $0x1, %al
cmpq $0x0, -0x68(%rbp)
movb %al, -0x69(%rbp)
jbe 0x59ea4
movq -0x40(%rbp), %rax
imulq $0x1c, -0x68(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq -0x40(%rbp), %rcx
movq -0x68(%rbp), %rdx
subq $0x1, %rdx
imulq $0x1c, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
seta %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0x59ead
jmp 0x59eaf
jmp 0x59ece
leaq 0x329598(%rip), %rdi    # 0x38344e
leaq 0x32845e(%rip), %rsi    # 0x38231b
movl $0x3993, %edx           # imm = 0x3993
leaq 0x3295a5(%rip), %rcx    # 0x38346e
callq 0x2130
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rax
imulq $0x1c, -0x68(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, %edx
movq -0x40(%rbp), %rax
imulq $0x1c, -0x68(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, %ecx
movq -0x58(%rbp), %r8
movq 0x10(%rbp), %r9
movq 0x18(%rbp), %r12
movq 0x20(%rbp), %r15
movq 0x28(%rbp), %r14
movq 0x30(%rbp), %rbx
movq 0x38(%rbp), %r11
movsd -0x60(%rbp), %xmm0
movq 0x40(%rbp), %r10
movq 0x48(%rbp), %rax
movq %r12, (%rsp)
movq %r15, 0x8(%rsp)
movq %r14, 0x10(%rsp)
movq %rbx, 0x18(%rsp)
movq %r11, 0x20(%rsp)
movq %r10, 0x28(%rsp)
movq %rax, 0x30(%rsp)
callq 0x59650
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x59e5f
movq -0x48(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nopw %cs:(%rax,%rax)