// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/hic.cpp
// Function: get_trans_rate_function_advance(ha_ug_index*, kvec_pe_hit*, hc_links*, bubble_type*, H_partition*, signed char*, mc_gg_status*, trans_idx*)
int get_trans_rate_function_advance(ha_ug_index* idx, kvec_pe_hit* hits, hc_links* link, bubble_type* bub, 
H_partition* hap, int8_t *s, mc_gg_status *sa, trans_idx* dis)
{
    kvec_t(uint64_t) buf;
    kv_init(buf);
    uint64_t beg, end, cnt[2];
    uint64_t k, i, t_d, r_idx, f_idx, med = (uint64_t)-1;
    uint32_t is_s;
    // int beg_status, end_status;

    buf.n = 0;
    for (k = 0; k < hits->a.n; ++k) 
    {
        beg = ((hits->a.a[k].s<<1)>>(64 - idx->uID_bits));
        end = ((hits->a.a[k].e<<1)>>(64 - idx->uID_bits));

        if(IF_HOM(beg, *bub)) continue;
        if(IF_HOM(end, *bub)) continue;
        if(is_hom_hit(hits->a.a[k])) continue;


        t_d = get_hic_distance(&(hits->a.a[k]), link, idx, NULL);
        if(t_d == (uint64_t)-1) continue;
        // if(beg == end)
        // {
        //     t_d = (t_d << 1);
        // }
        // else
        // {
        //     beg_status = (hap? get_phase_status(hap, beg):s[beg]);
        //     if(beg_status != 1 && beg_status != -1) continue;
        //     end_status = (hap? get_phase_status(hap, end):s[end]);
        //     if(end_status != 1 && end_status != -1) continue;
        //     if(beg_status != end_status)
        //     {
        //         t_d = (t_d << 1) + 1; 
        //     }
        //     else
        //     {
        //         t_d = (t_d << 1);
        //     }            
        // }
        is_s = is_same_phase(beg, end, hap, s, sa);
        if(is_s == (uint32_t)-1) continue;
        t_d = (t_d << 1) + 1 - is_s;

        kv_push(uint64_t, buf, t_d); 
    }

    ///might have bias, we may not use right linkage larger than trans rc linkage
    radix_sort_hc64(buf.a, buf.a+buf.n);

    for (k = 0, r_idx = f_idx = (uint64_t)-1; k < buf.n; k++)
    {
        if((buf.a[k]&1) == 0) r_idx = k;
        if((buf.a[k]&1) == 1) f_idx = k;
    }
    buf.n = MIN(r_idx, f_idx);

    
    trans_p_t* p = NULL;
    dis->n = 0;
    uint64_t bin_size = MIN(2250, buf.n>>8), m;
    if(bin_size == 0)
    {
        for (i = 8; i > 0; i--)
        {
            bin_size = buf.n>>i;
            if(bin_size > 0) break;
        }
        if(bin_size == 0) bin_size = buf.n;
    }
    i = 0;
    while (i < buf.n)
    {
        kv_pushp(trans_p_t, *dis, &p);
        p->beg = i;

        cnt[0] = cnt[1] = 0;
        k = MIN(i+bin_size, buf.n);
        for (; i < k; i++)
        {
            cnt[buf.a[i]&1]++;
        }
        p->end = i;
        p->cnt_0 = cnt[0];
        p->cnt_1 = cnt[1];
    }

    i = m = 0; med = (uint64_t)-1;
    while(i < dis->n)
    {
        if(dis->a[i].cnt_0 > 0 && dis->a[i].cnt_1 > 0)
        {
            dis->a[m] = dis->a[i];
            m++;
            i++;
            continue;
        }

        if(med == (uint64_t)-1) med = buf.a[dis->a[i].beg]>>1;
        k = i; cnt[0] = cnt[1] = 0;
        for (; i < dis->n; i++)
        {
            cnt[0] += dis->a[i].cnt_0;
            cnt[1] += dis->a[i].cnt_1;
            if(cnt[0] > 0 && cnt[1] > 0) break;
        }

        if(i < dis->n)
        {
            dis->a[m].cnt_0 = cnt[0];
            dis->a[m].cnt_1 = cnt[1];
            dis->a[m].beg = dis->a[k].beg;
            dis->a[m].end = dis->a[i].end;
            m++;
            i++;
            continue;
        }

        cnt[0] -= dis->a[k].cnt_0;
        cnt[1] -= dis->a[k].cnt_1;
        while (1)
        {
            cnt[0] += dis->a[k].cnt_0;
            cnt[1] += dis->a[k].cnt_1;
            if(cnt[0] > 0 && cnt[1] > 0) break;

            if(k == 0)
            {
                k = (uint64_t)-1;
                break;
            } 
            k--;
        }

        if(k != (uint64_t)-1)
        {
            dis->a[m].cnt_0 = cnt[0];
            dis->a[m].cnt_1 = cnt[1];
            dis->a[m].end = dis->a[i-1].end;
            continue;
        }
        m = 0;
        break;
    }
    dis->n = m;
    if(dis->n == 0)
    {
        kv_destroy(buf);
        return 0;
    } 

    for (i = 0; i < dis->n; i++)
    {
        dis->a[i].beg = buf.a[dis->a[i].beg]>>1;
        dis->a[i].end = (buf.a[dis->a[i].end-1]>>1);
    }

    for (i = 0; i < dis->n - 1; i++)
    {
        dis->a[i].end += ((dis->a[i+1].beg - dis->a[i].end)/2);
        dis->a[i+1].beg = dis->a[i].end;
    }

    // for (i = 0; i < dis->n; i++)
    // {
    //     if(i > 0 && dis->a[i].beg != dis->a[i-1].end) fprintf(stderr, "ERROR: dis->a[i].beg: %lu, dis->a[i-1].end: %lu\n", dis->a[i].beg, dis->a[i-1].end);
    //     fprintf(stderr, "beg: %lu, end: %lu, cnt_0: %lu, cnt_1: %lu, error_rate: %f\n", 
    //     dis->a[i].beg, dis->a[i].end, dis->a[i].cnt_0, dis->a[i].cnt_1, (double)(dis->a[i].cnt_1)/(double)(dis->a[i].cnt_1 + dis->a[i].cnt_0));
    // }
    
    LeastSquare_advance(dis, idx, med);
    // fprintf(stderr, "idx->a: %f, idx->b: %f, idx->frac: %f, med: %lu\n", 
    // (double)idx->a, (double)idx->b, (double)idx->frac, med);

    dis->max = dis->a[dis->n-1].end;


    
    if(idx->a < 0) idx->a = 0;
    if(idx->a == 0)
    {
        idx->b = MAX((((double)(dis->a[dis->n-1].cnt_1))/((double)(dis->a[dis->n-1].cnt_0 + dis->a[dis->n-1].cnt_1))), idx->b);
    }
    if(idx->b < 0 && get_trans(idx, dis->max) < 0)
    {
        idx->b = ((double)(dis->a[dis->n-1].cnt_1))/((double)(dis->a[dis->n-1].cnt_0 + dis->a[dis->n-1].cnt_1));
    } 

    // fprintf(stderr, "idx->a: %f, idx->b: %f, idx->frac: %f, med: %lu\n", 
    // (double)idx->a, (double)idx->b, (double)idx->frac, med);





    buf.n = 0;
    for (k = 0; k < hits->a.n; ++k) 
    {
        beg = ((hits->a.a[k].s<<1)>>(64 - idx->uID_bits));
        end = ((hits->a.a[k].e<<1)>>(64 - idx->uID_bits));

        if(IF_HOM(beg, *bub)) continue;
        if(IF_HOM(end, *bub)) continue;
        if(is_hom_hit(hits->a.a[k])) continue;
        if(beg == end) continue;

        t_d = get_hic_distance(&(hits->a.a[k]), link, idx, NULL);
        if(t_d == (uint64_t)-1) continue;
        kv_push(uint64_t, buf, t_d); 
    }

    ///might have bias, we may not use right linkage larger than trans rc linkage
    radix_sort_hc64(buf.a, buf.a+buf.n);
    if(buf.n == 0)
    {
        dis->med = 0;
    }
    else
    {
        dis->med = ((buf.n&1)?buf.a[buf.n>>1]:((buf.a[buf.n>>1]+buf.a[(buf.n>>1)-1])/2));
    }

    // fprintf(stderr, "dis->med: %lu\n", dis->med);
    
    kv_destroy(buf);
    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, 0x50(%rsp)
movq %r8, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
cmpq $0x0, (%rsi)
movq %rcx, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdi, 0x8(%rsp)
je 0x14b7c4
movq %rcx, %r8
movq %rdi, %rdx
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %r14d, %r14d
movq $0x0, 0x30(%rsp)
xorl %ebx, %ebx
movq 0x10(%rsi), %rdi
movq (%rdi,%r12), %r15
addq %r15, %r15
xorl %ecx, %ecx
subb 0x18(%rdx), %cl
shrq %cl, %r15
movq 0x8(%rdi,%r12), %r13
addq %r13, %r13
shrq %cl, %r13
movq (%r8), %rcx
movq 0x80(%r8), %rax
movl (%rcx,%r15,4), %r9d
incq %rax
cmpq %r9, %rax
jb 0x14b7b2
movl (%rcx,%r13,4), %ecx
cmpq %rcx, %rax
jb 0x14b7b2
cmpq $-0x1, 0x10(%rdi,%r12)
je 0x14b7b2
addq %r12, %rdi
movq 0x40(%rsp), %rsi
xorl %ecx, %ecx
callq 0x143e3e
cmpq $-0x1, %rax
je 0x14b7a3
movq %rax, 0x38(%rsp)
movq %r15, %rdi
movq %r13, %rsi
movq 0x48(%rsp), %rdx
movq 0x50(%rsp), %rcx
movq 0xb0(%rsp), %r8
callq 0x14b57e
cmpl $-0x1, %eax
je 0x14b7a3
movl %eax, %r15d
movq 0x30(%rsp), %rax
cmpq %rax, %r14
jne 0x14b778
leaq (%rax,%rax), %r13
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %r13
leaq (,%r13,8), %rsi
movq %rbx, %rdi
callq 0x2370
movq %rax, %rbx
movq %r13, 0x30(%rsp)
movq 0x18(%rsp), %r8
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x38(%rsp), %rax
leaq 0x1(,%rax,2), %rax
movl %r15d, %ecx
subq %rcx, %rax
movq %rax, (%rbx,%r14,8)
incq %r14
jmp 0x14b7b2
movq 0x18(%rsp), %r8
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
incq %rbp
addq $0x20, %r12
cmpq (%rsi), %rbp
jb 0x14b6b2
jmp 0x14b7d2
xorl %ebx, %ebx
movq $0x0, 0x30(%rsp)
xorl %r14d, %r14d
movq 0xb8(%rsp), %rbp
leaq (%rbx,%r14,8), %rsi
movq %rbx, %rdi
callq 0x13180d
testq %r14, %r14
je 0x14b811
movq $-0x1, %r15
xorl %ecx, %ecx
movq $-0x1, %rax
testb $0x1, (%rbx,%rcx,8)
cmoveq %rcx, %rax
cmovneq %rcx, %r15
incq %rcx
cmpq %rcx, %r14
jne 0x14b7fb
jmp 0x14b81f
movq $-0x1, %rax
movq $-0x1, %r15
cmpq %r15, %rax
cmovbq %rax, %r15
movq $0x0, 0x8(%rbp)
movq %r15, %rax
shrq $0x8, %rax
cmpq $0x8ca00, %r15          # imm = 0x8CA00
movl $0x8ca, %r14d           # imm = 0x8CA
cmovbq %rax, %r14
testq %r14, %r14
movq 0x8(%rsp), %rsi
jne 0x14b86f
movl $0x8, %ecx
movq %r15, %r14
shrq %cl, %r14
testq %r14, %r14
jne 0x14b868
decq %rcx
jne 0x14b855
xorl %r14d, %r14d
testq %r14, %r14
cmoveq %r15, %r14
testq %r15, %r15
je 0x14b921
xorl %r12d, %r12d
movl $0x2, %r13d
xorpd %xmm0, %xmm0
movq 0x10(%rbp), %rax
cmpq %rax, 0x8(%rbp)
jne 0x14b8bc
leaq (%rax,%rax), %rcx
testq %rax, %rax
cmoveq %r13, %rcx
movq %rcx, 0x10(%rbp)
movq (%rbp), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,4), %rsi
callq 0x2370
xorpd %xmm0, %xmm0
movq 0x8(%rsp), %rsi
movq %rax, (%rbp)
movq (%rbp), %rax
movq 0x8(%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbp)
leaq (%rcx,%rcx,4), %rcx
movq %r12, (%rax,%rcx,8)
leaq (%r12,%r14), %rdx
cmpq %r15, %rdx
cmovaeq %r15, %rdx
movapd %xmm0, 0x20(%rsp)
cmpq %rdx, %r12
jae 0x14b8fe
movl (%rbx,%r12,8), %edi
andl $0x1, %edi
incq 0x20(%rsp,%rdi,8)
incq %r12
cmpq %r12, %rdx
jne 0x14b8ea
leaq (%rax,%rcx,8), %rax
movq %r12, 0x8(%rax)
movq 0x20(%rsp), %rcx
movq %rcx, 0x18(%rax)
movq 0x28(%rsp), %rcx
movq %rcx, 0x20(%rax)
cmpq %r15, %r12
jb 0x14b885
movq 0x8(%rbp), %rdi
movq $-0x1, %rdx
testq %rdi, %rdi
je 0x14bb29
xorpd %xmm0, %xmm0
xorl %eax, %eax
xorl %ecx, %ecx
movq (%rbp), %rsi
leaq (%rcx,%rcx,4), %r8
leaq (%rsi,%r8,8), %r11
cmpq $0x0, 0x18(%r11)
je 0x14b9c8
leaq (,%rcx,8), %r8
leaq (%r8,%r8,4), %r9
leaq (,%rax,8), %r8
leaq (%r8,%r8,4), %r8
cmpq $0x0, 0x20(%r11)
je 0x14b9c8
movq 0x20(%r11), %rdi
movq %rdi, 0x20(%rsi,%r8)
movupd (%r11), %xmm1
movupd 0x10(%r11), %xmm2
movupd %xmm2, 0x10(%rsi,%r8)
movupd %xmm1, (%rsi,%r8)
incq %rax
incq %rcx
movq 0x8(%rbp), %rdi
cmpq %rdi, %rcx
jae 0x14bb2f
movq (%rbp), %rsi
leaq (%rcx,%rcx,4), %r10
leaq (%rsi,%r10,8), %r11
leaq 0x28(%r9), %r10
addq $0x28, %r8
cmpq $0x0, 0x40(%rsi,%r9)
movq %r10, %r9
jne 0x14b968
addq %rsi, %r10
movq %r10, %r11
cmpq $-0x1, %rdx
jne 0x14b9d8
movq (%r11), %rdx
movq (%rbx,%rdx,8), %rdx
shrq %rdx
movapd %xmm0, 0x20(%rsp)
leaq (%rcx,%rcx,4), %r14
cmpq %rdi, %rcx
setb %r12b
jae 0x14ba0d
movq 0x18(%rsi,%r14,8), %r9
movq 0x20(%rsi,%r14,8), %r8
testq %r9, %r9
setne %r10b
testq %r8, %r8
setne %r15b
testb %r15b, %r10b
je 0x14ba25
movq %rcx, %r10
jmp 0x14ba55
xorl %r8d, %r8d
xorl %r9d, %r9d
movq %rcx, %rdi
movq %r9, 0x20(%rsp)
movq %r8, 0x28(%rsp)
movq %rdi, %r10
jmp 0x14ba92
leaq (%rsi,%r14,8), %r13
addq $0x48, %r13
movq %rcx, %r10
incq %r10
cmpq %rdi, %r10
setb %r12b
jae 0x14ba16
addq (%r13), %r8
leaq 0x28(%r13), %r15
addq -0x8(%r13), %r9
movq %r15, %r13
je 0x14ba30
movq %r15, %r13
testq %r8, %r8
je 0x14ba30
movq %r9, 0x20(%rsp)
movq %r8, 0x28(%rsp)
testb %r12b, %r12b
je 0x14ba92
leaq (%rax,%rax,4), %rcx
movq %r9, 0x18(%rsi,%rcx,8)
movq %r8, 0x20(%rsi,%rcx,8)
movq (%r11), %rdi
movq %rdi, (%rsi,%rcx,8)
leaq (%r10,%r10,4), %rdi
movq 0x8(%rsi,%rdi,8), %rdi
movq %rdi, 0x8(%rsi,%rcx,8)
incq %rax
incq %r10
jmp 0x14bb12
subq 0x18(%rsi,%r14,8), %r9
movq %r9, 0x20(%rsp)
subq 0x20(%rsi,%r14,8), %r8
movq %r8, 0x28(%rsp)
addq 0x20(%rsi,%r14,8), %r8
addq 0x18(%rsi,%r14,8), %r9
je 0x14bab7
testq %r8, %r8
jne 0x14bae6
leaq (%rsi,%r14,8), %rdi
addq $-0x8, %rdi
subq $0x1, %rcx
jb 0x14badf
addq (%rdi), %r8
leaq -0x28(%rdi), %r11
addq -0x8(%rdi), %r9
movq %r11, %rdi
je 0x14babf
movq %r11, %rdi
testq %r8, %r8
je 0x14babf
jmp 0x14bae6
movq $-0x1, %rcx
movq %r9, 0x20(%rsp)
movq %r8, 0x28(%rsp)
cmpq $-0x1, %rcx
je 0x14bb2d
leaq (%rax,%rax,4), %rcx
movq %r9, 0x18(%rsi,%rcx,8)
movq %r8, 0x20(%rsi,%rcx,8)
leaq (%r10,%r10,4), %rdi
movq -0x20(%rsi,%rdi,8), %rdi
movq %rdi, 0x8(%rsi,%rcx,8)
movq 0x8(%rsp), %rsi
movq 0x8(%rbp), %rdi
movq %r10, %rcx
cmpq %rdi, %r10
jb 0x14b93d
jmp 0x14bb34
xorl %eax, %eax
jmp 0x14bb34
xorl %eax, %eax
movq 0x8(%rsp), %rsi
movq %rax, 0x8(%rbp)
testq %rax, %rax
je 0x14be0f
movq (%rbp), %rcx
addq $0x8, %rcx
movq %rax, %r9
movq -0x8(%rcx), %rdi
movq (%rcx), %r8
movq (%rbx,%rdi,8), %rdi
shrq %rdi
movq %rdi, -0x8(%rcx)
movq -0x8(%rbx,%r8,8), %rdi
shrq %rdi
movq %rdi, (%rcx)
addq $0x28, %rcx
decq %r9
jne 0x14bb4c
decq %rax
je 0x14bb9f
movq (%rbp), %rcx
addq $0x28, %rcx
movq -0x20(%rcx), %r8
movq (%rcx), %rdi
subq %r8, %rdi
shrq %rdi
addq %r8, %rdi
movq %rdi, -0x20(%rcx)
movq %rdi, (%rcx)
addq $0x28, %rcx
decq %rax
jne 0x14bb7f
movq %rbp, %rdi
callq 0x143f52
movq 0x8(%rsp), %rdx
movq (%rbp), %rax
movq 0x8(%rbp), %rcx
leaq (%rcx,%rcx,4), %rsi
movq -0x20(%rax,%rsi,8), %rcx
movq %rcx, 0x18(%rbp)
fldt 0x80(%rdx)
fldz
fucomi %st(1), %st
fstp %st(1)
jbe 0x14bbd7
fld %st(0)
fstpt 0x80(%rdx)
leaq (%rax,%rsi,8), %rax
fldt 0x80(%rdx)
fucomi %st(1), %st
movq 0x18(%rsp), %r9
movq 0x10(%rsp), %r10
jne 0x14bc5f
jp 0x14bc5f
movq -0x8(%rax), %rsi
movq %rsi, %xmm0
movq 0xd963e(%rip), %xmm1    # 0x225240
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0xd9642(%rip), %xmm2    # 0x225250
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addq -0x10(%rax), %rsi
addsd %xmm0, %xmm3
movq %rsi, %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd %xmm2, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd %xmm1, %xmm3
movsd %xmm3, 0x70(%rsp)
fldl 0x70(%rsp)
fldt 0x90(%rdx)
fxch %st(1)
fucomi %st(1), %st
fxch %st(1)
fcmovnb %st(1), %st
fstp %st(1)
fstpt 0x90(%rdx)
fldt 0x90(%rdx)
fxch %st(2)
fucompi %st(2), %st
jbe 0x14bd15
movq %rcx, 0x68(%rsp)
xorl %esi, %esi
testq %rcx, %rcx
sets %sil
fildll 0x68(%rsp)
leaq 0xe3360(%rip), %rcx     # 0x22efe8
fadds (%rcx,%rsi,4)
fldt 0xa0(%rdx)
fdivrp %st, %st(1)
fmulp %st, %st(1)
faddp %st, %st(1)
fstpl 0x60(%rsp)
xorpd %xmm0, %xmm0
ucomisd 0x60(%rsp), %xmm0
fldz
fldz
fxch %st(1)
jbe 0x14bd15
fstp %st(0)
fstp %st(0)
movq -0x8(%rax), %rcx
movq %rcx, %xmm0
movq 0xd957e(%rip), %xmm1    # 0x225240
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0xd9582(%rip), %xmm2    # 0x225250
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
addq -0x10(%rax), %rcx
movq %rcx, %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd %xmm2, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd %xmm1, %xmm3
movsd %xmm3, 0x58(%rsp)
fldl 0x58(%rsp)
fstpt 0x90(%rdx)
fldz
fldz
fxch %st(1)
fstp %st(0)
fstp %st(0)
cmpq $0x0, (%r10)
je 0x14be14
xorl %r13d, %r13d
xorl %r12d, %r12d
xorl %r14d, %r14d
movq 0x10(%r10), %rdi
movq (%rdi,%r13), %rax
addq %rax, %rax
xorl %ecx, %ecx
subb 0x18(%rdx), %cl
shrq %cl, %rax
movq 0x8(%rdi,%r13), %r11
addq %r11, %r11
shrq %cl, %r11
movq (%r9), %rsi
movq 0x80(%r9), %rcx
movl (%rsi,%rax,4), %r8d
incq %rcx
cmpq %r8, %rcx
jb 0x14bdfd
movl (%rsi,%r11,4), %esi
cmpq %rsi, %rcx
jb 0x14bdfd
cmpq $-0x1, 0x10(%rdi,%r13)
je 0x14bdfd
cmpq %r11, %rax
je 0x14bdfd
addq %r13, %rdi
movq 0x40(%rsp), %rsi
xorl %ecx, %ecx
callq 0x143e3e
cmpq $-0x1, %rax
je 0x14bdee
movq %rax, %r15
movq 0x30(%rsp), %rax
cmpq %rax, %r14
jne 0x14bdd6
movq %r14, 0x38(%rsp)
leaq (%rax,%rax), %r14
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %r14
leaq (,%r14,8), %rsi
movq %rbx, %rdi
callq 0x2370
movq %rax, %rbx
movq %r14, 0x30(%rsp)
movq 0x38(%rsp), %r14
movq 0x18(%rsp), %r9
movq 0x10(%rsp), %r10
movq 0x8(%rsp), %rdx
movq %r15, (%rbx,%r14,8)
incq %r14
jmp 0x14bdfd
movq 0x18(%rsp), %r9
movq 0x10(%rsp), %r10
movq 0x8(%rsp), %rdx
incq %r12
addq $0x20, %r13
cmpq (%r10), %r12
jb 0x14bd2c
jmp 0x14be17
xorl %r14d, %r14d
jmp 0x14be4d
xorl %r14d, %r14d
leaq (%rbx,%r14,8), %rsi
movq %rbx, %rdi
callq 0x13180d
testq %r14, %r14
je 0x14be41
movl %r14d, %ecx
shrq %r14
movq (%rbx,%r14,8), %rax
testb $0x1, %cl
jne 0x14be43
addq -0x8(%rbx,%r14,8), %rax
shrq %rax
jmp 0x14be43
xorl %eax, %eax
movq %rax, 0x20(%rbp)
movl $0x1, %r14d
movq %rbx, %rdi
callq 0x2220
movl %r14d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq