// File: 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
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x18(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
subq $0x1, %rax
movq %rax, -0xb8(%rbp)
movq -0x18(%rbp), %rax
subq $0x1, %rax
movq %rax, -0xc0(%rbp)
movq $0x0, -0xd0(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x98(%rbp)
movq $0x0, -0xa0(%rbp)
movq $0x0, -0xa8(%rbp)
movq $0x0, -0xb0(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0x1c31e7
movq -0x8(%rbp), %rax
movq -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x1c7b49(%rip), %rax    # 0x38a7e0
movzbl (%rax,%rcx), %eax
movl %eax, -0xdc(%rbp)
cmpl $0x4, -0xdc(%rbp)
jge 0x1c31a0
movq -0xb0(%rbp), %rax
shlq %rax
movl -0xdc(%rbp), %ecx
andl $0x1, %ecx
movslq %ecx, %rcx
orq %rcx, %rax
andq -0xb8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xa8(%rbp), %rax
shlq %rax
movl -0xdc(%rbp), %ecx
sarl %ecx
movslq %ecx, %rcx
orq %rcx, %rax
andq -0xb8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa0(%rbp), %rax
shrq %rax
movl -0xdc(%rbp), %edx
andl $0x1, %edx
movl $0x1, %ecx
subl %edx, %ecx
movslq %ecx, %rdx
movq -0xc0(%rbp), %rcx
shlq %cl, %rdx
movq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0xa0(%rbp)
movq -0x98(%rbp), %rax
shrq %rax
movl -0xdc(%rbp), %edx
sarl %edx
movl $0x1, %ecx
subl %edx, %ecx
movslq %ecx, %rdx
movq -0xc0(%rbp), %rcx
shlq %cl, %rdx
movq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0x98(%rbp)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
cmpq -0x18(%rbp), %rax
jb 0x1c319e
leaq -0xb0(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq -0x58(%rbp), %rsi
callq 0x212f90
movq %rax, -0xc8(%rbp)
cmpq $-0x1, -0x58(%rbp)
jne 0x1c2d9f
jmp 0x1c31d6
movq -0x28(%rbp), %rdi
movq -0xc8(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x213060
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq 0x48(%rcx), %rax
jbe 0x1c2dca
jmp 0x1c31d6
cmpq $0x1, -0x68(%rbp)
je 0x1c2dd6
jmp 0x1c31d6
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x68(%rbp), %rax
jae 0x1c2ff5
jmp 0x1c2dee
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x1c2e5f
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x1c2e1e
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x118(%rbp)
jmp 0x1c2e2c
movl $0x2, %eax
movq %rax, -0x118(%rbp)
jmp 0x1c2e2c
movq -0x118(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x4, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rdx
movq (%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, (%rdx)
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0xd0(%rbp)
movq -0x60(%rbp), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x3f, %rax
cmpq -0x58(%rbp), %rax
setne %al
andb $0x1, %al
movzbl %al, %eax
movq %rax, -0x70(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x60(%rbp), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x28(%rbp), %rcx
andq 0x30(%rcx), %rax
movq %rax, -0x80(%rbp)
movq -0x60(%rbp), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shlq %rax
movq -0x28(%rbp), %rdx
movl $0x40, %ecx
subq 0x18(%rdx), %rcx
shrq %cl, %rax
movq %rax, -0x88(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x88(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movq %rax, -0xd8(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0x1c2f37
movq -0xd8(%rbp), %rax
subq $0x1, %rax
movq -0x80(%rbp), %rcx
addq $0x1, %rcx
subq -0x18(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rcx
movq -0x18(%rbp), %rax
shlq $0x20, %rax
orq %rax, %rcx
movq -0xd0(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x80(%rbp), %rax
cmpq -0x78(%rbp), %rax
jb 0x1c2f6c
movq -0x80(%rbp), %rax
subq -0x78(%rbp), %rax
movq %rax, -0x120(%rbp)
jmp 0x1c2f95
movq -0x78(%rbp), %rax
subq -0x80(%rbp), %rax
movq -0x28(%rbp), %rcx
movq 0x28(%rcx), %rcx
subq $0x1, %rcx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x120(%rbp)
movq -0x120(%rbp), %rcx
movq -0xd0(%rbp), %rax
movq %rcx, (%rax)
movq -0x70(%rbp), %rcx
shlq $0x3f, %rcx
movq -0x60(%rbp), %rax
movq -0x40(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movq -0x28(%rbp), %rdx
andq 0x20(%rdx), %rax
orq %rax, %rcx
movq -0xd0(%rbp), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rdx
andq 0x30(%rdx), %rax
orq %rax, %rcx
movq -0xd0(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x1c2dde
cmpq $0x1, -0x68(%rbp)
jne 0x1c319c
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rsi
addq $0x1, %rsi
movq -0x10(%rbp), %rdx
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x88(%rbp), %rcx
addq %rcx, %rax
movq 0x20(%rax), %rcx
movq -0x80(%rbp), %r8
addq $0x1, %r8
movq -0xd8(%rbp), %r9
movq -0x10(%rbp), %r10
movq -0x70(%rbp), %rax
xorl %r11d, %r11d
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
callq 0x213270
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
addq $0x1, %rax
cmpq -0x18(%rbp), %rax
jb 0x1c30ba
movq $0x0, -0x48(%rbp)
movq $0x0, -0x98(%rbp)
movq $0x0, -0xa0(%rbp)
movq $0x0, -0xa8(%rbp)
movq $0x0, -0xb0(%rbp)
movq -0x38(%rbp), %rax
addq -0x40(%rbp), %rax
movq -0x18(%rbp), %rcx
subq $0x1, %rcx
subq %rcx, %rax
movq %rax, -0x38(%rbp)
jmp 0x1c30ca
movq -0x18(%rbp), %rax
subq -0x40(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rcx
shlq $0x20, %rcx
addq -0x40(%rbp), %rcx
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rdx
movq (%rdx), %rdx
subq $0x1, %rdx
shlq $0x4, %rdx
addq %rdx, %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x78(%rbp), %rax
cmpq -0x18(%rbp), %rax
jb 0x1c319a
movq -0x80(%rbp), %rax
cmpq -0x18(%rbp), %rax
jb 0x1c319a
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rsi
subq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x88(%rbp), %rcx
addq %rcx, %rax
movq 0x20(%rax), %rcx
movq -0x80(%rbp), %r8
subq -0x18(%rbp), %r8
movq -0xd8(%rbp), %r9
movq -0x10(%rbp), %r10
movq -0x70(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movq $0x1, 0x10(%rsp)
callq 0x213270
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rcx
shlq $0x20, %rcx
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rdx
movq (%rdx), %rdx
subq $0x1, %rdx
shlq $0x4, %rdx
addq %rdx, %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
jmp 0x1c319c
jmp 0x1c319e
jmp 0x1c31d4
movq $0x0, -0x48(%rbp)
movq $0x0, -0x98(%rbp)
movq $0x0, -0xa0(%rbp)
movq $0x0, -0xa8(%rbp)
movq $0x0, -0xb0(%rbp)
jmp 0x1c31d6
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x1c2c74
movq -0x20(%rbp), %rax
movq (%rax), %rax
subq -0x30(%rbp), %rax
cmpq $0x0, %rax
jne 0x1c31fd
jmp 0x1c3573
movq -0x20(%rbp), %rax
movq (%rax), %rax
subq -0x30(%rbp), %rax
cmpq $0x1, %rax
jbe 0x1c323c
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x30(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x20(%rbp), %rax
movq (%rax), %rax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x1bdb80
movaps 0x1bedcd(%rip), %xmm1   # 0x382010
movq -0x10(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x1bedcc(%rip), %xmm1   # 0x382020
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x1c85c5(%rip), %xmm1   # 0x38b830
mulsd %xmm1, %xmm0
movsd 0x1bed89(%rip), %xmm1   # 0x382000
addsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0x1bed66(%rip), %xmm1   # 0x381ff8
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0xf0(%rbp)
movq $0x0, -0x108(%rbp)
movq $-0x1, -0x110(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x50(%rbp)
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x1c3549
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x38(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
leaq -0x70(%rbp), %rdx
leaq -0x88(%rbp), %rcx
leaq -0x80(%rbp), %r8
leaq -0x78(%rbp), %r9
leaq -0x68(%rbp), %rax
xorl %r10d, %r10d
movq %rax, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x213560
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0xe8(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rdx
xorl %eax, %eax
cmpq (%rdx), %rcx
movb %al, -0x121(%rbp)
jae 0x1c33e2
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movq 0x28(%rcx), %rcx
subq $0x1, %rcx
shrq %cl, %rax
movq %rax, -0x130(%rbp)
movq -0xe8(%rbp), %rdx
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rcx
subq $0x1, %rcx
shrq %cl, %rdx
movq -0x130(%rbp), %rcx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0x121(%rbp)
jne 0x1c33e2
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
subq -0xe8(%rbp), %rax
cmpq -0xf0(%rbp), %rax
setbe %al
movb %al, -0x121(%rbp)
movb -0x121(%rbp), %al
testb $0x1, %al
jne 0x1c33ee
jmp 0x1c33ff
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x1c3346
movq -0x38(%rbp), %rax
subq -0xf8(%rbp), %rax
cmpq $0x1, %rax
jbe 0x1c343e
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0xf8(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x38(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x1be010
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0xf8(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
movq -0x38(%rbp), %rsi
subq -0xf8(%rbp), %rsi
callq 0x213680
movq %rax, -0x100(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x38(%rbp), %rax
subq $0x1, %rax
shlq $0x4, %rax
addq %rax, %rcx
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x50(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x50(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
shlq $0x20, %rcx
shrq $0x20, %rcx
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x50(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq -0x100(%rbp), %rcx
shlq $0x20, %rcx
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x50(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x108(%rbp), %rax
movq -0x100(%rbp), %rcx
andq $0xffff, %rcx           # imm = 0xFFFF
cmpq %rcx, %rax
jae 0x1c3544
movq -0x100(%rbp), %rax
andq $0xffff, %rax           # imm = 0xFFFF
movq %rax, -0x108(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x110(%rbp)
jmp 0x1c32ca
movq -0x50(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x110(%rbp), %rcx
movq -0xf0(%rbp), %r8
callq 0x214150
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
nopl (%rax)