// File: chhylp123[P]hifiasm/gfa_ut.cpp
// Function: gen_unique_g_adv_old(ul_resolve_t*, usg_t*, unsigned long*, unsigned long, unsigned long*, unsigned int)
uint64_t gen_unique_g_adv_old(ul_resolve_t *uidx, usg_t *ng, uint64_t *int_idx, uint64_t int_idx_n, uint64_t *int_a, uint32_t max_ext)
{
    uint64_t pi, ei, *pz, bn, a_n, ua_n, *r_a, r_n; uint8_t *ff; CALLOC(ff, ng->n<<1);
    uint32_t i, k, n_vtx = ng->n<<1, s, e, zs, ze, v, b64_n; 
    uint32_t *ng_occ; CALLOC(ng_occ, n_vtx); 
    asg64_v b64, ub64; kv_init(b64); kv_init(ub64); 
    
    for (k = 0; k < int_idx_n; k++) {///scan all integer contigs
        r_a = int_a + (int_idx[k]>>32); r_n = (uint32_t)int_idx[k];
        assert(r_n >= 2);
        for (i = 1; i + 1 < r_n; i++) {
            ng_occ[r_a[i]]++; ng_occ[r_a[i]^1]++;
        }
        ng_occ[r_a[0]]++; ng_occ[r_a[r_n-1]^1]++;
    }

    ma_ug_t *un_g = ma_ug_hybrid_gen(ng); ma_utg_t *u;
    // print_debug_gfa(uidx->sg, un_g, uidx->uopt->coverage_cut, "iig0", uidx->uopt->sources, 
    // uidx->uopt->ruIndex, uidx->uopt->max_hang, uidx->uopt->min_ovlp, 0, 0, 0);
    int32_t ui, un;
    for (k = 0; k < un_g->u.n; k++) {///all unitigs of raw utg 
        u = &(un_g->u.a[k]); 
        zs = ze = (uint32_t)-1; un = u->n;
        for (ui = 0; ui < un; ui++) {
            if(occ_m(ng_occ[(u->a[ui]>>32)^1]) == 1) {
                zs = ui; break;
            }
        }

        for (ui = ((int32_t)un)-1; ui >= 0; ui--) {
            if(occ_m(ng_occ[u->a[ui]>>32]) == 1) {
                ze = ui; break;
            }
        }
        if(zs != (uint32_t)-1 && ze != (uint32_t)-1 && zs > ze) continue;
        if(zs != (uint32_t)-1) ng_occ[(u->a[zs]>>32)^1] |= ((uint32_t)0x80000000);
        if(ze != (uint32_t)-1) ng_occ[(u->a[ze]>>32)] |= ((uint32_t)0x80000000);
    }
    ma_ug_destroy(un_g);
    
    // fprintf(stderr, ">>>>>>[M::%s::] int_idx[0]::%lu, int_idx[1]::%lu\n", __func__, int_idx[0], int_idx[1]);
    // prt_intg_info(int_idx, int_idx_n, int_a, "intg");
    for (i = b64.n = ua_n = a_n = 0; i < int_idx_n; i++) {///scan all integer contigs
        s = int_idx[i]>>32; e = s + ((uint32_t)int_idx[i]); 
        assert(e > s + 1);//the length is at least 2
        for (k = s, bn = b64.n, pi = (uint64_t)-1; k < e; k++) {
            v = int_a[k];
            if((!(ng_occ[v]&((uint32_t)0x80000000)))&&(!(ng_occ[v^1]&((uint32_t)0x80000000)))) {
                continue;///it must be a unique node
            }
            if((pi != (uint64_t)-1) && (ng_occ[v^1]&((uint32_t)0x80000000))) {
                // fprintf(stderr, "+++[M::%s::i->%u::s->%u::e->%u] pi::%lu, k::%u\n", __func__, i, s, e, pi, k);
                kv_pushp(uint64_t, b64, &pz); *pz = pi; (*pz) <<= 32; (*pz) |= k; a_n++;
            }
            if(ng_occ[v]&((uint32_t)0x80000000)) pi = k;
        }

        b64_n = b64.n;
        for (k = bn, pi = s; k < b64_n; k++) {
            ei = b64.a[k]>>32;
            if(pi < ei) {
                kv_pushp(uint64_t, b64, &pz); ua_n++;
                (*pz) = pi; (*pz) <<= 32; (*pz) |= ei; (*pz) |= ((uint64_t)0x8000000000000000);
            }
            pi = (uint32_t)b64.a[k];
        }

        ei = e - 1;
        if(pi < ei) {
            kv_pushp(uint64_t, b64, &pz); ua_n++;
            (*pz) = pi; (*pz) <<= 32; (*pz) |= ei; (*pz) |= ((uint64_t)0x8000000000000000);
        }
    }
    assert(a_n + ua_n == b64.n);
    // prt_thread_info(b64.a, a_n+ua_n, NULL, 0, "tt_minus");
    // fprintf(stderr, "**0**[M::%s::] a_n::%lu, ua_n::%lu\n", __func__, a_n, ua_n);

    uint64_t *i_idx, n_clus; CALLOC(i_idx, ng->n<<1);
    radix_sort_srt64(b64.a, b64.a + b64.n);///keeps the coordinates within int_a[]

    // prt_thread_info(b64.a, a_n, NULL, 0, "tt0");
    /*********debugging*********/
    // for (i = 0; i < a_n; i++) { ///available intervals
    //     s = b64.a[i]>>32; e = (uint32_t)b64.a[i];
    //     fprintf(stderr, "[M::%s::ava->%u] s::%u, e::%u\n", __func__, i, s, e);
    //     for (k = s; k <= e; k++) {
    //         fprintf(stderr, "utg%.6dl(%c)\n", ((int32_t)(int_a[k]>>1))+1, "+-"[int_a[k]&1]);
    //     }
    // }
    // for (i = a_n; i < b64.n; i++) {///unavailable intervals
    //     s = (b64.a[i]<<1)>>33; e = (uint32_t)b64.a[i];
    //     fprintf(stderr, "[M::%s::uava->%u] s::%u, e::%u\n", __func__, i - (uint32_t)a_n, s, e);
    //     for (k = s; k <= e; k++) {
    //         fprintf(stderr, "utg%.6dl(%c)\n", ((int32_t)(int_a[k]>>1))+1, "+-"[int_a[k]&1]);
    //     }
    // }
    /*********debugging*********/






    for (i = a_n; i < b64.n; i++) {///unavailable intervals; mask all unavailable nodes
        assert(b64.a[i]&((uint64_t)0x8000000000000000)); ua_n--;
        s = (b64.a[i]<<1)>>33; e = (uint32_t)b64.a[i]; assert(e > s);//[s, e]
        for (k = s + 1; k < e; k++) {///note: here is [s, e]
            i_idx[int_a[k]] |= ((uint64_t)0x8000000000000000);
            i_idx[int_a[k]^1] |= ((uint64_t)0x8000000000000000);
        }
        i_idx[int_a[s]] |= ((uint64_t)0x8000000000000000);
        i_idx[int_a[e]^1] |= ((uint64_t)0x8000000000000000);
    }
    // prt_thread_info(b64.a, a_n, NULL, 0, "tt1");
    ///unavailable intervals are useless
    b64.n = a_n; assert(ua_n == 0);
    for (i = 0; i < a_n; i++) { ///available intervals
        s = b64.a[i]>>32; e = (uint32_t)b64.a[i]; assert(e > s);///[s, e] -> coordinates within int_a[]
        if(i == 3201 || i == 3202) {
            fprintf(stderr, "[M::%s::] s::%u, e::%u, int_a[s]::%lu(occ::%u), int_a[e]^1::%lu(occ::%u)\n", 
            __func__, s, e, int_a[s], occ_m(ng_occ[int_a[s]]),
            int_a[e]^1, occ_m(ng_occ[int_a[e]^1]));
        }
        
        assert(!(b64.a[i]&((uint64_t)0x8000000000000000)));
        for (k = s + 1; k < e; k++) {///note: here is [s, e]; s && e are unique, but [s+1, e-1] are not unique
            kv_pushp(uint64_t, b64, &pz); //i_idx[int_a[k]]++;
            (*pz) = int_a[k]; (*pz) <<= 32; (*pz) |= i;///(raw unitig/non-unqiue node id)|(integer contig id)

            kv_pushp(uint64_t, b64, &pz); //i_idx[int_a[k]^1]++;
            (*pz) = int_a[k]^1; (*pz) <<= 32; (*pz) |= i;
        }
        kv_pushp(uint64_t, b64, &pz); //i_idx[int_a[s]]++;
        (*pz) = int_a[s]; (*pz) <<= 32; (*pz) |= i;

        kv_pushp(uint64_t, b64, &pz); //i_idx[int_a[e]^1]++;
        (*pz) = int_a[e]^1; (*pz) <<= 32; (*pz) |= i;
    }
    // prt_thread_info(b64.a, a_n, NULL, 0, "tt2");
    // fprintf(stderr, "**1**[M::%s::] a_n::%lu, ua_n::%lu\n", __func__, a_n, ua_n);
    ///index
    radix_sort_srt64(b64.a + a_n, b64.a + b64.n);///(raw unitig node id)|(integer contig id)
    for (k = a_n + 1, i = a_n; k <= b64.n; k++) {
        if(k == b64.n || (b64.a[k]>>32) != (b64.a[i]>>32)) {
            i_idx[b64.a[i]>>32] |= (((uint64_t)i)<<32)|((uint64_t)k);///b64.a[i]>>32 appear once (unique ends)/multipe times
            i = k;
        }
    }
    // prt_thread_info(b64.a, a_n, NULL, 0, "tt3");
    // fprintf(stderr, "**2**[M::%s::] a_n::%lu, ua_n::%lu\n", __func__, a_n, ua_n);
    ///b64.a[0, a_n]:: all resolvable paths with unique beg && end
    ///b64.a[a_n, b64.n]:: (raw unitig/non-unqiue node id)|(resolvable path id)
    // n_clus = usg_unique_arcs_cluster(&b64, a_n, i_idx, int_a);///this function might be wrong
    n_clus = usg_unique_arcs_cluster_adv(&b64, a_n, i_idx, int_a, &ub64);
    fprintf(stderr, "**3**[M::%s::] a_n::%lu, n_clus::%lu\n", __func__, a_n, n_clus);
    // prt_thread_info(b64.a, a_n, NULL, 0, "tt4");
    assert(b64.n == (a_n<<1));
    old_path_ext(uidx, ng, &b64, &ub64, a_n, n_clus, i_idx, int_a, ff, ng_occ, max_ext);
    // new_path_ext(uidx, ng, &b64, &ub64, a_n, n_clus, i_idx, int_a, ff, ng_occ, max_ext);

    free(ng_occ); free(i_idx); free(ff); kv_destroy(b64); kv_destroy(ub64); 
    return b64.n - a_n;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movl %r9d, -0x3c(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
shlq %rdi
movl $0x1, %esi
callq 0x2140
movq %rax, -0x88(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %eax
movl %eax, %edi
movl $0x4, %esi
callq 0x2140
movq %rax, -0xb8(%rbp)
movq $0x0, -0xc8(%rbp)
movq $0x0, -0xd0(%rbp)
movq $0x0, -0xc0(%rbp)
movq $0x0, -0xe0(%rbp)
movq $0x0, -0xe8(%rbp)
movq $0x0, -0xd8(%rbp)
movl $0x0, -0x90(%rbp)
movl -0x90(%rbp), %eax
cmpq -0x30(%rbp), %rax
jae 0x35cf30
movq -0x38(%rbp), %rax
movq -0x28(%rbp), %rcx
movl -0x90(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x28(%rbp), %rax
movl -0x90(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x80(%rbp)
cmpq $0x2, -0x80(%rbp)
jb 0x35ce56
jmp 0x35ce75
leaq 0x3ce29(%rip), %rdi     # 0x399c86
leaq 0x39355(%rip), %rsi     # 0x3961b9
movl $0x342d, %edx           # imm = 0x342D
leaq 0x3ce1f(%rip), %rcx     # 0x399c8f
callq 0x2130
movl $0x1, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
cmpq -0x80(%rbp), %rax
jae 0x35cee1
movq -0xb8(%rbp), %rax
movq -0x78(%rbp), %rcx
movl -0x8c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0xb8(%rbp), %rax
movq -0x78(%rbp), %rcx
movl -0x8c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
xorq $0x1, %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x35ce7f
movq -0xb8(%rbp), %rax
movq -0x78(%rbp), %rcx
movq (%rcx), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0xb8(%rbp), %rax
movq -0x78(%rbp), %rcx
movq -0x80(%rbp), %rdx
subq $0x1, %rdx
movq (%rcx,%rdx,8), %rcx
xorq $0x1, %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x35ce08
movq -0x20(%rbp), %rdi
callq 0x359c70
movq %rax, -0xf0(%rbp)
movl $0x0, -0x90(%rbp)
movl -0x90(%rbp), %eax
movq -0xf0(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x35d11b
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x90(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xf8(%rbp)
movl $0xffffffff, -0xa4(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0xa0(%rbp) # imm = 0xFFFFFFFF
movq -0xf8(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x100(%rbp)
movl $0x0, -0xfc(%rbp)
movl -0xfc(%rbp), %eax
cmpl -0x100(%rbp), %eax
jge 0x35d00e
movq -0xb8(%rbp), %rax
movq -0xf8(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq -0xfc(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
xorq $0x1, %rcx
movl (%rax,%rcx,4), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpl $0x1, %eax
jne 0x35cffb
movl -0xfc(%rbp), %eax
movl %eax, -0xa0(%rbp)
jmp 0x35d00e
jmp 0x35cffd
movl -0xfc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xfc(%rbp)
jmp 0x35cfad
movl -0x100(%rbp), %eax
subl $0x1, %eax
movl %eax, -0xfc(%rbp)
cmpl $0x0, -0xfc(%rbp)
jl 0x35d075
movq -0xb8(%rbp), %rax
movq -0xf8(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq -0xfc(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
movl (%rax,%rcx,4), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpl $0x1, %eax
jne 0x35d062
movl -0xfc(%rbp), %eax
movl %eax, -0xa4(%rbp)
jmp 0x35d075
jmp 0x35d064
movl -0xfc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xfc(%rbp)
jmp 0x35d01d
cmpl $-0x1, -0xa0(%rbp)
je 0x35d097
cmpl $-0x1, -0xa4(%rbp)
je 0x35d097
movl -0xa0(%rbp), %eax
cmpl -0xa4(%rbp), %eax
jbe 0x35d097
jmp 0x35d107
cmpl $-0x1, -0xa0(%rbp)
je 0x35d0d0
movq -0xb8(%rbp), %rax
movq -0xf8(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl -0xa0(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
xorq $0x1, %rcx
movl (%rax,%rcx,4), %edx
orl $0x80000000, %edx       # imm = 0x80000000
movl %edx, (%rax,%rcx,4)
cmpl $-0x1, -0xa4(%rbp)
je 0x35d105
movq -0xb8(%rbp), %rax
movq -0xf8(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl -0xa4(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
movl (%rax,%rcx,4), %edx
orl $0x80000000, %edx       # imm = 0x80000000
movl %edx, (%rax,%rcx,4)
jmp 0x35d107
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x35cf4a
movq -0xf0(%rbp), %rdi
callq 0xcd6f0
movq $0x0, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0xd0(%rbp)
movl $0x0, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
cmpq -0x30(%rbp), %rax
jae 0x35d5dc
movq -0x28(%rbp), %rax
movl -0x8c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movl %eax, -0x98(%rbp)
movl -0x98(%rbp), %eax
movq -0x28(%rbp), %rcx
movl -0x8c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
addl %ecx, %eax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
movl -0x98(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jbe 0x35d1a5
jmp 0x35d1c4
leaq 0x3c750(%rip), %rdi     # 0x3998fc
leaq 0x39006(%rip), %rsi     # 0x3961b9
movl $0x3450, %edx           # imm = 0x3450
leaq 0x3cad0(%rip), %rcx     # 0x399c8f
callq 0x2130
movl -0x98(%rbp), %eax
movl %eax, -0x90(%rbp)
movq -0xd0(%rbp), %rax
movq %rax, -0x60(%rbp)
movq $-0x1, -0x48(%rbp)
movl -0x90(%rbp), %eax
cmpl -0x9c(%rbp), %eax
jae 0x35d376
movq -0x38(%rbp), %rax
movl -0x90(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0xa8(%rbp)
movq -0xb8(%rbp), %rax
movl -0xa8(%rbp), %ecx
movl (%rax,%rcx,4), %eax
andl $0x80000000, %eax       # imm = 0x80000000
cmpl $0x0, %eax
jne 0x35d247
movq -0xb8(%rbp), %rax
movl -0xa8(%rbp), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
andl $0x80000000, %eax       # imm = 0x80000000
cmpl $0x0, %eax
jne 0x35d247
jmp 0x35d362
cmpq $-0x1, -0x48(%rbp)
je 0x35d33c
movq -0xb8(%rbp), %rax
movl -0xa8(%rbp), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
andl $0x80000000, %eax       # imm = 0x80000000
cmpl $0x0, %eax
je 0x35d33c
jmp 0x35d277
movq -0xd0(%rbp), %rax
cmpq -0xc8(%rbp), %rax
jne 0x35d2de
cmpq $0x0, -0xc8(%rbp)
je 0x35d2a4
movq -0xc8(%rbp), %rax
shlq %rax
movq %rax, -0x118(%rbp)
jmp 0x35d2b2
movl $0x2, %eax
movq %rax, -0x118(%rbp)
jmp 0x35d2b2
movq -0x118(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc0(%rbp), %rdi
movq -0xc8(%rbp), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq -0xd0(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0xd0(%rbp)
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
movq -0x58(%rbp), %rax
movq (%rax), %rcx
shlq $0x20, %rcx
movq %rcx, (%rax)
movl -0x90(%rbp), %eax
movl %eax, %ecx
movq -0x58(%rbp), %rax
orq (%rax), %rcx
movq %rcx, (%rax)
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movq -0xb8(%rbp), %rax
movl -0xa8(%rbp), %ecx
movl (%rax,%rcx,4), %eax
andl $0x80000000, %eax       # imm = 0x80000000
cmpl $0x0, %eax
je 0x35d360
movl -0x90(%rbp), %eax
movq %rax, -0x48(%rbp)
jmp 0x35d362
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x35d1e3
movq -0xd0(%rbp), %rax
movl %eax, -0xac(%rbp)
movq -0x60(%rbp), %rax
movl %eax, -0x90(%rbp)
movl -0x98(%rbp), %eax
movq %rax, -0x48(%rbp)
movl -0x90(%rbp), %eax
cmpl -0xac(%rbp), %eax
jae 0x35d4d2
movq -0xc0(%rbp), %rax
movl -0x90(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x35d4a7
jmp 0x35d3d2
movq -0xd0(%rbp), %rax
cmpq -0xc8(%rbp), %rax
jne 0x35d439
cmpq $0x0, -0xc8(%rbp)
je 0x35d3ff
movq -0xc8(%rbp), %rax
shlq %rax
movq %rax, -0x120(%rbp)
jmp 0x35d40d
movl $0x2, %eax
movq %rax, -0x120(%rbp)
jmp 0x35d40d
movq -0x120(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc0(%rbp), %rdi
movq -0xc8(%rbp), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq -0xd0(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0xd0(%rbp)
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
movq -0x58(%rbp), %rax
movq (%rax), %rcx
shlq $0x20, %rcx
movq %rcx, (%rax)
movq -0x50(%rbp), %rcx
movq -0x58(%rbp), %rax
orq (%rax), %rcx
movq %rcx, (%rax)
movq -0x58(%rbp), %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
orq (%rax), %rcx
movq %rcx, (%rax)
movq -0xc0(%rbp), %rax
movl -0x90(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x48(%rbp)
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x35d397
movl -0x9c(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x35d5c6
jmp 0x35d4f1
movq -0xd0(%rbp), %rax
cmpq -0xc8(%rbp), %rax
jne 0x35d558
cmpq $0x0, -0xc8(%rbp)
je 0x35d51e
movq -0xc8(%rbp), %rax
shlq %rax
movq %rax, -0x128(%rbp)
jmp 0x35d52c
movl $0x2, %eax
movq %rax, -0x128(%rbp)
jmp 0x35d52c
movq -0x128(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc0(%rbp), %rdi
movq -0xc8(%rbp), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq -0xd0(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0xd0(%rbp)
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
movq -0x58(%rbp), %rax
movq (%rax), %rcx
shlq $0x20, %rcx
movq %rcx, (%rax)
movq -0x50(%rbp), %rcx
movq -0x58(%rbp), %rax
orq (%rax), %rcx
movq %rcx, (%rax)
movq -0x58(%rbp), %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
orq (%rax), %rcx
movq %rcx, (%rax)
jmp 0x35d5c8
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x35d14c
movq -0x68(%rbp), %rax
addq -0x70(%rbp), %rax
cmpq -0xd0(%rbp), %rax
jne 0x35d5ef
jmp 0x35d60e
leaq 0x3c6fc(%rip), %rdi     # 0x399cf2
leaq 0x38bbc(%rip), %rsi     # 0x3961b9
movl $0x346d, %edx           # imm = 0x346D
leaq 0x3c686(%rip), %rcx     # 0x399c8f
callq 0x2130
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
shlq %rdi
movl $0x8, %esi
callq 0x2140
movq %rax, -0x108(%rbp)
movq -0xc0(%rbp), %rdi
movq -0xc0(%rbp), %rsi
movq -0xd0(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x30ed90
movq -0x68(%rbp), %rax
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
cmpq -0xd0(%rbp), %rax
jae 0x35d802
movq -0xc0(%rbp), %rcx
movl -0x8c(%rbp), %eax
movl %eax, %edx
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
andq (%rcx,%rdx,8), %rax
cmpq $0x0, %rax
je 0x35d68d
jmp 0x35d6ac
leaq 0x3c672(%rip), %rdi     # 0x399d06
leaq 0x38b1e(%rip), %rsi     # 0x3961b9
movl $0x348c, %edx           # imm = 0x348C
leaq 0x3c5e8(%rip), %rcx     # 0x399c8f
callq 0x2130
movq -0x70(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x70(%rbp)
movq -0xc0(%rbp), %rax
movl -0x8c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shlq %rax
shrq $0x21, %rax
movl %eax, -0x98(%rbp)
movq -0xc0(%rbp), %rax
movl -0x8c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0x98(%rbp), %eax
jbe 0x35d6fd
jmp 0x35d71c
leaq 0x3bdfb(%rip), %rdi     # 0x3994ff
leaq 0x38aae(%rip), %rsi     # 0x3961b9
movl $0x348d, %edx           # imm = 0x348D
leaq 0x3c578(%rip), %rcx     # 0x399c8f
callq 0x2130
movl -0x98(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %eax
cmpl -0x9c(%rbp), %eax
jae 0x35d79c
movq -0x108(%rbp), %rax
movq -0x38(%rbp), %rcx
movl -0x90(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x108(%rbp), %rax
movq -0x38(%rbp), %rcx
movl -0x90(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
xorq $0x1, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x35d72b
movq -0x108(%rbp), %rax
movq -0x38(%rbp), %rcx
movl -0x98(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x108(%rbp), %rax
movq -0x38(%rbp), %rcx
movl -0x9c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
xorq $0x1, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x35d655
movq -0x68(%rbp), %rax
movq %rax, -0xd0(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x35d816
jmp 0x35d835
leaq 0x3c511(%rip), %rdi     # 0x399d2e
leaq 0x38995(%rip), %rsi     # 0x3961b9
movl $0x3497, %edx           # imm = 0x3497
leaq 0x3c45f(%rip), %rcx     # 0x399c8f
callq 0x2130
movl $0x0, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
cmpq -0x68(%rbp), %rax
jae 0x35dd14
movq -0xc0(%rbp), %rax
movl -0x8c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movl %eax, -0x98(%rbp)
movq -0xc0(%rbp), %rax
movl -0x8c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0x98(%rbp), %eax
jbe 0x35d891
jmp 0x35d8b0
leaq 0x3bc67(%rip), %rdi     # 0x3994ff
leaq 0x3891a(%rip), %rsi     # 0x3961b9
movl $0x3499, %edx           # imm = 0x3499
leaq 0x3c3e4(%rip), %rcx     # 0x399c8f
callq 0x2130
cmpl $0xc81, -0x8c(%rbp)     # imm = 0xC81
je 0x35d8cc
cmpl $0xc82, -0x8c(%rbp)     # imm = 0xC82
jne 0x35d966
movq 0x6670d(%rip), %rax     # 0x3c3fe0
movq (%rax), %rdi
movl -0x98(%rbp), %ecx
movl -0x9c(%rbp), %r8d
movq -0x38(%rbp), %rax
movl -0x98(%rbp), %edx
movq (%rax,%rdx,8), %r9
movq -0xb8(%rbp), %rax
movq -0x38(%rbp), %rdx
movl -0x98(%rbp), %esi
movq (%rdx,%rsi,8), %rdx
movl (%rax,%rdx,4), %r11d
andl $0x7fffffff, %r11d      # imm = 0x7FFFFFFF
movq -0x38(%rbp), %rax
movl -0x9c(%rbp), %edx
movq (%rax,%rdx,8), %r10
xorq $0x1, %r10
movq -0xb8(%rbp), %rax
movq -0x38(%rbp), %rdx
movl -0x9c(%rbp), %esi
movq (%rdx,%rsi,8), %rdx
xorq $0x1, %rdx
movl (%rax,%rdx,4), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
leaq 0x3c3ed(%rip), %rsi     # 0x399d38
leaq 0x3c430(%rip), %rdx     # 0x399d82
movl %r11d, (%rsp)
movq %r10, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movb $0x0, %al
callq 0x22a0
movq -0xc0(%rbp), %rcx
movl -0x8c(%rbp), %eax
movl %eax, %edx
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
andq (%rcx,%rdx,8), %rax
cmpq $0x0, %rax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x35d992
jmp 0x35d994
jmp 0x35d9b3
leaq 0x3c3fc(%rip), %rdi     # 0x399d97
leaq 0x38817(%rip), %rsi     # 0x3961b9
movl $0x34a0, %edx           # imm = 0x34A0
leaq 0x3c2e1(%rip), %rcx     # 0x399c8f
callq 0x2130
movl -0x98(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %eax
cmpl -0x9c(%rbp), %eax
jae 0x35db74
jmp 0x35d9d6
movq -0xd0(%rbp), %rax
cmpq -0xc8(%rbp), %rax
jne 0x35da3d
cmpq $0x0, -0xc8(%rbp)
je 0x35da03
movq -0xc8(%rbp), %rax
shlq %rax
movq %rax, -0x130(%rbp)
jmp 0x35da11
movl $0x2, %eax
movq %rax, -0x130(%rbp)
jmp 0x35da11
movq -0x130(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc0(%rbp), %rdi
movq -0xc8(%rbp), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq -0xd0(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0xd0(%rbp)
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rax
movl -0x90(%rbp), %ecx
movq (%rax,%rcx,8), %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
movq -0x58(%rbp), %rax
movq (%rax), %rcx
shlq $0x20, %rcx
movq %rcx, (%rax)
movl -0x8c(%rbp), %eax
movl %eax, %ecx
movq -0x58(%rbp), %rax
orq (%rax), %rcx
movq %rcx, (%rax)
movq -0xd0(%rbp), %rax
cmpq -0xc8(%rbp), %rax
jne 0x35db00
cmpq $0x0, -0xc8(%rbp)
je 0x35dac6
movq -0xc8(%rbp), %rax
shlq %rax
movq %rax, -0x138(%rbp)
jmp 0x35dad4
movl $0x2, %eax
movq %rax, -0x138(%rbp)
jmp 0x35dad4
movq -0x138(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc0(%rbp), %rdi
movq -0xc8(%rbp), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq -0xd0(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0xd0(%rbp)
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rax
movl -0x90(%rbp), %ecx
movq (%rax,%rcx,8), %rcx
xorq $0x1, %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
movq -0x58(%rbp), %rax
movq (%rax), %rcx
shlq $0x20, %rcx
movq %rcx, (%rax)
movl -0x8c(%rbp), %eax
movl %eax, %ecx
movq -0x58(%rbp), %rax
orq (%rax), %rcx
movq %rcx, (%rax)
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x35d9c2
jmp 0x35db76
movq -0xd0(%rbp), %rax
cmpq -0xc8(%rbp), %rax
jne 0x35dbdd
cmpq $0x0, -0xc8(%rbp)
je 0x35dba3
movq -0xc8(%rbp), %rax
shlq %rax
movq %rax, -0x140(%rbp)
jmp 0x35dbb1
movl $0x2, %eax
movq %rax, -0x140(%rbp)
jmp 0x35dbb1
movq -0x140(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc0(%rbp), %rdi
movq -0xc8(%rbp), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq -0xd0(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0xd0(%rbp)
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rax
movl -0x98(%rbp), %ecx
movq (%rax,%rcx,8), %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
movq -0x58(%rbp), %rax
movq (%rax), %rcx
shlq $0x20, %rcx
movq %rcx, (%rax)
movl -0x8c(%rbp), %eax
movl %eax, %ecx
movq -0x58(%rbp), %rax
orq (%rax), %rcx
movq %rcx, (%rax)
movq -0xd0(%rbp), %rax
cmpq -0xc8(%rbp), %rax
jne 0x35dca0
cmpq $0x0, -0xc8(%rbp)
je 0x35dc66
movq -0xc8(%rbp), %rax
shlq %rax
movq %rax, -0x148(%rbp)
jmp 0x35dc74
movl $0x2, %eax
movq %rax, -0x148(%rbp)
jmp 0x35dc74
movq -0x148(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc0(%rbp), %rdi
movq -0xc8(%rbp), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq -0xd0(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0xd0(%rbp)
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rax
movl -0x9c(%rbp), %ecx
movq (%rax,%rcx,8), %rcx
xorq $0x1, %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
movq -0x58(%rbp), %rax
movq (%rax), %rcx
shlq $0x20, %rcx
movq %rcx, (%rax)
movl -0x8c(%rbp), %eax
movl %eax, %ecx
movq -0x58(%rbp), %rax
orq (%rax), %rcx
movq %rcx, (%rax)
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x35d83f
movq -0xc0(%rbp), %rdi
movq -0x68(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0xc0(%rbp), %rsi
movq -0xd0(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x30ed90
movq -0x68(%rbp), %rax
addq $0x1, %rax
movl %eax, -0x90(%rbp)
movq -0x68(%rbp), %rax
movl %eax, -0x8c(%rbp)
movl -0x90(%rbp), %eax
cmpq -0xd0(%rbp), %rax
ja 0x35de04
movl -0x90(%rbp), %eax
cmpq -0xd0(%rbp), %rax
je 0x35dda9
movq -0xc0(%rbp), %rax
movl -0x90(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq -0xc0(%rbp), %rcx
movl -0x8c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
cmpq %rcx, %rax
je 0x35ddee
movl -0x8c(%rbp), %eax
movl %eax, %edx
shlq $0x20, %rdx
movl -0x90(%rbp), %eax
orq %rax, %rdx
movq -0x108(%rbp), %rax
movq -0xc0(%rbp), %rcx
movl -0x8c(%rbp), %esi
movq (%rcx,%rsi,8), %rcx
shrq $0x20, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x90(%rbp), %eax
movl %eax, -0x8c(%rbp)
jmp 0x35ddf0
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x35dd58
movq -0x68(%rbp), %rsi
movq -0x108(%rbp), %rdx
movq -0x38(%rbp), %rcx
leaq -0xd0(%rbp), %rdi
leaq -0xe8(%rbp), %r8
callq 0x356dd0
movl %eax, %eax
movq %rax, -0x110(%rbp)
movq 0x661aa(%rip), %rax     # 0x3c3fe0
movq (%rax), %rdi
movq -0x68(%rbp), %rcx
movq -0x110(%rbp), %r8
leaq 0x3bf77(%rip), %rsi     # 0x399dc2
leaq 0x3bf30(%rip), %rdx     # 0x399d82
movb $0x0, %al
callq 0x22a0
movq -0xd0(%rbp), %rax
movq -0x68(%rbp), %rcx
shlq %rcx
cmpq %rcx, %rax
jne 0x35de6e
jmp 0x35de8d
leaq 0x3bf73(%rip), %rdi     # 0x399de8
leaq 0x3833d(%rip), %rsi     # 0x3961b9
movl $0x34c0, %edx           # imm = 0x34C0
leaq 0x3be07(%rip), %rcx     # 0x399c8f
callq 0x2130
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x68(%rbp), %r8
movq -0x110(%rbp), %r9
movq -0x108(%rbp), %r14
movq -0x38(%rbp), %rbx
movq -0x88(%rbp), %r11
movq -0xb8(%rbp), %r10
movl -0x3c(%rbp), %eax
leaq -0xd0(%rbp), %rdx
leaq -0xe8(%rbp), %rcx
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movl %eax, 0x20(%rsp)
callq 0x35c7f0
movq -0xb8(%rbp), %rdi
callq 0x2210
movq -0x108(%rbp), %rdi
callq 0x2210
movq -0x88(%rbp), %rdi
callq 0x2210
movq -0xc0(%rbp), %rdi
callq 0x2210
movq -0xd8(%rbp), %rdi
callq 0x2210
movq -0xd0(%rbp), %rax
subq -0x68(%rbp), %rax
addq $0x160, %rsp            # imm = 0x160
popq %rbx
popq %r14
popq %rbp
retq
nopl (%rax)