// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/hic.cpp
// Function: get_alignment_debug(char*, unsigned long, unsigned long, kvec_vote*, ha_ug_index const*, unsigned long, unsigned long)
void get_alignment_debug(char *r, uint64_t len, uint64_t k_mer, kvec_vote* buf, const ha_ug_index* idx, uint64_t buf_iter, uint64_t rid)
{
    uint64_t i, j, l = 0,  m, skip, *pos_list = NULL, cnt, rev, self_p, ref_p, uID;
    uint64_t x[4], mask = (1ULL<<k_mer) - 1, shift = k_mer - 1, hash;
    /****************************may have bugs********************************/
    /**
    ///buf->a.n = 0;
    uint64_t k_len, c_sfx, k;
    for (i = l = 0, x[0] = x[1] = x[2] = x[3] = 0; i < len; ++i) {
        int c = seq_nt4_table[(uint8_t)r[i]];
        ///c = 00, 01, 10, 11
        if (c < 4) { // not an "N" base
            ///x[0] & x[1] are the forward k-mer
            ///x[2] & x[3] are the reverse complementary k-mer
            x[0] = (x[0] << 1 | (c&1))  & mask;
            x[1] = (x[1] << 1 | (c>>1)) & mask;
            x[2] = x[2] >> 1 | (uint64_t)(1 - (c&1))  << shift;
            x[3] = x[3] >> 1 | (uint64_t)(1 - (c>>1)) << shift;
            if (++l >= k_mer)
            {
                hash = hc_hash_long(x, &skip, k_mer);
                if(skip == (uint64_t)-1) continue;
                cnt = get_hc_pt1_count((ha_ug_index*)idx, hash, &pos_list);
                if(cnt > idx->hap_cnt || cnt <= 0) continue;

                if(cnt > 1)
                {
                    for (j = 0; j < cnt; j++)
                    {
                        uID = (pos_list[j] << 1) >> (64 - idx->uID_bits);
                        for (k = j + 1; k < cnt; k++)
                        {
                            if(uID == ((pos_list[k] << 1) >> (64 - idx->uID_bits))) break;
                        }
                        if(k < cnt) break;
                    }

                    if(j < cnt) continue;
                }
                // if(cnt > 0) fprintf(stderr, "+i: %lu, l: %lu, cnt: %lu\n", i, l, cnt);
                get_longest_hit(r, len, k_mer, i, skip, buf, idx, pos_list, cnt, &c_sfx);
                // if(cnt > 0) fprintf(stderr, "c_sfx: %lu\n", c_sfx);
                if(c_sfx != (uint64_t)-1)
                {
                    k_len = c_sfx;
                    if((k_len + 1) >= k_mer)
                    {
                        l = 0, x[0] = x[1] = x[2] = x[3] = 0;
                        i = i + k_len - (k_mer - 1);
                    }
                    else
                    {
                        ///l = i - (i + k_len - (k_mer - 1));
                        l = k_mer - k_len - 1;
                    }  
                }
                // if(cnt > 0) fprintf(stderr, "-i: %lu, l: %lu\n", i, l);
            }
            
        } else l = 0, x[0] = x[1] = x[2] = x[3] = 0; // if there is an "N", restart
    }
    **/

    s_hit *p = NULL; uint64_t u_len;
    ///buf->a.n = 0;
    for (i = l = 0, x[0] = x[1] = x[2] = x[3] = 0; i < len; ++i) {
        int c = seq_nt4_table[(uint8_t)r[i]];
        ///c = 00, 01, 10, 11
        if (c < 4) { // not an "N" base
            ///x[0] & x[1] are the forward k-mer
            ///x[2] & x[3] are the reverse complementary k-mer
            x[0] = (x[0] << 1 | (c&1))  & mask;
            x[1] = (x[1] << 1 | (c>>1)) & mask;
            x[2] = x[2] >> 1 | (uint64_t)(1 - (c&1))  << shift;
            x[3] = x[3] >> 1 | (uint64_t)(1 - (c>>1)) << shift;
            if (++l >= k_mer)
            {
                hash = hc_hash_long(x, &skip, k_mer);
                if(skip == (uint64_t)-1) continue;
                /*******************************for debug************************************/
                // if(debug_hash_value(r, i, k_mer) != hash)
                // {
                //     fprintf(stderr, "ERROR\n");
                // }
                /*******************************for debug************************************/
                cnt = get_hc_pt1_count((ha_ug_index*)idx, hash, &pos_list);
                if(cnt > idx->hap_cnt) continue;
                if(cnt != 1) continue; ///might be able to be disabled in future

                
                for (j = 0; j < cnt; j++)
                {
                    kv_pushp(s_hit, buf->a, &p);
                    rev = (pos_list[j]>>63) != skip;
                    self_p = i;
                    ref_p = pos_list[j] & idx->pos_mode;
                    uID = (pos_list[j] << 1) >> (64 - idx->uID_bits);
                    u_len = idx->ug->u.a[uID].len;
                    if(rev) ref_p = u_len - 1 - (ref_p + 1 - k_mer);
                    p->off_cnt = self_p | ((uint64_t)k_mer << 32); ///high bits should be the legnth

                    p->ref = ref_p >= self_p? (ref_p-self_p) 
                                    : (self_p-ref_p) + ((uint64_t)1 << (idx->pos_bits - 1));
                    p->ref = (rev << 63)|(pos_list[j] & idx->uID_mode)|(p->ref&idx->pos_mode);


                    /*******************************for debug************************************/
                    // if(check_exact_match(r, i + 1 - k_mer, len,
                    //                     idx->ug->u.a[uID].s, ref_p  + 1 - k_mer, u_len, k_mer, rev, 0) != k_mer
                    //     ||
                    //    check_exact_match(r, i, len,
                    //                     idx->ug->u.a[uID].s, ref_p, u_len, k_mer, rev, 1) != k_mer)
                    // {
                    //     fprintf(stderr, "ERROR\n");
                    // }
                    /*******************************for debug************************************/
                }
                
                if(cnt == 1)
                {
                    ///uint64_t debug_right = 0, debug_left = 0, debug_len;

                    j = check_exact_match(r, self_p + 1, len, idx->ug->u.a[uID].s, ref_p + 1, u_len, len, rev, 0);
                    
                    ///debug_right = j;
                    ///if(j == 0) continue;
                    if((j + 1) >= k_mer)
                    {
                        l = 0, x[0] = x[1] = x[2] = x[3] = 0;
                        i = i + j - (k_mer - 1);
                    }
                    else
                    {
                        ///l = i - (i + j - (k_mer - 1));
                        l = k_mer - j -1;
                    }
                    buf->a.a[buf->a.n-1].off_cnt += ((uint64_t)j << 32) + j;

                    if(self_p >= k_mer && ref_p >= k_mer)
                    {
                        j = check_exact_match(r, self_p - k_mer, len, idx->ug->u.a[uID].s, 
                                                                ref_p - k_mer, u_len, len, rev, 1);
                        buf->a.a[buf->a.n-1].off_cnt += ((uint64_t)j << 32);
                        ///debug_left = j;
                    }


                    // debug_len = check_exact_match(r, self_p + debug_right, len, idx->ug->u.a[uID].s, 
                    // ref_p + debug_right, u_len, len, rev, 1);
                    // if(debug_len!= (debug_left + debug_right + k_mer))
                    // {
                    //     fprintf(stderr, "debug_len: %lu, debug_left: %lu, debug_right: %lu\n",
                    //     debug_len, debug_left, debug_right);
                    // }
                }
                
            }
            
        } else l = 0, x[0] = x[1] = x[2] = x[3] = 0; // if there is an "N", restart
    }
    /****************************may have bugs********************************/
    
    if(buf->a.n - buf_iter == 0) return;
    if(buf->a.n - buf_iter > 1) radix_sort_hc_s_hit_an1(buf->a.a + buf_iter, buf->a.a + buf->a.n);


    uint64_t cur_ref_p, thres = (len * HIC_R_E_RATE) + 1, index_beg, ovlp;
    /****************************may have bugs********************************/
    uint64_t maxLen = 0, max_i = (uint64_t)-1;
    /****************************may have bugs********************************/
    i = m = buf_iter;
    while (i < buf->a.n)
    {
        interpret_pos(idx, &buf->a.a[i], &rev, &uID, &ref_p, &self_p, &cnt, NULL);
        cur_ref_p = buf->a.a[i].ref;
        index_beg = i;
        while ((i < buf->a.n) && 
                ((buf->a.a[i].ref>>(idx->pos_bits-1)) == (cur_ref_p>>(idx->pos_bits-1))) && 
               (buf->a.a[i].ref - cur_ref_p <= thres))
        {
            i++;
        }
        if(i - index_beg > 1)
        {
            radix_sort_hc_s_hit_an2(buf->a.a + index_beg, buf->a.a + i);//sort by self_p
        }
        ovlp = collect_votes(buf->a.a + index_beg, i - index_beg);
        buf->a.a[m] = buf->a.a[i - 1];
        buf->a.a[m].off_cnt = (buf->a.a[m].off_cnt << 32)>>32;
        buf->a.a[m].off_cnt += ((uint64_t)ovlp<<32);
        m++;
        /****************************may have bugs********************************/
        if(maxLen < (ovlp&((uint64_t)65535))) maxLen = (ovlp&((uint64_t)65535)), max_i = m;
        /****************************may have bugs********************************/
    }
    buf->a.n = m; 
    /****************************may have bugs********************************/
    ///compress_mapped_pos_advance(idx, buf, buf_iter, (k_mer * 0.1) > 0? (k_mer * 0.1) : 1);
    compress_mapped_pos_debug(idx, buf, buf_iter, max_i, thres);
    /****************************may have bugs********************************/
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %r9, 0x28(%rsp)
movq %r8, 0x58(%rsp)
movq %rcx, %r8
movq %rdx, %r11
movq %rsi, %r13
movq $-0x1, %r10
movl %r11d, %ecx
shlq %cl, %r10
xorpd %xmm0, %xmm0
movapd %xmm0, 0x70(%rsp)
movapd %xmm0, 0x60(%rsp)
testq %rsi, %rsi
movq %r8, 0x10(%rsp)
je 0x137305
notq %r10
leaq -0x1(%r11), %rax
movq %rax, 0x98(%rsp)
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rbx
movq 0x70(%rsp), %r9
movq 0x78(%rsp), %r15
movq %r11, %rax
shlq $0x20, %rax
movq %rax, 0xb0(%rsp)
leaq 0x1(%rdi), %rax
movq %rax, 0xa0(%rsp)
xorl %r14d, %r14d
leaq 0xf6f11(%rip), %r12     # 0x22da10
movq $0x0, 0x20(%rsp)
movq $0x0, 0x90(%rsp)
movq %r13, 0x18(%rsp)
movq %r11, 0x38(%rsp)
movq %rdi, 0x30(%rsp)
movq %r10, 0x48(%rsp)
movzbl (%rdi,%r14), %eax
movzbl (%r12,%rax), %eax
cmpq $0x3, %rax
ja 0x136bf6
movq %r9, %rdx
movl %eax, %ebp
andl $0x1, %ebp
leaq (,%rsi,2), %rsi
addq %rbp, %rsi
andq %r10, %rsi
movq %rsi, 0x60(%rsp)
addq %rbx, %rbx
shrl %eax
orq %rax, %rbx
andq %r10, %rbx
movq %rbx, 0x68(%rsp)
xorl $0x1, %ebp
movq 0x98(%rsp), %rcx
shlq %cl, %rbp
shrq %rdx
movq %rbp, %r9
orq %rdx, %r9
movq %r9, 0x70(%rsp)
movq %r15, %rdx
shrq %rdx
movl $0x1, %r15d
subl %eax, %r15d
shlq %cl, %r15
orq %rdx, %r15
movq %r15, 0x78(%rsp)
movq 0x20(%rsp), %rcx
incq %rcx
movq %rcx, 0x20(%rsp)
cmpq %r11, %rcx
jb 0x136c15
cmpq %r15, %rbx
jne 0x136bc0
movq $-0x1, %rdx
cmpq %r9, %rsi
je 0x136bc6
setae %al
movzbl %al, %edx
cmpq $-0x1, %rdx
movq %rsi, 0x40(%rsp)
movq %r9, 0x8(%rsp)
je 0x136c2c
movq %rdx, %rax
shlq $0x4, %rax
cmpq $0x20, %r11
ja 0x136c38
movq 0x60(%rsp,%rax), %r9
shlq $0x20, %r9
orq 0x68(%rsp,%rax), %r9
jmp 0x136cc9
movapd %xmm0, 0x70(%rsp)
movapd %xmm0, 0x60(%rsp)
xorl %esi, %esi
xorl %ebx, %ebx
xorl %r9d, %r9d
xorl %r15d, %r15d
movq $0x0, 0x20(%rsp)
movq %r14, %rbp
incq %rbp
movq %rbp, %r14
cmpq %r13, %rbp
jb 0x136b28
jmp 0x137305
movq $-0x1, %r9
jmp 0x136cc9
movq 0x60(%rsp,%rax), %rcx
movq 0x68(%rsp,%rax), %rax
movq %rdx, %rsi
movq %rcx, %rdx
notq %rdx
shlq $0x15, %rcx
addq %rdx, %rcx
movq %rcx, %rdx
shrq $0x18, %rdx
xorq %rcx, %rdx
imulq $0x109, %rdx, %rcx      # imm = 0x109
movq %rcx, %rdx
shrq $0xe, %rdx
xorq %rcx, %rdx
leaq (%rdx,%rdx,4), %rcx
leaq (%rdx,%rcx,4), %rcx
movq %rcx, %rdx
shrq $0x1c, %rdx
xorq %rcx, %rdx
movq %rax, %rcx
notq %rcx
shlq $0x15, %rax
addq %rcx, %rax
movq %rax, %rcx
shrq $0x18, %rcx
xorq %rax, %rcx
imulq $0x109, %rcx, %rax      # imm = 0x109
movq %rax, %rcx
shrq $0xe, %rcx
xorq %rax, %rcx
leaq (%rcx,%rcx,4), %rax
leaq (%rcx,%rax,4), %rax
movq %rax, %rcx
shrq $0x1c, %rcx
xorq %rax, %rcx
addq %rdx, %rcx
movq %rsi, %rdx
movq %rcx, %r9
shlq $0x1f, %r9
addq %rcx, %r9
cmpq $-0x1, %rdx
je 0x136d68
movq %rdx, 0x50(%rsp)
movq 0x58(%rsp), %rax
movb 0x50(%rax), %cl
movq $-0x1, %r8
shlq %cl, %r8
notq %r8
movq 0x78(%rax), %rax
andq %r9, %r8
shlq $0x5, %r8
movq (%rax,%r8), %rsi
movq 0x10(%rsi), %rdx
xorl %r10d, %r10d
movl $0x0, %edi
testq %rdx, %rdx
je 0x136d7d
movb (%rsi), %cl
movl $0x1, %edi
shll %cl, %edi
movq %r9, %r11
shrq $0xc, %r11
imull $0x9e3779b9, %r11d, %r11d # imm = 0x9E3779B9
negb %cl
shrl %cl, %r11d
leal -0x1(%rdi), %ecx
movq 0x8(%rsi), %r13
movl %r11d, %r12d
movl %r12d, %ebp
shrl $0x5, %ebp
movl (%r13,%rbp,4), %ebp
btl %r12d, %ebp
jae 0x136d73
movl %r12d, %ebp
shlq $0x4, %rbp
movq (%rdx,%rbp), %rbp
xorq %r9, %rbp
cmpq $0x1000, %rbp           # imm = 0x1000
jb 0x136d70
incl %r12d
andl %ecx, %r12d
cmpl %r11d, %r12d
jne 0x136d33
jmp 0x136d73
movq %r14, %rbp
jmp 0x13705f
movl %r12d, %edi
movq 0x18(%rsp), %r13
movq 0x38(%rsp), %r11
testq %rdx, %rdx
je 0x136d8d
movb (%rsi), %cl
movl $0x1, %r10d
shll %cl, %r10d
cmpl %r10d, %edi
jne 0x136d9f
xorl %r12d, %r12d
movq 0x48(%rsp), %r10
jmp 0x136e20
addq %r8, %rax
movl %edi, %ecx
shlq $0x4, %rcx
movq 0x8(%rdx,%rcx), %r8
leaq (,%r8,8), %r9
addq 0x10(%rax), %r9
movq %r9, 0x90(%rsp)
movq (%rdx,%rcx), %r12
movl $0xfff, %ecx            # imm = 0xFFF
andq %rcx, %r12
cmpq %rcx, %r12
movq 0x48(%rsp), %r10
jne 0x136e20
cmpl 0x18(%rax), %edi
jne 0x136de2
movq 0x8(%rax), %r12
jmp 0x136e1d
testq %rdx, %rdx
je 0x136df4
movb (%rsi), %cl
movl $0x1, %r9d
shll %cl, %r9d
jmp 0x136df7
xorl %r9d, %r9d
incl %edi
cmpl %r9d, %edi
je 0x136ddc
movq 0x8(%rsi), %rcx
movl %edi, %r9d
shrl $0x5, %r9d
movl (%rcx,%r9,4), %ecx
btl %edi, %ecx
jae 0x136de2
movl %edi, %eax
shlq $0x4, %rax
movq 0x8(%rdx,%rax), %r12
subq %r8, %r12
movq 0x8(%rsp), %r9
cmpq $0x1, %r12
movq 0x10(%rsp), %r8
movq 0x40(%rsp), %rsi
movq 0x50(%rsp), %rdx
jne 0x13702d
movq 0x58(%rsp), %rax
cmpq $0x0, 0x48(%rax)
je 0x13702d
movq 0x8(%r8), %rax
cmpq %rax, (%r8)
jne 0x136e8a
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r8)
movq 0x10(%r8), %rdi
shlq $0x4, %rsi
callq 0x2370
movq 0x50(%rsp), %rdx
xorpd %xmm0, %xmm0
movq 0x10(%rsp), %r8
movq %rax, 0x10(%r8)
movq %r14, %r11
orq 0xb0(%rsp), %r11
movq (%r8), %r10
movq 0x10(%r8), %rdi
leaq 0x1(%r10), %rax
movq %rax, (%r8)
shlq $0x4, %r10
movq 0x90(%rsp), %rax
movq (%rax), %rax
movq %rax, %r9
shrq $0x3f, %r9
movq 0x58(%rsp), %rbp
movq 0x30(%rbp), %r8
movq %r8, %r13
andq %rax, %r13
addq %rax, %rax
movb 0x18(%rbp), %sil
xorl %ecx, %ecx
subb %sil, %cl
shrq %cl, %rax
movq (%rbp), %rcx
movq 0x10(%rcx), %rcx
leaq (%rax,%rax,4), %rax
movq %rax, 0x88(%rsp)
movl (%rcx,%rax,8), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %r13, %rsi
notq %rsi
addq 0x98(%rsp), %rsi
addq %rax, %rsi
cmpq %rdx, %r9
cmoveq %r13, %rsi
movq %r11, 0x8(%rdi,%r10)
movq %rsi, %r11
subq %r14, %r11
movq %rax, 0xa8(%rsp)
jae 0x136f37
movq %r14, %r13
subq %rsi, %r13
movb 0x28(%rbp), %cl
decb %cl
movl $0x1, %r11d
shlq %cl, %r11
addq %r13, %r11
movq 0x18(%rsp), %r13
addq %r10, %rdi
xorl %ecx, %ecx
cmpq %rdx, %r9
setne %cl
movq %r11, (%rdi)
shlq $0x3f, %rcx
movq 0x20(%rbp), %r10
movq %rdx, %rax
movq 0x90(%rsp), %rdx
andq (%rdx), %r10
orq %rcx, %r10
andq %r11, %r8
orq %r10, %r8
movq %r8, (%rdi)
cmpq $0x1, %r12
jne 0x137041
leaq 0x1(%r14), %r8
leaq 0x1(%rsi), %rdi
movq (%rbp), %rcx
movq 0x10(%rcx), %rcx
movq 0x88(%rsp), %rdx
movq 0x20(%rcx,%rdx,8), %rcx
movq %r9, 0x88(%rsp)
cmpq %rax, %r9
movq %rax, %rdx
jne 0x13706e
testq %r13, %r13
movq 0xa8(%rsp), %rax
jle 0x137112
cmpq %r13, %r8
jge 0x137112
movl $0x0, %r9d
cmpq %rax, %rdi
jge 0x137124
leaq 0x2(%r14), %rdi
movq 0xa0(%rsp), %r8
addq %r14, %r8
leaq 0x2(%rsi), %r10
leaq (%rcx,%rsi), %r11
incq %r11
xorl %r12d, %r12d
movb (%r8,%r12), %r9b
cmpb (%r11,%r12), %r9b
jne 0x137117
leaq 0x1(%r12), %r9
cmpq %r13, %r9
jge 0x137124
leaq (%rdi,%r12), %r13
cmpq 0x18(%rsp), %r13
movq 0x18(%rsp), %r13
jge 0x137124
addq %r10, %r12
cmpq %rax, %r12
movq %r9, %r12
jl 0x136fed
jmp 0x137124
movq %r14, %rbp
movq 0x30(%rsp), %rdi
leaq 0xf69d4(%rip), %r12     # 0x22da10
jmp 0x136c18
movq %r14, %rbp
movq 0x10(%rsp), %r8
movq 0x38(%rsp), %r11
movq 0x30(%rsp), %rdi
movq 0x48(%rsp), %r10
leaq 0xf69b1(%rip), %r12     # 0x22da10
movq 0x40(%rsp), %rsi
movq 0x8(%rsp), %r9
jmp 0x136c18
testq %r13, %r13
movq 0xa8(%rsp), %rax
jle 0x137112
cmpq %r13, %r8
jge 0x137112
movl $0x0, %r9d
cmpq %rax, %rdi
jge 0x137124
leaq 0x2(%r14), %rdi
movq 0xa0(%rsp), %r8
addq %r14, %r8
leaq 0x2(%rsi), %r10
movq %rax, %r9
subq %rsi, %r9
leaq (%rcx,%r9), %r11
addq $-0x2, %r11
xorl %r12d, %r12d
movsbl (%r8,%r12), %r9d
movzbl (%r11), %r13d
leaq 0xf6945(%rip), %rbp     # 0x22da10
movzbl (%rbp,%r13), %r13d
leaq 0xf7f76(%rip), %rbp     # 0x22f04e
movzbl (%r13,%rbp), %ebp
cmpl %ebp, %r9d
jne 0x13711c
leaq 0x1(%r12), %r9
movq 0x18(%rsp), %r13
cmpq %r13, %r9
jge 0x137124
leaq (%rdi,%r12), %r13
cmpq 0x18(%rsp), %r13
movq 0x18(%rsp), %r13
jge 0x137124
addq %r10, %r12
decq %r11
cmpq %rax, %r12
movq %r9, %r12
jl 0x1370bb
jmp 0x137124
xorl %r9d, %r9d
jmp 0x137124
movq %r12, %r9
jmp 0x137124
movq %r12, %r9
movq 0x18(%rsp), %r13
leaq 0x1(%r9), %rdi
movq 0x38(%rsp), %r11
cmpq %r11, %rdi
jae 0x13714a
movq %r9, %rdx
notq %rdx
addq %r11, %rdx
movq %rdx, 0x20(%rsp)
movq 0x50(%rsp), %rdx
movq %r14, %rbp
jmp 0x137183
movq %r14, %rdi
subq %r11, %rdi
leaq (%rdi,%r9), %rbp
incq %rbp
movapd %xmm0, 0x70(%rsp)
movapd %xmm0, 0x60(%rsp)
movq $0x0, 0x40(%rsp)
xorl %ebx, %ebx
movq $0x0, 0x8(%rsp)
xorl %r15d, %r15d
movq $0x0, 0x20(%rsp)
movq 0x30(%rsp), %rdi
leaq 0xf6881(%rip), %r12     # 0x22da10
movq %r9, %r8
shlq $0x20, %r8
addq %r9, %r8
movq 0x10(%rsp), %r9
movq (%r9), %r10
movq 0x10(%r9), %r9
shlq $0x4, %r10
addq -0x8(%r9,%r10), %r8
movq %r8, -0x8(%r9,%r10)
subq %r11, %r14
jb 0x13725e
movq %r9, 0x50(%rsp)
movq %r11, %r12
movq %rsi, %r11
subq %r12, %r11
movq 0x8(%rsp), %r9
jb 0x13723e
cmpq %rdx, 0x88(%rsp)
movq 0x30(%rsp), %rdi
leaq 0xf682b(%rip), %r12     # 0x22da10
jne 0x13726d
testq %r13, %r13
jle 0x1372d0
movq %r11, %rax
orq %r14, %rax
movl $0x0, %edx
js 0x1372d9
xorl %edx, %edx
movb (%rdi,%r14), %al
cmpb (%rcx,%r11), %al
jne 0x1372d9
incq %rdx
cmpq %r13, %rdx
jge 0x1372d9
testq %r14, %r14
jle 0x1372d9
leaq -0x1(%r11), %rax
decq %r14
testq %r11, %r11
movq %rax, %r11
jg 0x137207
jmp 0x1372d9
movq 0x10(%rsp), %r8
movq 0x38(%rsp), %r11
movq 0x30(%rsp), %rdi
movq 0x48(%rsp), %r10
leaq 0xf67b7(%rip), %r12     # 0x22da10
jmp 0x1372fb
movq 0x10(%rsp), %r8
movq 0x48(%rsp), %r10
jmp 0x13705f
testq %r13, %r13
jle 0x1372d0
movq %r11, %rdx
orq %r14, %rdx
movl $0x0, %edx
js 0x1372d9
addq 0x98(%rsp), %rcx
subq %rsi, %rax
addq %rcx, %rax
xorl %edx, %edx
movsbl (%rdi,%r14), %ecx
movzbl (%rax,%rdx), %esi
movzbl (%r12,%rsi), %esi
leaq 0xf7daa(%rip), %r9      # 0x22f04e
movzbl (%rsi,%r9), %esi
cmpl %esi, %ecx
jne 0x1372d4
incq %rdx
cmpq %r13, %rdx
jge 0x1372d4
testq %r14, %r14
movq 0x8(%rsp), %r9
jle 0x1372d9
decq %r14
leaq -0x1(%r11), %rcx
testq %r11, %r11
movq %rcx, %r11
jg 0x13728f
jmp 0x1372d9
xorl %edx, %edx
jmp 0x1372d9
movq 0x8(%rsp), %r9
movq 0x50(%rsp), %rax
addq %r10, %rax
shlq $0x20, %rdx
addq %r8, %rdx
movq %rdx, -0x8(%rax)
movq 0x10(%rsp), %r8
movq 0x38(%rsp), %r11
movq 0x48(%rsp), %r10
movq 0x40(%rsp), %rsi
jmp 0x136c18
movq (%r8), %rsi
movq %rsi, %rax
movq 0x28(%rsp), %rdi
subq %rdi, %rax
je 0x137695
cmpq $0x2, %rax
jb 0x137340
movq 0x10(%r8), %rax
shlq $0x4, %rdi
addq %rax, %rdi
shlq $0x4, %rsi
addq %rax, %rsi
callq 0x13356d
movq 0x10(%rsp), %r8
movq 0x28(%rsp), %rdi
movq %r13, %xmm0
punpckldq 0xedef3(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xedefb(%rip), %xmm0    # 0x225250
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0xf7c77(%rip), %xmm1    # 0x22efe0
addsd 0xedeff(%rip), %xmm1    # 0x225270
cvttsd2si %xmm1, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0xedee3(%rip), %xmm1    # 0x225268
cvttsd2si %xmm1, %r14
andq %rcx, %r14
orq %rax, %r14
movq (%r8), %rax
movq $-0x1, %rbp
movq %rdi, 0x20(%rsp)
cmpq %rdi, %rax
jbe 0x13755a
xorl %r12d, %r12d
movq 0x28(%rsp), %rcx
movq %rcx, %r13
movq %rcx, 0x20(%rsp)
movq %rbp, 0x18(%rsp)
movq %r13, %rbp
movq 0x10(%r8), %rsi
movq %r13, %rbx
shlq $0x4, %rbx
movq (%rsi,%rbx), %rdx
movq 0x58(%rsp), %rcx
movq 0x28(%rcx), %rcx
decq %rcx
movq %rdx, %r8
shrq %cl, %r8
leaq (%rsi,%rbx), %rdi
leaq 0x1(%r13), %r9
cmpq %r9, %rax
cmovaq %rax, %r9
movq %rdi, %rax
movq (%rax), %r10
movq %r10, %r11
shrq %cl, %r11
cmpq %r8, %r11
jne 0x137418
subq %rdx, %r10
cmpq %r14, %r10
ja 0x137418
incq %r13
addq $0x10, %rax
cmpq %r13, %r9
jne 0x1373f3
movq %r9, %r13
movq %r13, %r15
subq %rbp, %r15
cmpq $0x2, %r15
jb 0x137433
movq %r13, %rax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x133787
movq 0x10(%rsp), %r8
movq 0x10(%r8), %rax
testq %r15, %r15
je 0x13750b
cmpq $0x1, %r15
jne 0x137457
addq %rax, %rbx
movl 0xc(%rbx), %r15d
jmp 0x13750b
movq %r13, %rdi
shlq $0x4, %rdi
movq -0x8(%rax,%rdi), %rcx
movl %ecx, %edx
movq %rcx, %r8
shrq $0x20, %r8
movq %rdx, %rsi
subq %r8, %rsi
notq %rsi
addq $-0x2, %r15
js 0x1374ee
negq %r8
leaq (%rdx,%r8), %r9
incq %r9
notq %rbp
addq %r13, %rbp
leaq (%rax,%rdi), %r8
addq $-0x18, %r8
xorl %edi, %edi
movq (%r8), %r10
movl %r10d, %r11d
shrq $0x20, %r10
negq %r10
addq %r11, %r10
incq %r10
cmpq %r10, %r9
movq %r10, %rbx
cmovaq %r9, %rbx
cmpq %r11, %rdx
movq %r11, %r15
cmovbq %rdx, %r15
cmpq %r15, %rbx
jbe 0x1374d0
addq %rdi, %rsi
leaq (%rdx,%rsi), %rdi
incq %rdi
movq %r11, %rdx
jmp 0x1374d7
cmpq %r10, %r9
cmovbq %r9, %r10
movq %r10, %rsi
negq %rsi
decq %rbp
addq $-0x10, %r8
movq %r10, %r9
testq %rbp, %rbp
jg 0x137495
jmp 0x1374f0
xorl %edi, %edi
addq %rdi, %rdx
addq %rdx, %rsi
incq %rsi
subq %rdx, %rcx
shlq $0x10, %rcx
orq %rsi, %rcx
movq %rcx, %r15
movq 0x10(%rsp), %r8
movq %r13, %rcx
shlq $0x4, %rcx
movq 0x20(%rsp), %rsi
movq %rsi, %rdx
shlq $0x4, %rdx
movupd -0x10(%rax,%rcx), %xmm0
movupd %xmm0, (%rax,%rdx)
movq 0x10(%r8), %rax
movl %r15d, 0xc(%rax,%rdx)
incq %rsi
movzwl %r15w, %eax
cmpq %rax, %r12
cmovbeq %rax, %r12
movq 0x18(%rsp), %rbp
movq %rsi, 0x20(%rsp)
cmovbq %rsi, %rbp
movq (%r8), %rax
cmpq %rax, %r13
jb 0x1373b8
movq 0x20(%rsp), %r13
movq %r13, (%r8)
movq 0x28(%rsp), %r11
cmpq %r11, %r13
jbe 0x137692
movq 0x10(%r8), %rax
movq %rbp, %rdx
shlq $0x4, %rdx
leaq (%rax,%rdx), %rcx
movq 0x8(%rax,%rdx), %rdx
movl %edx, %esi
movq %rdx, %rdi
shrq $0x20, %rdi
movzwl %di, %edi
shrq $0x30, %rdx
addq %rdi, %rdx
negq %rdx
leaq (%rsi,%rdx), %r8
incq %r8
xorps %xmm0, %xmm0
cvtsi2sd %edi, %xmm0
mulsd 0xedf00(%rip), %xmm0    # 0x2254b0
movq %r11, %rdx
shlq $0x4, %rdx
leaq (%rdx,%rax), %r9
addq $0x8, %r9
movq $-0x1, %rdi
xorl %r10d, %r10d
cmpq %r11, %rbp
je 0x137626
movq (%r9), %r12
movl %r12d, %r15d
movq %r12, %rbx
shrq $0x20, %rbx
movzwl %bx, %ebx
shrq $0x30, %r12
addq %rbx, %r12
negq %r12
addq %r15, %r12
incq %r12
cmpq %r8, %r12
cmovbeq %r8, %r12
cmpq %rsi, %r15
cmovaeq %rsi, %r15
cmpq %r15, %r12
ja 0x13761b
subq %r12, %r15
incq %r15
cmpq %r14, %r15
jbe 0x13761b
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
ucomisd %xmm0, %xmm1
jb 0x137626
jmp 0x137688
cmpq %rbx, %r10
cmovbeq %rbx, %r10
cmovbq %r11, %rdi
incq %r11
addq $0x10, %r9
cmpq %r11, %r13
jne 0x1375c9
cmpq $-0x1, %rdi
je 0x137675
cmpq %rbp, %rdi
movq %rbp, %rcx
cmovbq %rdi, %rcx
cmovaq %rdi, %rbp
shlq $0x4, %rcx
movups (%rax,%rcx), %xmm0
movups %xmm0, (%rax,%rdx)
movq 0x10(%rsp), %r8
movq 0x10(%r8), %rax
shlq $0x4, %rbp
movupd (%rax,%rbp), %xmm0
movupd %xmm0, 0x10(%rax,%rdx)
movq 0x28(%rsp), %r11
addq $0x2, %r11
jmp 0x137692
movupd (%rcx), %xmm0
movupd %xmm0, (%rax,%rdx)
movq 0x28(%rsp), %r11
incq %r11
jmp 0x13768d
movq 0x28(%rsp), %r11
movq 0x10(%rsp), %r8
movq %r11, (%r8)
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq