// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: detect_break_point_advance(ma_utg_t*, unsigned int, asg_t*, All_reads*, ma_sub_t*, ma_hit_t_alloc*, R_to_U*, kvec_asg_arc_t_warp*, int, int, unsigned char*, kvec_t_u64_warp*, kv_in_sub_t*, kvec_t_u64_warp*, int*, int*, double)
void detect_break_point_advance(ma_utg_t *u, uint32_t uID, asg_t* read_g, All_reads *RNF, ma_sub_t* coverage_cut, 
ma_hit_t_alloc* sources, R_to_U* ruIndex, kvec_asg_arc_t_warp* edge, int max_hang, int min_ovlp,
uint8_t* r_flag, kvec_t_u64_warp* d, kv_in_sub_t* depth_i, kvec_t_u64_warp* res, int* b_low_cov,
int* b_high_cov, double m_rate)
{
    if(u->n < 2 || u->m == 0) return;
    uint32_t k, l, c_beg;
    memset(r_flag, 0, read_g->n_seq);
    for (k = 0; k < u->n; k++) r_flag[u->a[k]>>33] = 1;

    d->a.n = 0;
    for (k = l = 0; k < u->n; k++)
    {
        c_beg = l;
        l += (uint32_t)u->a[k];
        get_break_point_cov_advance((uint64_t)(u->a[k])>>32, c_beg, read_g, RNF, sources, ruIndex, r_flag, d, u->len, u->circ, &uID);
    }
    
    for (k = l = 0; k < u->n; k++)
    {
        c_beg = l;
        l += (uint32_t)u->a[k];
        get_break_point_cov_advance((uint64_t)(u->a[k])>>32, c_beg, read_g, RNF, sources, ruIndex, r_flag, d, u->len, u->circ, NULL);
    }

    radix_sort_arch64(d->a.a, d->a.a + d->a.n);

    long long dp, o_dp;
    uint32_t idx, o_idx, dir, o_dir;
    in_sub_t* p = NULL;



    /*******************************for debug************************************/
    ///debug_break_point_advance(u, uID, read_g, RNF, sources, ruIndex, edge, r_flag);
    /*******************************for debug************************************/









    depth_i->n = 0;
    ///[start, end)
    ///for circle
    dp = 0; o_idx = 0; o_dir = 1;///means it is a beg 
    for (k = 0; k < d->a.n; k++)
    {
        o_dp = dp;
        ///if start = end, we should meet end first, otherwise it will have a bug
        if(d->a.a[k]&1) ++dp;
        else --dp;

        dir = d->a.a[k]&1; idx = d->a.a[k]>>2;
        if((idx - o_idx > 0) || (idx == o_idx && o_dir != dir))
        {
            if(b_low_cov)
            {
                ///merge
                if(o_dp >= (*b_low_cov) && depth_i->n > 0 && (int)depth_i->a[depth_i->n-1].dp >= (*b_low_cov))
                {
                    p = &(depth_i->a[depth_i->n-1]);
                    p->k_end = idx;
                    p->dp = o_dp;
                }
                else //insert new
                {
                    kv_pushp(in_sub_t, *depth_i, &p);
                    p->k_beg = o_idx;
                    p->k_end = idx;
                    p->dp = o_dp;
                }
            }

            if(b_high_cov)
            {
                if(o_dp <= (*b_high_cov) && depth_i->n > 0 && (int)depth_i->a[depth_i->n-1].dp <= (*b_high_cov))
                {
                    p = &(depth_i->a[depth_i->n-1]);
                    p->k_end = idx;
                    p->dp = o_dp;
                }
                else //insert new
                {
                    kv_pushp(in_sub_t, *depth_i, &p);
                    p->k_beg = o_idx;
                    p->k_end = idx;
                    p->dp = o_dp;
                }
            }
            
        } 
        o_idx = idx;
        o_dir = dir;
    }

    if(o_idx != u->len)
    {
        kv_pushp(in_sub_t, *depth_i, &p);
        p->k_beg = o_idx;
        p->k_end = u->len;
        p->dp = 0;
    }

    // if(b_high_cov)
    // {
    //     fprintf(stderr, "\n\n\n\n\n\n\n\n\n\n");
    //     fprintf(stderr, "uID: %u, u->n: %u, u->len: %u\n", uID, (uint32_t)u->n, (uint32_t)u->len);
    //     for (k = 0; k < depth_i->n; k++)
    //     {
    //         fprintf(stderr, "k: %u, k_beg: %lu, k_end: %lu, dp: %u\n", 
    //         k, depth_i->a[k].k_beg, depth_i->a[k].k_end, depth_i->a[k].dp);
    //     }
    // }
    

    uint32_t beg_idx, end_idx, cir_beg_idx, cir_end_idx, min, min_idx, cur_idx, i;
    beg_idx = end_idx = (uint32_t)-1;
    cir_beg_idx = cir_end_idx = (uint32_t)-1;
    uint64_t tmp;

    for (k = 0; k < depth_i->n; k++)
    {
        if(k > 0) 
        {
            if((b_low_cov && (int)depth_i->a[k-1].dp >= (*b_low_cov) && (int)depth_i->a[k].dp < (*b_low_cov)) ||
                (b_high_cov && (int)depth_i->a[k-1].dp <= (*b_high_cov) && (int)depth_i->a[k].dp > (*b_high_cov)))
            {
                beg_idx = k;
            }
        }

        if(k < depth_i->n-1)
        {
            if((b_low_cov && (int)depth_i->a[k].dp < (*b_low_cov) && (int)depth_i->a[k+1].dp >= (*b_low_cov)) || 
                (b_high_cov && (int)depth_i->a[k].dp > (*b_high_cov) && (int)depth_i->a[k+1].dp <= (*b_high_cov)))
            {
                end_idx = k;
                if(beg_idx == (uint32_t)-1) cir_end_idx = k;


                if(beg_idx != (uint32_t)-1 && end_idx >= beg_idx)
                {
                    min = min_idx = (uint32_t)-1;
                    for (i = beg_idx; i <= end_idx; i++)
                    {
                        // if(b_high_cov)
                        // {
                        //     fprintf(stderr, "+k_end: %lu, k_end: %lu, dp: %u\n", depth_i->a[i].k_beg, depth_i->a[i].k_end, depth_i->a[i].dp);
                        // }
                        if(depth_i->a[i].dp < min)
                        {
                            cur_idx = get_break_point_idx(u, RNF, r_flag, sources, read_g, ruIndex,
                                                    depth_i->a[i].k_beg, depth_i->a[i].k_end, m_rate);
                            if(cur_idx == (uint32_t)-1) continue;
                            min = depth_i->a[i].dp; min_idx = cur_idx;
                        }
                    }
                    if(min_idx != (uint32_t)-1)
                    {
                        //fprintf(stderr, "+uID: %u, min_idx: %u, k_beg: %lu, k_end: %lu\n", uID, min_idx, depth_i->a[min_idx].k_beg, depth_i->a[min_idx].k_end);
                        if(min_idx != (uint32_t)-1)
                        {
                            tmp = uID; tmp <<=32; tmp += min_idx;
                            kv_push(uint64_t, res->a, tmp);
                        }
                    } 
                }
                beg_idx = end_idx = (uint32_t)-1;
            }
        }
    }

    if(beg_idx != (uint32_t)-1 && end_idx == (uint32_t)-1) cir_beg_idx = beg_idx;

     if(u->circ && (cir_beg_idx != (uint32_t)-1 || cir_end_idx != (uint32_t)-1))
     {
        beg_idx = cir_beg_idx;
        end_idx = cir_end_idx;

        min = min_idx = (uint32_t)-1;
        if(beg_idx != (uint32_t)-1)
        {
            for (i = beg_idx; i < depth_i->n; i++)
            {
                // if(b_high_cov)
                // {
                //     fprintf(stderr, "-0-k_end: %lu, k_end: %lu, dp: %u\n", depth_i->a[i].k_beg, depth_i->a[i].k_end, depth_i->a[i].dp);
                // }
                if(depth_i->a[i].dp < min)
                {
                    // min = depth_i->a[i].dp;
                    // min_idx = i;
                    cur_idx = get_break_point_idx(u, RNF, r_flag, sources, read_g, ruIndex,
                                            depth_i->a[i].k_beg, depth_i->a[i].k_end, m_rate);
                    if(cur_idx == (uint32_t)-1) continue;
                    min = depth_i->a[i].dp; min_idx = cur_idx;
                }
            }
        }

        if(end_idx != (uint32_t)-1)
        {
            for (i = 0; i <= end_idx; i++)
            {
                // if(b_high_cov)
                // {
                //     fprintf(stderr, "-1-k_end: %lu, k_end: %lu, dp: %u\n", depth_i->a[i].k_beg, depth_i->a[i].k_end, depth_i->a[i].dp);
                // }
                if(depth_i->a[i].dp < min)
                {
                    cur_idx = get_break_point_idx(u, RNF, r_flag, sources, read_g, ruIndex,
                                            depth_i->a[i].k_beg, depth_i->a[i].k_end, m_rate);
                    if(cur_idx == (uint32_t)-1) continue;
                    min = depth_i->a[i].dp; min_idx = cur_idx;
                }
            }
        }

        if(min_idx != (uint32_t)-1)
        {
            ///fprintf(stderr, "-uID: %u, min_idx: %u, k_beg: %lu, k_end: %lu\n", uID, min_idx, depth_i->a[min_idx].k_beg, depth_i->a[min_idx].k_end);
            if(min_idx != (uint32_t)-1)
            {
                tmp = uID; tmp <<=32; tmp += min_idx;
                kv_push(uint64_t, res->a, tmp);
            }
        } 
     }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0xf0, %rsp
movq 0x58(%rbp), %rax
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movl 0x28(%rbp), %eax
movl 0x20(%rbp), %eax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x18(%rbp)
movl %esi, -0x1c(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movq %r9, -0x40(%rbp)
movsd %xmm0, -0x48(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x2, 0x10(%rax)
jb 0xf3a94
movq -0x18(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0xf3a99
jmp 0xf47f0
movq 0x30(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edx
xorl %esi, %esi
callq 0x2100
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0xf3aed
movq 0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl -0x4c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x21, %rcx
movb $0x1, (%rax,%rcx)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xf3abb
movq 0x38(%rbp), %rax
movq $0x0, (%rax)
movl $0x0, -0x50(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0xf3bad
movl -0x50(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x4c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
addl -0x50(%rbp), %eax
movl %eax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x4c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movl %eax, %edi
movl -0x54(%rbp), %eax
movl %eax, %esi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %r8
movq 0x10(%rbp), %r9
movq 0x30(%rbp), %r14
movq 0x38(%rbp), %rbx
movq -0x18(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %r11d
movq -0x18(%rbp), %rax
movl (%rax), %r10d
shrl $0x1f, %r10d
leaq -0x1c(%rbp), %rax
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movl %r10d, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0xf2680
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xf3b06
movl $0x0, -0x50(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0xf3c62
movl -0x50(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x4c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
addl -0x50(%rbp), %eax
movl %eax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x4c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movl %eax, %edi
movl -0x54(%rbp), %eax
movl %eax, %esi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %r8
movq 0x10(%rbp), %r9
movq 0x30(%rbp), %rbx
movq 0x38(%rbp), %r11
movq -0x18(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %r10d
movq -0x18(%rbp), %rax
movl (%rax), %eax
shrl $0x1f, %eax
xorl %r14d, %r14d
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
callq 0xf2680
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xf3bbb
movq 0x38(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x38(%rbp), %rax
movq 0x10(%rax), %rsi
movq 0x38(%rbp), %rax
movq (%rax), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0xc90e0
movq $0x0, -0x80(%rbp)
movq 0x40(%rbp), %rax
movq $0x0, (%rax)
movq $0x0, -0x60(%rbp)
movl $0x0, -0x70(%rbp)
movl $0x1, -0x78(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq 0x38(%rbp), %rcx
cmpq (%rcx), %rax
jae 0xf3fed
movq -0x60(%rbp), %rax
movq %rax, -0x68(%rbp)
movq 0x38(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x4c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
andq $0x1, %rax
cmpq $0x0, %rax
je 0xf3cf4
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0xf3d00
movq -0x60(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x60(%rbp)
movq 0x38(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x4c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
andq $0x1, %rax
movl %eax, -0x74(%rbp)
movq 0x38(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x4c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x2, %rax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
subl -0x70(%rbp), %eax
cmpl $0x0, %eax
ja 0xf3d4f
movl -0x6c(%rbp), %eax
cmpl -0x70(%rbp), %eax
jne 0xf3fd3
movl -0x78(%rbp), %eax
cmpl -0x74(%rbp), %eax
je 0xf3fd3
cmpq $0x0, 0x50(%rbp)
je 0xf3e90
movq -0x68(%rbp), %rax
movq 0x50(%rbp), %rcx
movslq (%rcx), %rcx
cmpq %rcx, %rax
jl 0xf3dd4
movq 0x40(%rbp), %rax
cmpq $0x0, (%rax)
jbe 0xf3dd4
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x40(%rbp), %rcx
movq (%rcx), %rcx
subq $0x1, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq 0x50(%rbp), %rcx
cmpl (%rcx), %eax
jl 0xf3dd4
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x40(%rbp), %rcx
movq (%rcx), %rcx
subq $0x1, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x68(%rbp), %rax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, (%rax)
jmp 0xf3e8e
jmp 0xf3dd6
movq 0x40(%rbp), %rax
movq (%rax), %rax
movq 0x40(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0xf3e44
movq 0x40(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xf3e06
movq 0x40(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0xb0(%rbp)
jmp 0xf3e14
movl $0x2, %eax
movq %rax, -0xb0(%rbp)
jmp 0xf3e14
movq -0xb0(%rbp), %rcx
movq 0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x40(%rbp), %rax
imulq $0x18, 0x8(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq 0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x40(%rbp), %rdx
movq (%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, (%rdx)
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movl -0x70(%rbp), %eax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x6c(%rbp), %eax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x68(%rbp), %rax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, (%rax)
jmp 0xf3e90
cmpq $0x0, 0x58(%rbp)
je 0xf3fd1
movq -0x68(%rbp), %rax
movq 0x58(%rbp), %rcx
movslq (%rcx), %rcx
cmpq %rcx, %rax
jg 0xf3f15
movq 0x40(%rbp), %rax
cmpq $0x0, (%rax)
jbe 0xf3f15
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x40(%rbp), %rcx
movq (%rcx), %rcx
subq $0x1, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq 0x58(%rbp), %rcx
cmpl (%rcx), %eax
jg 0xf3f15
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x40(%rbp), %rcx
movq (%rcx), %rcx
subq $0x1, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x68(%rbp), %rax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, (%rax)
jmp 0xf3fcf
jmp 0xf3f17
movq 0x40(%rbp), %rax
movq (%rax), %rax
movq 0x40(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0xf3f85
movq 0x40(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xf3f47
movq 0x40(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0xb8(%rbp)
jmp 0xf3f55
movl $0x2, %eax
movq %rax, -0xb8(%rbp)
jmp 0xf3f55
movq -0xb8(%rbp), %rcx
movq 0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x40(%rbp), %rax
imulq $0x18, 0x8(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq 0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x40(%rbp), %rdx
movq (%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, (%rdx)
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movl -0x70(%rbp), %eax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x6c(%rbp), %eax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x68(%rbp), %rax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, (%rax)
jmp 0xf3fd1
jmp 0xf3fd3
movl -0x6c(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x74(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xf3cb5
movl -0x70(%rbp), %eax
movq -0x18(%rbp), %rcx
movl (%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
je 0xf40c6
jmp 0xf4006
movq 0x40(%rbp), %rax
movq (%rax), %rax
movq 0x40(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0xf4074
movq 0x40(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xf4036
movq 0x40(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0xc0(%rbp)
jmp 0xf4044
movl $0x2, %eax
movq %rax, -0xc0(%rbp)
jmp 0xf4044
movq -0xc0(%rbp), %rcx
movq 0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x40(%rbp), %rax
imulq $0x18, 0x8(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq 0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x40(%rbp), %rdx
movq (%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, (%rdx)
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movl -0x70(%rbp), %eax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x80(%rbp), %rax
movl $0x0, (%rax)
movl $0xffffffff, -0x88(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x84(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x90(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x8c(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq 0x40(%rbp), %rcx
cmpq (%rcx), %rax
jae 0xf4498
cmpl $0x0, -0x4c(%rbp)
jbe 0xf41a2
cmpq $0x0, 0x50(%rbp)
je 0xf4153
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x4c(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq 0x50(%rbp), %rcx
cmpl (%rcx), %eax
jl 0xf4153
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x4c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq 0x50(%rbp), %rcx
cmpl (%rcx), %eax
jl 0xf4197
cmpq $0x0, 0x58(%rbp)
je 0xf41a0
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x4c(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq 0x58(%rbp), %rcx
cmpl (%rcx), %eax
jg 0xf41a0
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x4c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq 0x58(%rbp), %rcx
cmpl (%rcx), %eax
jle 0xf41a0
movl -0x4c(%rbp), %eax
movl %eax, -0x84(%rbp)
jmp 0xf41a2
movl -0x4c(%rbp), %eax
movq 0x40(%rbp), %rcx
movq (%rcx), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0xf4488
cmpq $0x0, 0x50(%rbp)
je 0xf41fd
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x4c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq 0x50(%rbp), %rcx
cmpl (%rcx), %eax
jge 0xf41fd
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x4c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq 0x50(%rbp), %rcx
cmpl (%rcx), %eax
jge 0xf424d
cmpq $0x0, 0x58(%rbp)
je 0xf4486
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x4c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq 0x58(%rbp), %rcx
cmpl (%rcx), %eax
jle 0xf4486
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x4c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq 0x58(%rbp), %rcx
cmpl (%rcx), %eax
jg 0xf4486
movl -0x4c(%rbp), %eax
movl %eax, -0x88(%rbp)
cmpl $-0x1, -0x84(%rbp)
jne 0xf4268
movl -0x4c(%rbp), %eax
movl %eax, -0x90(%rbp)
cmpl $-0x1, -0x84(%rbp)
je 0xf4472
movl -0x88(%rbp), %eax
cmpl -0x84(%rbp), %eax
jb 0xf4472
movl $0xffffffff, -0x98(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x94(%rbp) # imm = 0xFFFFFFFF
movl -0x84(%rbp), %eax
movl %eax, -0xa0(%rbp)
movl -0xa0(%rbp), %eax
cmpl -0x88(%rbp), %eax
ja 0xf438d
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xa0(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl -0x94(%rbp), %eax
jae 0xf4377
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq 0x30(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %r8
movq 0x10(%rbp), %r9
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xa0(%rbp), %r10d
imulq $0x18, %r10, %r10
addq %r10, %rax
movq 0x8(%rax), %rax
movl %eax, %r10d
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xa0(%rbp), %r11d
imulq $0x18, %r11, %r11
addq %r11, %rax
movq 0x10(%rax), %rax
movsd -0x48(%rbp), %xmm0
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0xf2cc0
movl %eax, -0x9c(%rbp)
cmpl $-0x1, -0x9c(%rbp)
jne 0xf434e
jmp 0xf4379
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xa0(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x94(%rbp)
movl -0x9c(%rbp), %eax
movl %eax, -0x98(%rbp)
jmp 0xf4379
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0xf42a7
cmpl $-0x1, -0x98(%rbp)
je 0xf4470
cmpl $-0x1, -0x98(%rbp)
je 0xf446e
movl -0x1c(%rbp), %eax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
shlq $0x20, %rax
movq %rax, -0xa8(%rbp)
movl -0x98(%rbp), %eax
addq -0xa8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq 0x48(%rbp), %rax
movq (%rax), %rax
movq 0x48(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0xf4448
movq 0x48(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xf4407
movq 0x48(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0xc8(%rbp)
jmp 0xf4415
movl $0x2, %eax
movq %rax, -0xc8(%rbp)
jmp 0xf4415
movq -0xc8(%rbp), %rcx
movq 0x48(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x48(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x48(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0xa8(%rbp), %rdx
movq 0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x48(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movq %rdx, (%rax,%rcx,8)
jmp 0xf446e
jmp 0xf4470
jmp 0xf4472
movl $0xffffffff, -0x88(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x84(%rbp) # imm = 0xFFFFFFFF
jmp 0xf4488
jmp 0xf448a
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xf40f5
cmpl $-0x1, -0x84(%rbp)
je 0xf44b6
cmpl $-0x1, -0x88(%rbp)
jne 0xf44b6
movl -0x84(%rbp), %eax
movl %eax, -0x8c(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0xf47f0
cmpl $-0x1, -0x8c(%rbp)
jne 0xf44de
cmpl $-0x1, -0x90(%rbp)
je 0xf47f0
movl -0x8c(%rbp), %eax
movl %eax, -0x84(%rbp)
movl -0x90(%rbp), %eax
movl %eax, -0x88(%rbp)
movl $0xffffffff, -0x98(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x94(%rbp) # imm = 0xFFFFFFFF
cmpl $-0x1, -0x84(%rbp)
je 0xf460c
movl -0x84(%rbp), %eax
movl %eax, -0xa0(%rbp)
movl -0xa0(%rbp), %eax
movq 0x40(%rbp), %rcx
cmpq (%rcx), %rax
jae 0xf460a
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xa0(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl -0x94(%rbp), %eax
jae 0xf45f4
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq 0x30(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %r8
movq 0x10(%rbp), %r9
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xa0(%rbp), %r10d
imulq $0x18, %r10, %r10
addq %r10, %rax
movq 0x8(%rax), %rax
movl %eax, %r10d
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xa0(%rbp), %r11d
imulq $0x18, %r11, %r11
addq %r11, %rax
movq 0x10(%rax), %rax
movsd -0x48(%rbp), %xmm0
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0xf2cc0
movl %eax, -0x9c(%rbp)
cmpl $-0x1, -0x9c(%rbp)
jne 0xf45cb
jmp 0xf45f6
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xa0(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x94(%rbp)
movl -0x9c(%rbp), %eax
movl %eax, -0x98(%rbp)
jmp 0xf45f6
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0xf4523
jmp 0xf460c
cmpl $-0x1, -0x88(%rbp)
je 0xf470b
movl $0x0, -0xa0(%rbp)
movl -0xa0(%rbp), %eax
cmpl -0x88(%rbp), %eax
ja 0xf4709
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xa0(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl -0x94(%rbp), %eax
jae 0xf46f3
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq 0x30(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %r8
movq 0x10(%rbp), %r9
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xa0(%rbp), %r10d
imulq $0x18, %r10, %r10
addq %r10, %rax
movq 0x8(%rax), %rax
movl %eax, %r10d
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xa0(%rbp), %r11d
imulq $0x18, %r11, %r11
addq %r11, %rax
movq 0x10(%rax), %rax
movsd -0x48(%rbp), %xmm0
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0xf2cc0
movl %eax, -0x9c(%rbp)
cmpl $-0x1, -0x9c(%rbp)
jne 0xf46ca
jmp 0xf46f5
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xa0(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x94(%rbp)
movl -0x9c(%rbp), %eax
movl %eax, -0x98(%rbp)
jmp 0xf46f5
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0xf4623
jmp 0xf470b
cmpl $-0x1, -0x98(%rbp)
je 0xf47ee
cmpl $-0x1, -0x98(%rbp)
je 0xf47ec
movl -0x1c(%rbp), %eax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
shlq $0x20, %rax
movq %rax, -0xa8(%rbp)
movl -0x98(%rbp), %eax
addq -0xa8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq 0x48(%rbp), %rax
movq (%rax), %rax
movq 0x48(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0xf47c6
movq 0x48(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xf4785
movq 0x48(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0xd0(%rbp)
jmp 0xf4793
movl $0x2, %eax
movq %rax, -0xd0(%rbp)
jmp 0xf4793
movq -0xd0(%rbp), %rcx
movq 0x48(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x48(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x48(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0xa8(%rbp), %rdx
movq 0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x48(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movq %rdx, (%rax,%rcx,8)
jmp 0xf47ec
jmp 0xf47ee
jmp 0xf47f0
addq $0xf0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nopl (%rax)