// File: /workspace/github_cpp_makefile_star2_O3/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 $0x98, %rsp
movq %r9, 0x78(%rsp)
movq %r8, 0x58(%rsp)
movq %rcx, %r11
movq %rsi, %rbp
movq $-0x1, %r8
movl %edx, %ecx
shlq %cl, %r8
testq %rsi, %rsi
movq %r11, 0x20(%rsp)
je 0x13d0dd
notq %r8
leaq -0x1(%rdx), %rcx
movq %rdx, %rax
shlq $0x20, %rax
movq %rax, 0x90(%rsp)
leaq 0x1(%rdi), %rax
movq %rax, 0x70(%rsp)
xorl %r15d, %r15d
leaq 0xfd2b5(%rip), %r9      # 0x239c20
xorl %esi, %esi
xorl %r13d, %r13d
xorl %r14d, %r14d
xorl %ebx, %ebx
xorl %r10d, %r10d
movq %rdx, 0x40(%rsp)
movq %rdi, 0x30(%rsp)
movq %r8, 0x38(%rsp)
movq %rcx, 0x28(%rsp)
movq %rbp, 0x10(%rsp)
movzbl (%rdi,%r15), %eax
movzbl (%r9,%rax), %eax
cmpq $0x3, %rax
ja 0x13ca00
movq %rbp, %r12
movq %rsi, %rbp
movq %r14, %rsi
movl %eax, %r14d
andl $0x1, %r14d
leaq (%r14,%r10,2), %r10
andq %r8, %r10
addq %rbx, %rbx
shrl %eax
orq %rax, %rbx
andq %r8, %rbx
shrq %rsi
xorl $0x1, %r14d
shlq %cl, %r14
orq %rsi, %r14
movq %r13, %rsi
movl $0x1, %r13d
subl %eax, %r13d
shlq %cl, %r13
shrq %rsi
orq %rsi, %r13
movq %rbp, %rsi
incq %rsi
cmpq %rdx, %rsi
movq %r10, 0x50(%rsp)
jae 0x13ca1b
movq %r15, %r10
movq %r12, %rbp
jmp 0x13cbbf
movq $0x0, 0x50(%rsp)
xorl %ebx, %ebx
xorl %r14d, %r14d
xorl %r13d, %r13d
xorl %esi, %esi
movq %r15, %r10
jmp 0x13cbbf
cmpq %r13, %rbx
jne 0x13ca30
cmpq %r14, %r10
movq %r12, %rbp
jne 0x13ca39
movq %r10, %r14
movq %rbx, %r13
jmp 0x13ca13
setae %r11b
movq %r12, %rbp
jmp 0x13ca3d
setae %r11b
movq %rsi, 0x18(%rsp)
testb %r11b, %r11b
movq %r10, %rax
cmovneq %r14, %rax
cmpq $0x20, %rdx
ja 0x13ca68
shlq $0x20, %rax
testb %r11b, %r11b
movq %rbx, %rdi
cmovneq %r13, %rdi
orq %rax, %rdi
jmp 0x13caf3
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
testb %r11b, %r11b
movq %rbx, %rax
cmovneq %r13, %rax
movq %rax, %rsi
notq %rsi
shlq $0x15, %rax
addq %rsi, %rax
movq %rax, %rsi
shrq $0x18, %rsi
xorq %rax, %rsi
imulq $0x109, %rsi, %rax      # imm = 0x109
movq %rax, %rsi
shrq $0xe, %rsi
xorq %rax, %rsi
leaq (%rsi,%rsi,4), %rax
leaq (%rsi,%rax,4), %rax
movq %rax, %rsi
shrq $0x1c, %rsi
xorq %rax, %rsi
addq %rcx, %rsi
movq %rsi, %rdi
shlq $0x1f, %rdi
addq %rsi, %rdi
movq 0x58(%rsp), %rax
movb 0x50(%rax), %cl
movq $-0x1, %r8
shlq %cl, %r8
notq %r8
movq 0x78(%rax), %rax
andq %rdi, %r8
shlq $0x5, %r8
movq (%rax,%r8), %r9
movq 0x10(%r9), %rsi
testq %rsi, %rsi
je 0x13cb97
movb %r11b, 0xf(%rsp)
movb (%r9), %cl
movl $0x1, %r10d
shll %cl, %r10d
movq %rdi, %r11
shrq $0xc, %r11
imull $0x9e3779b9, %r11d, %r11d # imm = 0x9E3779B9
negb %cl
shrl %cl, %r11d
addq %r8, %rax
leal -0x1(%r10), %ecx
movq 0x8(%r9), %r9
movl %r11d, %r8d
movl %r8d, %r12d
shrl $0x5, %r12d
movl (%r9,%r12,4), %ebp
btl %r8d, %ebp
jae 0x13cb88
movl %r8d, %ebp
shlq $0x4, %rbp
movq (%rsi,%rbp), %rdx
movq %rdx, %r12
xorq %rdi, %r12
cmpq $0x1000, %r12           # imm = 0x1000
jb 0x13cbd8
incl %r8d
andl %ecx, %r8d
cmpl %r11d, %r8d
jne 0x13cb52
movq %r15, %r10
movq 0x20(%rsp), %r11
movq 0x10(%rsp), %rbp
jmp 0x13cb9f
movq %r15, %r10
movq 0x20(%rsp), %r11
movq 0x40(%rsp), %rdx
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %r8
movq 0x28(%rsp), %rcx
leaq 0xfd066(%rip), %r9      # 0x239c20
movq 0x18(%rsp), %rsi
incq %r10
movq %r10, %r15
cmpq %rbp, %r10
movq 0x50(%rsp), %r10
jb 0x13c991
jmp 0x13d0dd
cmpl %r10d, %r8d
movq 0x20(%rsp), %r11
jne 0x13cbe7
movq %r15, %r10
jmp 0x13cb90
movq 0x8(%rsi,%rbp), %r12
movl $0xfff, %edi            # imm = 0xFFF
andq %rdi, %rdx
cmpq %rdi, %rdx
movq 0x58(%rsp), %r10
jne 0x13cc31
cmpl 0x18(%rax), %r8d
jne 0x13cc0a
movq 0x8(%rax), %rdx
jmp 0x13cc2e
cmpl %r8d, %ecx
je 0x13cc04
incl %r8d
movl %r8d, %edx
shrl $0x5, %edx
movl (%r9,%rdx,4), %edx
btl %r8d, %edx
jae 0x13cc0a
movl %r8d, %ecx
shlq $0x4, %rcx
movq 0x8(%rsi,%rcx), %rdx
subq %r12, %rdx
cmpq $0x1, %rdx
movq 0x10(%rsp), %rbp
movq 0x40(%rsp), %rdx
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %r8
movq 0x28(%rsp), %rcx
leaq 0xfcfcb(%rip), %r9      # 0x239c20
jne 0x13ce7a
cmpq $0x0, 0x48(%r10)
movq 0x18(%rsp), %rsi
je 0x13ca13
movq 0x10(%rax), %rax
movq %rax, 0x48(%rsp)
movq (%r11), %rdx
movq 0x10(%r11), %rbp
cmpq 0x8(%r11), %rdx
jne 0x13ccbc
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r11)
shlq $0x4, %rsi
movq %rbp, %rdi
movq %r12, %rbp
movq %r10, %r12
callq 0x2370
movq %r12, %r10
movq %rbp, %r12
movq 0x20(%rsp), %r11
movq %rax, %rbp
movq %rax, 0x10(%r11)
movq (%r11), %rdx
movq %r15, %rsi
orq 0x90(%rsp), %rsi
leaq 0x1(%rdx), %rax
movq %rax, 0x18(%rsp)
movq %rax, (%r11)
shlq $0x4, %rdx
movq %r12, 0x88(%rsp)
movq 0x48(%rsp), %rax
movq (%rax,%r12,8), %rdi
testq %rdi, %rdi
sets %cl
movb 0xf(%rsp), %al
xorb %cl, %al
movq 0x30(%r10), %r9
movq %r9, %r12
andq %rdi, %r12
addq %rdi, %rdi
movb 0x18(%r10), %r8b
xorl %ecx, %ecx
subb %r8b, %cl
shrq %cl, %rdi
movq (%r10), %rcx
movq 0x10(%rcx), %rcx
leaq (%rdi,%rdi,4), %r11
movq %rcx, 0x80(%rsp)
movl (%rcx,%r11,8), %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movq %r12, %rdi
notq %rdi
addq 0x28(%rsp), %rdi
addq %r8, %rdi
movb %al, 0xf(%rsp)
testb %al, %al
cmoveq %r12, %rdi
movq %rsi, 0x60(%rsp)
movq %rsi, 0x8(%rbp,%rdx)
movq %rdi, %r12
subq %r15, %r12
jae 0x13cd73
movq %rbp, %rax
movq %r15, %rbp
subq %rdi, %rbp
movb 0x28(%r10), %cl
decb %cl
movl $0x1, %r12d
shlq %cl, %r12
addq %rbp, %r12
movq %rax, %rbp
movq %rbp, 0x68(%rsp)
addq %rbp, %rdx
movq %r12, (%rdx)
movb 0xf(%rsp), %al
movzbl %al, %ecx
shlq $0x3f, %rcx
movq 0x20(%r10), %rbp
movq 0x88(%rsp), %rsi
movq 0x48(%rsp), %r10
andq (%r10,%rsi,8), %rbp
orq %rcx, %rbp
andq %r12, %r9
orq %rbp, %r9
movq %r9, (%rdx)
leaq 0x1(%r15), %rdx
movq 0x80(%rsp), %rcx
movq 0x20(%rcx,%r11,8), %rcx
movq %rcx, 0x48(%rsp)
leaq 0x1(%rdi), %rcx
testb %al, %al
je 0x13ce82
movq 0x10(%rsp), %rbp
testq %rbp, %rbp
jle 0x13ceec
cmpq %rbp, %rdx
jge 0x13ceec
movl $0x0, %r11d
cmpq %r8, %rcx
jge 0x13cefe
leaq 0x2(%r15), %rdx
movq 0x70(%rsp), %rcx
leaq (%rcx,%r15), %r9
leaq 0x2(%rdi), %r10
movq %r8, %rcx
subq %rdi, %rcx
movq 0x48(%rsp), %rax
addq %rax, %rcx
addq $-0x2, %rcx
xorl %r12d, %r12d
movsbl (%r9,%r12), %r11d
movzbl (%rcx), %ebp
leaq 0xfcdf9(%rip), %rsi     # 0x239c20
movzbl (%rsi,%rbp), %ebp
leaq 0xfe46c(%rip), %rsi     # 0x23b29e
movzbl (%rbp,%rsi), %ebp
cmpl %ebp, %r11d
jne 0x13cef1
leaq 0x1(%r12), %r11
movq 0x10(%rsp), %rbp
cmpq %rbp, %r11
jge 0x13cefe
leaq (%rdx,%r12), %rbp
cmpq 0x10(%rsp), %rbp
movq 0x10(%rsp), %rbp
jge 0x13cefe
addq %r10, %r12
decq %rcx
cmpq %r8, %r12
movq %r11, %r12
jl 0x13ce18
jmp 0x13cefe
movq %r15, %r10
jmp 0x13cbba
movq 0x10(%rsp), %rbp
testq %rbp, %rbp
jle 0x13ceec
cmpq %rbp, %rdx
jge 0x13ceec
movl $0x0, %r11d
cmpq %r8, %rcx
jge 0x13cefe
leaq 0x2(%r15), %rcx
movq 0x70(%rsp), %rdx
addq %r15, %rdx
leaq 0x2(%rdi), %r9
movq 0x48(%rsp), %rax
leaq (%rax,%rdi), %r10
incq %r10
xorl %r12d, %r12d
movb (%rdx,%r12), %r11b
cmpb (%r10,%r12), %r11b
jne 0x13cefb
leaq 0x1(%r12), %r11
cmpq %rbp, %r11
jge 0x13cefe
leaq (%rcx,%r12), %rbp
cmpq 0x10(%rsp), %rbp
movq 0x10(%rsp), %rbp
jge 0x13cefe
addq %r9, %r12
cmpq %r8, %r12
movq %r11, %r12
jl 0x13cebb
jmp 0x13cefe
xorl %r11d, %r11d
jmp 0x13cefe
movq %r12, %r11
movq 0x10(%rsp), %rbp
jmp 0x13cefe
movq %r12, %r11
leaq 0x1(%r11), %rcx
movq 0x40(%rsp), %rdx
cmpq %rdx, %rcx
jae 0x13cf1a
movq %r11, %rax
notq %rax
addq %rdx, %rax
movq %r15, %r10
jmp 0x13cf3a
movq %r15, %rcx
subq %rdx, %rcx
leaq (%rcx,%r11), %r10
incq %r10
movq $0x0, 0x50(%rsp)
xorl %ebx, %ebx
xorl %r14d, %r14d
xorl %r13d, %r13d
xorl %eax, %eax
movq 0x28(%rsp), %rcx
leaq 0xfccda(%rip), %r9      # 0x239c20
movq 0x60(%rsp), %r12
movq %r11, %rsi
shlq $0x20, %rsi
addq %r11, %rsi
movq 0x18(%rsp), %r11
shlq $0x4, %r11
addq %rsi, %r12
movq 0x68(%rsp), %rsi
movq %r12, -0x8(%rsi,%r11)
subq %rdx, %r15
jb 0x13d03c
movq %r11, 0x18(%rsp)
movq %rdi, %r9
subq %rdx, %r9
movq 0x20(%rsp), %r11
jb 0x13d01f
cmpb $0x0, 0xf(%rsp)
movq %rax, %rsi
je 0x13d053
testq %rbp, %rbp
movq 0x48(%rsp), %rdx
jle 0x13d09b
movq %r9, %rcx
orq %r15, %rcx
movl $0x0, %r11d
js 0x13d0a3
addq 0x28(%rsp), %rdx
subq %rdi, %r8
addq %rdx, %r8
xorl %r11d, %r11d
movq 0x30(%rsp), %rcx
movsbl (%rcx,%r15), %ecx
movzbl (%r8,%r11), %edx
leaq 0xfcc44(%rip), %rsi     # 0x239c20
movzbl (%rsi,%rdx), %edx
leaq 0xfe2b7(%rip), %rsi     # 0x23b29e
movzbl (%rdx,%rsi), %edx
cmpl %edx, %ecx
jne 0x13d0a0
incq %r11
cmpq %rbp, %r11
jge 0x13d0a0
testq %r15, %r15
movq %rax, %rsi
jle 0x13d0a3
decq %r15
leaq -0x1(%r9), %rcx
testq %r9, %r9
movq %rcx, %r9
jg 0x13cfc6
jmp 0x13d0a3
movq 0x40(%rsp), %rdx
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %r8
movq 0x28(%rsp), %rcx
leaq 0xfcbe6(%rip), %r9      # 0x239c20
jmp 0x13d04b
movq 0x20(%rsp), %r11
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %r8
movq %rax, %rsi
jmp 0x13cbbf
testq %rbp, %rbp
movq 0x48(%rsp), %rax
jle 0x13d09b
movq %r9, %rcx
orq %r15, %rcx
movl $0x0, %r11d
js 0x13d0a3
xorl %r11d, %r11d
movq 0x30(%rsp), %rcx
movb (%rcx,%r15), %cl
cmpb (%rax,%r9), %cl
jne 0x13d0a3
incq %r11
cmpq %rbp, %r11
jge 0x13d0a3
testq %r15, %r15
jle 0x13d0a3
leaq -0x1(%r9), %rcx
decq %r15
testq %r9, %r9
movq %rcx, %r9
jg 0x13d06e
jmp 0x13d0a3
xorl %r11d, %r11d
jmp 0x13d0a3
movq %rax, %rsi
movq 0x68(%rsp), %rax
addq 0x18(%rsp), %rax
shlq $0x20, %r11
addq %r12, %r11
movq %r11, -0x8(%rax)
movq 0x20(%rsp), %r11
movq 0x40(%rsp), %rdx
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %r8
movq 0x28(%rsp), %rcx
leaq 0xfcb48(%rip), %r9      # 0x239c20
jmp 0x13cbbf
movq (%r11), %rax
movq %rax, %rcx
movq 0x78(%rsp), %r13
subq %r13, %rcx
je 0x13d48d
cmpq $0x2, %rcx
jb 0x13d11c
movq 0x10(%r11), %rcx
movq %r13, %rdi
shlq $0x4, %rdi
addq %rcx, %rdi
shlq $0x4, %rax
addq %rcx, %rax
movq %rax, %rsi
callq 0x139737
movq 0x20(%rsp), %r11
movq (%r11), %rax
cmpq %r13, %rax
movq 0x58(%rsp), %rdi
jbe 0x13d48a
movq %rbp, %xmm0
punpckldq 0xf4149(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xf4151(%rip), %xmm0    # 0x231290
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0xfe0dd(%rip), %xmm1    # 0x23b230
addsd 0xf41b5(%rip), %xmm1    # 0x231310
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
subsd 0xf4199(%rip), %xmm1    # 0x231308
cvttsd2si %xmm1, %r14
andq %rdx, %r14
orq %rcx, %r14
movq 0x10(%r11), %rsi
movq $-0x1, 0x50(%rsp)
movl $0x1, %edx
xorl %r8d, %r8d
movq %r13, %rbp
movq %r8, 0x10(%rsp)
movq %rbp, %r15
movq %rbp, %rbx
shlq $0x4, %rbx
movq (%rsi,%rbx), %r8
movq 0x28(%rdi), %rcx
decq %rcx
movq %r8, %r9
shrq %cl, %r9
movq %rdx, 0x18(%rsp)
leaq (%rsi,%rbx), %rdi
leaq 0x1(%rbp), %rdx
cmpq %rdx, %rax
cmovaq %rax, %rdx
movq %rdi, %rax
movq (%rax), %r10
movq %r10, %r11
shrq %cl, %r11
cmpq %r9, %r11
jne 0x13d1ee
subq %r8, %r10
cmpq %r14, %r10
ja 0x13d1ee
incq %rbp
addq $0x10, %rax
cmpq %rbp, %rdx
jne 0x13d1c9
movq %rdx, %rbp
movq %rbp, %r12
subq %r15, %r12
cmpq $0x2, %r12
jb 0x13d214
movq %rbp, %rax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x139951
movq 0x20(%rsp), %r11
movq 0x10(%r11), %rsi
jmp 0x13d219
movq 0x20(%rsp), %r11
testq %r12, %r12
je 0x13d2ed
cmpq $0x1, %r12
jne 0x13d234
addq %rsi, %rbx
movl 0xc(%rbx), %r12d
jmp 0x13d2ed
movq %rbp, %rdi
shlq $0x4, %rdi
movq -0x8(%rsi,%rdi), %rax
movl %eax, %ecx
movq %rax, %rdx
shrq $0x20, %rdx
negq %rdx
leaq (%rcx,%rdx), %r9
incq %r9
movq %r9, %rdx
negq %rdx
addq $-0x2, %r12
js 0x13d2d1
notq %r15
addq %rbp, %r15
leaq (%rsi,%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, %rcx
movq %r11, %r12
cmovbq %rcx, %r12
cmpq %r12, %rbx
jbe 0x13d2aa
addq %rdi, %rdx
leaq (%rcx,%rdx), %rdi
incq %rdi
movq %r11, %rcx
jmp 0x13d2b1
cmpq %r10, %r9
cmovbq %r9, %r10
movq %r10, %rdx
negq %rdx
decq %r15
addq $-0x10, %r8
movq %r10, %r9
testq %r15, %r15
jg 0x13d26f
leaq 0x1(%rcx), %r8
movq 0x20(%rsp), %r11
jmp 0x13d2d7
leaq 0x1(%rcx), %r8
xorl %edi, %edi
addq %rdi, %r8
addq %rdx, %r8
addq %rdi, %rcx
subq %rcx, %rax
shlq $0x10, %rax
orq %r8, %rax
movq %rax, %r12
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %r8
movq %rbp, %rax
shlq $0x4, %rax
movq %r13, %rcx
shlq $0x4, %rcx
movupd -0x10(%rsi,%rax), %xmm0
incq %r13
movzwl %r12w, %eax
cmpq %rax, %r8
cmovbeq %rax, %r8
movupd %xmm0, (%rsi,%rcx)
movq 0x10(%r11), %rsi
movq 0x50(%rsp), %rax
cmovbq %r13, %rax
movq %rax, 0x50(%rsp)
movl %r12d, 0xc(%rsi,%rcx)
movq (%r11), %rax
leaq 0x1(%rbx), %rdx
cmpq %rax, %rbp
movq 0x58(%rsp), %rdi
jb 0x13d192
movq %r13, (%r11)
movq 0x78(%rsp), %rax
cmpq %rax, %r13
movq %rax, %r13
jbe 0x13d48a
movq 0x10(%r11), %rax
movq 0x50(%rsp), %rbp
movq %rbp, %rdx
shlq $0x4, %rdx
leaq (%rax,%rdx), %rcx
movq %rcx, 0x18(%rsp)
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 0xf4208(%rip), %xmm0    # 0x2315b0
movq %r13, %rdx
shlq $0x4, %rdx
leaq (%rdx,%rax), %r9
addq $0x8, %r9
movq $-0x1, %rdi
xorl %r10d, %r10d
movq %r13, %r11
cmpq %r11, %rbp
je 0x13d42a
movq %rbx, %rcx
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 0x13d41c
subq %r12, %r15
incq %r15
cmpq %r14, %r15
jbe 0x13d41c
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
ucomisd %xmm0, %xmm1
movq %rcx, %rbx
jb 0x13d42a
jmp 0x13d485
cmpq %rbx, %r10
cmovbeq %rbx, %r10
cmovbq %r11, %rdi
movq %rcx, %rbx
incq %r11
addq $0x10, %r9
decq %rbx
jne 0x13d3c4
cmpq $-0x1, %rdi
je 0x13d474
cmpq %rbp, %rdi
movq %rbp, %rcx
cmovbq %rdi, %rcx
cmovaq %rdi, %rbp
shlq $0x4, %rcx
movups (%rax,%rcx), %xmm0
movups %xmm0, (%rax,%rdx)
movq 0x20(%rsp), %r11
movq 0x10(%r11), %rax
shlq $0x4, %rbp
movupd (%rax,%rbp), %xmm0
movupd %xmm0, 0x10(%rax,%rdx)
addq $0x2, %r13
jmp 0x13d48a
movq 0x18(%rsp), %rcx
movupd (%rcx), %xmm0
movupd %xmm0, (%rax,%rdx)
incq %r13
movq 0x20(%rsp), %r11
movq %r13, (%r11)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq