// File: /workspace/github_c_makefile_star2_O3/c-zhou[P]yahs/link.c
// Function: dump_links_from_bam_file
void dump_links_from_bam_file(const char *f, const char *fai, uint32_t ml, uint8_t mq, double q_drop, const char *out)
{
    bamFile fp;
    FILE *fo;
    bam_header_t *h;
    bam1_t *b;
    char *cname0, *cname1, *rname0, *rname1;
    int32_t s0, s1, e0, e1, first;
    uint32_t i0, i1, p0, p1;
    uint8_t q, q0, q1;
    int8_t buff;
    uint64_t rec_c, pair_c, inter_c, intra_c, sd_l, n, m, max_m;
    enum bam_sort_order so;
    cov_t *cov;
    
    khash_t(str) *hmseq; // for absent sequences
    khint_t k;
    int absent;
    hmseq = kh_init(str);

    sdict_t *dict = make_sdict_from_index(fai, ml);
    
    fp = bam_open(f, "r");
    if (fp == NULL) {
        fprintf(stderr, "[E::%s] cannot open file %s for reading\n", __func__, f);
        exit(EXIT_FAILURE);
    }
    
    fo = fopen(out, "w");
    if (fo == NULL) {
        fprintf(stderr, "[E::%s] cannot open file %s for writing\n", __func__, out);
        exit(EXIT_FAILURE);
    }
    write_bin_header(fo);
    sd_l = write_sequence_dictionary(fo, dict);

    h = bam_header_read(fp);
    b = bam_init1();
    so = bam_hrecs_sort_order(h);
    cname0 = cname1 = rname0 = rname1 = 0;
    s0 = s1 = e0 = e1 = 0;
    i0 = i1 = p0 = p1 = 0;
    rec_c = pair_c = inter_c = intra_c = 0;
    buff = 0;
    cov = cov_init(dict->n);
    n = 0;
    max_m = 0x7FFFFFFULL; // 128MB - ~1GB mem for covs

    fwrite(&pair_c, sizeof(uint64_t), 1, fo);

    if (so == ORDER_NAME) {
        // sorted by read names
        while (bam_read1(fp, b) >= 0 ) {

            if (buff == 0) {
                q0 = 255;
                rname0 = parse_bam_rec(b, h, &s0, &e0, &q0, &cname0);
                if (!rname0)
                    continue;
                ++buff;
            } else if (buff == 1) {
                q1 = 255;
                rname1 = parse_bam_rec(b, h, &s1, &e1, &q1, &cname1);
                if (!rname1)
                    continue;
                if (strcmp(rname0, rname1) == 0) {
                    buff = 0;

                    i0 = sd_get(dict, cname0);
                    i1 = sd_get(dict, cname1);
                    q = MIN(q0, q1);

                    if (i0 == UINT32_MAX) {
                        k = kh_put(str, hmseq, cname0, &absent);
                        if (absent) {
                            kh_key(hmseq, k) = strdup(cname0);
                            fprintf(stderr, "[W::%s] sequence \"%s\" not found \n", __func__, cname0);
                        }
                    } else if (i1 == UINT32_MAX) {
                        k = kh_put(str, hmseq, cname1, &absent);
                        if (absent) {
                            kh_key(hmseq, k) = strdup(cname1);
                            fprintf(stderr, "[W::%s] sequence \"%s\" not found \n", __func__, cname1);
                        }
                    } else if (q >= mq) {
                        // update read coverage
                        // fix bad alignments
                        s0 = MIN_MAX(s0, 0, dict->s[i0].len - 1);
                        e0 = MIN_MAX(e0, 0, dict->s[i0].len - 1);
                        s1 = MIN_MAX(s1, 0, dict->s[i1].len - 1);
                        e1 = MIN_MAX(e1, 0, dict->s[i1].len - 1);
                        kv_push(uint64_t, cov->p[i0], (uint64_t) s0 << 32 | (uint32_t) 1);
                        kv_push(uint64_t, cov->p[i0], (uint64_t) e0 << 32 | (uint32_t) -1);
                        kv_push(uint64_t, cov->p[i1], (uint64_t) s1 << 32 | (uint32_t) 1);
                        kv_push(uint64_t, cov->p[i1], (uint64_t) e1 << 32 | (uint32_t) -1);
                        n += 4;
                        if (n > max_m) {
                            m = pos_compression(cov); // m is the position size after compression
                            fprintf(stderr, "[I::%s] position compression n = %lu, m = %lu, max_m = %lu\n", __func__, n, m, max_m);
                            if (m > n>>1) {
                                max_m <<= 1; // increase m limit if compression ratio smaller than 0.5
                                fprintf(stderr, "[I::%s] position memory buffer expanded max_m = %lu\n", __func__, max_m);
                            }
                            n = m;
                        }

                        // from zero-based to one-based
                        p0 = s0 / 2 + e0 / 2 + (s0 & 1 && e0 & 1);
                        p1 = s1 / 2 + e1 / 2 + (s1 & 1 && e1 & 1);
                        if (i0 > i1) {
                            SWAP(uint32_t, i0, i1);
                            SWAP(uint32_t, p0, p1);
                        }
                        fwrite(&i0, sizeof(uint32_t), 1, fo);
                        fwrite(&p0, sizeof(uint32_t), 1, fo);
                        fwrite(&i1, sizeof(uint32_t), 1, fo);
                        fwrite(&p1, sizeof(uint32_t), 1, fo);
                        fwrite(&q, sizeof(uint8_t), 1, fo);

                        if (i0 == i1)
                            ++intra_c;
                        else
                            ++inter_c;

                        ++pair_c;
                    }
                    
                    free(rname0);
                    free(rname1);
                    rname0 = 0;
                    rname1 = 0;
                } else {
                    buff = 1;

                    cname0 = cname1;
                    s0 = s1;
                    e0 = e1;
                    q0 = q1;
                    free(rname0);
                    rname0 = rname1;
                    rname1 = 0;
                }
            }

            if (++rec_c % 1000000 == 0)
                fprintf(stderr, "[I::%s] %lu million records processed, %lu read pairs \n", __func__, rec_c / 1000000, pair_c);
        }
    } else {
        // sorted by coordinates or others
        if (mq > 0)
            fprintf(stderr, "[W::%s] BAM file is not sorted by read name. Filtering by mapping quality %hhu suppressed \n", __func__, mq);
        q = 255;

        while (bam_read1(fp, b) >= 0) {

            first = parse_bam_rec1(b, h, &cname0, &s0, &e0, &cname1, &s1);

            if (first < 0) continue; // read not paired or not primary

            i0 = sd_get(dict, cname0);
            if (i0 != UINT32_MAX) {
                // update read coverage
                // fix bad alignments
                s0 = MIN_MAX(s0, 0, dict->s[i0].len - 1);
                e0 = MIN_MAX(e0, 0, dict->s[i0].len - 1);
                kv_push(uint64_t, cov->p[i0], (uint64_t) s0 << 32 | (uint32_t) 1);
                kv_push(uint64_t, cov->p[i0], (uint64_t) e0 << 32 | (uint32_t) -1);
                n += 2;
                if (n > max_m) {
                    m = pos_compression(cov); // m is the position size after compression
                    fprintf(stderr, "[I::%s] position compression n = %lu, m = %lu, max_m = %lu\n", __func__, n, m, max_m);
                    if (m > n>>1) {
                        max_m <<= 1; // increase m limit if compression ratio smaller than 0.5
                        fprintf(stderr, "[I::%s] position memory buffer expanded max_m = %lu\n", __func__, max_m);
                    }
                    n = m;
                }
            }

            if (first == 0) { // second read only for each read pair
                // i0 = sd_get(dict, cname0);
                i1 = sd_get(dict, cname1);

                if (i0 == UINT32_MAX) {
                    k = kh_put(str, hmseq, cname0, &absent);
                    if (absent) {
                        kh_key(hmseq, k) = strdup(cname0);
                        fprintf(stderr, "[W::%s] sequence \"%s\" not found \n", __func__, cname0);
                    }
                } else if (i1 == UINT32_MAX) {
                    k = kh_put(str, hmseq, cname1, &absent);
                    if (absent) {
                        kh_key(hmseq, k) = strdup(cname1);
                        fprintf(stderr, "[W::%s] sequence \"%s\" not found \n", __func__, cname1);
                    }
                } else {
                    // fix bad alignments
                    s1 = MIN_MAX(s1, 0, dict->s[i1].len - 1);
                    if (i0 > i1) {
                        SWAP(uint32_t, i0, i1);
                        SWAP(uint32_t, s0, s1);
                    }
                    fwrite(&i0, sizeof(uint32_t), 1, fo);
                    fwrite(&s0, sizeof(uint32_t), 1, fo);
                    fwrite(&i1, sizeof(uint32_t), 1, fo);
                    fwrite(&s1, sizeof(uint32_t), 1, fo);
                    fwrite(&q, sizeof(uint8_t), 1, fo);

                    if (i0 == i1)
                        ++intra_c;
                    else
                        ++inter_c;

                    ++pair_c;
                }
            }

            if (++rec_c % 1000000 == 0)
                fprintf(stderr, "[I::%s] %lu million records processed, %lu read pairs \n", __func__, rec_c / 1000000, pair_c);
        }
    }

    m = pos_compression(cov);
    fprintf(stderr, "[I::%s] position compression n = %lu, m = %lu, max_m = %lu\n", __func__, n, m, max_m);

    for (k = 0; k < kh_end(hmseq); ++k)
        if (kh_exist(hmseq, k))
            free((char *) kh_key(hmseq, k));
    kh_destroy(str, hmseq);

    if (rname0)
        free(rname0);
    if (rname1)
        free(rname1);
    bam_destroy1(b);
    bam_header_destroy(h);
    bam_close(fp);
    // write pair number
    fseek(fo, sizeof(uint64_t) + sd_l, SEEK_SET);
    fwrite(&pair_c, sizeof(uint64_t), 1, fo);
    fseek(fo, pair_c * 17, SEEK_CUR);

    fprintf(stderr, "[I::%s] dumped %lu read pairs from %lu records: %lu intra links + %lu inter links \n", __func__, pair_c, rec_c, intra_c, inter_c);

    // cov_t *cov = bam_cstats(f, dict, 0);
    cov_norm_t *cov_norm = calc_cov_norms(cov, dict, q_drop);
    fwrite(&cov_norm->n, sizeof(uint64_t), 1, fo);
    fwrite(cov_norm->norm[0], sizeof(double), cov_norm->n, fo);
    cov_destroy(cov);
    cov_norm_destroy(cov_norm);

    sd_destroy(dict);
    fclose(fo);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %r8, %rbx
movsd %xmm0, 0x110(%rsp)
movl %ecx, 0x98(%rsp)
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %r14
movl $0x1, %esi
movl $0x28, %edx
xorl %edi, %edi
callq 0xbf84
movq %rax, %r13
movq %r15, %rdi
movl %ebp, %esi
callq 0x12d2b
movq %rax, %r15
leaq 0x13875(%rip), %rsi     # 0x23449
movq %r14, %rdi
callq 0x55c3
testq %rax, %rax
je 0x10aed
movq %rax, %r12
leaq 0x12421(%rip), %rsi     # 0x22010
movq %rbx, %rdi
callq 0x23e0
testq %rax, %rax
je 0x10af5
movq %rax, %rbp
movq %rax, %rdi
callq 0x4b59
movq %rbp, %rdi
movq %r15, %rsi
callq 0x165a9
movq %rax, 0x108(%rsp)
movq %r12, %rdi
callq 0x4f95
movq %rax, %rbx
movl $0x1, %edi
movl $0x38, %esi
callq 0x2290
movq %r15, %r14
movq %rax, %r15
movq %rbx, 0x90(%rsp)
movq %rbx, %rdi
callq 0x543b
movl %eax, 0x28(%rsp)
xorl %eax, %eax
movq %rax, 0xd8(%rsp)
movq %rax, 0xe0(%rsp)
movl %eax, 0x60(%rsp)
movl %eax, 0x64(%rsp)
movl %eax, 0x1c(%rsp)
movl %eax, 0xc(%rsp)
movl %eax, 0x80(%rsp)
movl %eax, 0x84(%rsp)
leaq 0xb8(%rsp), %rbx
movq %rax, (%rbx)
movl (%r14), %edi
callq 0x16f08
movq %rax, 0x20(%rsp)
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rdi
movq %rbp, 0xc0(%rsp)
movq %rbp, %rcx
callq 0x24d0
cmpl $0x1, 0x28(%rsp)
movq %r14, 0x78(%rsp)
jne 0x103d0
movq 0xb8(%rsp), %rax
movq %rax, 0x88(%rsp)
movq %r13, %rax
addq $0x18, %rax
movq %rax, 0xf0(%rsp)
movl $0x7ffffff, %eax        # imm = 0x7FFFFFF
movq %rax, 0x40(%rsp)
movq $0x0, 0x48(%rsp)
movq $0x0, 0xb0(%rsp)
movq $0x0, 0xa8(%rsp)
movq $0x0, 0x38(%rsp)
xorl %ebx, %ebx
xorl %r14d, %r14d
movq 0x90(%rsp), %rbp
testb %bl, %bl
sete %bl
movq %r14, 0x28(%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x5195
testl %eax, %eax
js 0x108e4
testb $0x1, %bl
jne 0xfd79
movb $-0x1, 0xa(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
leaq 0x1c(%rsp), %rdx
leaq 0x60(%rsp), %rcx
leaq 0xa(%rsp), %r8
leaq 0xd8(%rsp), %r9
callq 0x10afd
xorl %ebx, %ebx
testq %rax, %rax
je 0xfd31
jmp 0xfdbd
movb $-0x1, 0xb(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
leaq 0xc(%rsp), %rdx
leaq 0x64(%rsp), %rcx
leaq 0xb(%rsp), %r8
leaq 0xe0(%rsp), %r9
callq 0x10afd
movq %rax, %r14
movb $0x1, %bl
movl $0x0, %eax
movq %rax, 0x28(%rsp)
testq %r14, %r14
je 0xfd31
jmp 0x102a0
movq %rax, %r14
movq 0x28(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x22a0
testl %eax, %eax
je 0xfe0b
movq 0xd8(%rsp), %rax
movq %rax, 0xe0(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, 0xc(%rsp)
movl 0x60(%rsp), %eax
movl %eax, 0x64(%rsp)
movb 0xa(%rsp), %al
movb %al, 0xb(%rsp)
movq %rbx, %rdi
callq 0x2060
movb $0x1, %bl
jmp 0x102a0
movq %rbx, 0x28(%rsp)
movq 0xe0(%rsp), %rsi
movq 0x78(%rsp), %rdi
movq %rsi, 0x50(%rsp)
callq 0x12707
movl %eax, %ebx
movl %eax, 0x18(%rsp)
movq 0xd8(%rsp), %rsi
movq 0x78(%rsp), %rdi
movq %rsi, 0x30(%rsp)
callq 0x12707
movl %eax, %edi
movl %eax, 0x14(%rsp)
movzbl 0xb(%rsp), %eax
movzbl 0xa(%rsp), %ecx
cmpb %cl, %al
cmovbl %eax, %ecx
cmpl $-0x1, %ebx
je 0x10242
cmpl $-0x1, %edi
je 0x10269
movl %ebx, %esi
cmpb 0x98(%rsp), %cl
movq 0x28(%rsp), %rbx
jb 0x1028b
movl %ecx, 0xa0(%rsp)
movl 0xc(%rsp), %r8d
testl %r8d, %r8d
movl $0x0, %edx
cmovlel %edx, %r8d
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rax
movl %esi, %r10d
leaq (,%r10,8), %rcx
leaq (%rcx,%rcx,2), %rbx
movl 0x10(%rax,%rbx), %ecx
decl %ecx
cmpl %ecx, %r8d
cmovael %ecx, %r8d
movl %r8d, 0xc(%rsp)
movl 0x64(%rsp), %r9d
testl %r9d, %r9d
cmovlel %edx, %r9d
cmpl %ecx, %r9d
cmovael %ecx, %r9d
movq %r9, 0x50(%rsp)
movl %r9d, 0x64(%rsp)
movl 0x1c(%rsp), %ecx
testl %ecx, %ecx
cmovlel %edx, %ecx
movl %edi, %r9d
movq %r9, 0xf8(%rsp)
leaq (%r9,%r9,2), %r9
movq %r9, 0x30(%rsp)
movl 0x10(%rax,%r9,8), %eax
decl %eax
cmpl %eax, %ecx
cmovael %eax, %ecx
movq %rcx, 0x70(%rsp)
movl %ecx, 0x1c(%rsp)
movl 0x60(%rsp), %r9d
testl %r9d, %r9d
cmovlel %edx, %r9d
cmpl %eax, %r9d
cmovael %eax, %r9d
movl %r9d, 0x60(%rsp)
movq 0x20(%rsp), %rbp
movq 0x8(%rbp), %rcx
movq (%rcx,%rbx), %rdx
cmpq 0x8(%rcx,%rbx), %rdx
movq %r8, 0x58(%rsp)
movl %esi, 0xec(%rsp)
movl %edi, 0xe8(%rsp)
movq %r9, 0x68(%rsp)
jne 0xff9c
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %eax
cmoveq %rax, %rsi
leaq (%rcx,%rbx), %rax
movq %rsi, 0x8(%rcx,%rbx)
movq 0x10(%rax), %rdi
shlq $0x3, %rsi
movq %r10, 0x100(%rsp)
callq 0x2390
movq 0x100(%rsp), %r10
movq 0x58(%rsp), %r8
movq 0x8(%rbp), %rcx
movq %rax, 0x10(%rcx,%rbx)
movq (%rcx,%rbx), %rdx
movq %r8, %rsi
shlq $0x20, %rsi
incq %rsi
leaq (%r10,%r10,2), %rbp
movq 0x10(%rcx,%rbp,8), %rax
leaq 0x1(%rdx), %rdi
movq %rdi, (%rcx,%rbp,8)
movq %rsi, (%rax,%rdx,8)
movq (%rcx,%rbp,8), %rdx
cmpq 0x8(%rcx,%rbp,8), %rdx
jne 0xfff9
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %edx
cmoveq %rdx, %rsi
movq %rsi, 0x8(%rcx,%rbx)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2390
movq 0x20(%rsp), %rcx
movq 0x8(%rcx), %rcx
movq %rax, 0x10(%rcx,%rbx)
movq (%rcx,%rbx), %rdx
movq 0x30(%rsp), %r11
movq 0x50(%rsp), %rsi
shlq $0x20, %rsi
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
orq %rdi, %rsi
leaq 0x1(%rdx), %rdi
movq %rdi, (%rcx,%rbp,8)
movq %rsi, (%rax,%rdx,8)
movq (%rcx,%r11,8), %rdx
cmpq 0x8(%rcx,%r11,8), %rdx
jne 0x10077
leaq (%rcx,%r11,8), %rax
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %edx
cmoveq %rdx, %rsi
movq 0xf8(%rsp), %rdx
leaq (,%rdx,8), %rdx
leaq (%rdx,%rdx,2), %rbx
movq %rsi, 0x8(%rcx,%rbx)
movq 0x10(%rax), %rdi
shlq $0x3, %rsi
callq 0x2390
movq 0x30(%rsp), %r11
movq 0x20(%rsp), %rcx
movq 0x8(%rcx), %rcx
movq %rax, 0x10(%rcx,%rbx)
movq (%rcx,%rbx), %rdx
movq 0x90(%rsp), %rbp
movq 0x70(%rsp), %r9
movq %r9, %rsi
shlq $0x20, %rsi
incq %rsi
movq 0x10(%rcx,%r11,8), %rax
leaq 0x1(%rdx), %rdi
movq %rdi, (%rcx,%r11,8)
movq %rsi, (%rax,%rdx,8)
movq (%rcx,%r11,8), %rdx
cmpq 0x8(%rcx,%r11,8), %rdx
jne 0x100f7
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %edx
cmoveq %rdx, %rsi
movq 0xf8(%rsp), %rdx
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %rbx
movq %rsi, 0x8(%rcx,%rbx)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2390
movq 0x30(%rsp), %r11
movq 0x70(%rsp), %r9
movq 0x20(%rsp), %rcx
movq 0x8(%rcx), %rcx
movq %rax, 0x10(%rcx,%rbx)
movq (%rcx,%rbx), %rdx
movq 0x48(%rsp), %rbx
movq 0x58(%rsp), %r8
movq 0x68(%rsp), %r10
movq %r10, %rsi
shlq $0x20, %rsi
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
orq %rdi, %rsi
leaq 0x1(%rdx), %rdi
movq %rdi, (%rcx,%r11,8)
movq %rsi, (%rax,%rdx,8)
addq $0x4, %rbx
cmpq 0x40(%rsp), %rbx
ja 0x10345
movq %rbx, 0x48(%rsp)
movl %r8d, %eax
shrl %eax
movq 0x50(%rsp), %rcx
andl %ecx, %r8d
shrl %ecx
addl %eax, %ecx
andl $0x1, %r8d
addl %ecx, %r8d
movl %r8d, 0x84(%rsp)
movl %r9d, %eax
shrl %eax
andl %r10d, %r9d
shrl %r10d
addl %eax, %r10d
andl $0x1, %r9d
addl %r10d, %r9d
movl %r9d, 0x80(%rsp)
movl 0xec(%rsp), %eax
movl 0xe8(%rsp), %ecx
cmpl %ecx, %eax
jbe 0x1019c
movl %ecx, 0x18(%rsp)
movl %eax, 0x14(%rsp)
movl %r9d, 0x84(%rsp)
movl %r8d, 0x80(%rsp)
movl $0x4, %esi
movl $0x1, %edx
leaq 0x18(%rsp), %rdi
movq 0xc0(%rsp), %rbx
movq %rbx, %rcx
callq 0x24d0
movl $0x4, %esi
movl $0x1, %edx
leaq 0x84(%rsp), %rdi
movq %rbx, %rcx
callq 0x24d0
movl $0x4, %esi
movl $0x1, %edx
leaq 0x14(%rsp), %rdi
movq %rbx, %rcx
callq 0x24d0
movl $0x4, %esi
movl $0x1, %edx
leaq 0x80(%rsp), %rdi
movq %rbx, %rcx
callq 0x24d0
movsbl 0xa0(%rsp), %edi
movq %rbx, %rsi
callq 0x2260
movl 0x18(%rsp), %eax
xorl %ecx, %ecx
xorl %edx, %edx
cmpl 0x14(%rsp), %eax
setne %cl
sete %dl
addq %rdx, 0xb0(%rsp)
addq %rcx, 0xa8(%rsp)
incq 0x88(%rsp)
jmp 0x10262
movq %r13, %rdi
movq 0x50(%rsp), %rbx
movq %rbx, %rsi
leaq 0x10(%rsp), %rdx
callq 0x10b5c
cmpl $0x0, 0x10(%rsp)
jne 0x10315
movq 0x28(%rsp), %rbx
jmp 0x1028b
movq %r13, %rdi
movq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x10b5c
cmpl $0x0, 0x10(%rsp)
movq 0x28(%rsp), %rbx
jne 0x1032c
movq %rbx, %rdi
callq 0x2060
movq %r14, %rdi
callq 0x2060
xorl %ebx, %ebx
xorl %r14d, %r14d
movq 0x38(%rsp), %rsi
incq %rsi
movq %rsi, %rax
movabsq $0x431bde82d7b634db, %rcx # imm = 0x431BDE82D7B634DB
mulq %rcx
movq %rdx, %rcx
movq %rsi, 0x38(%rsp)
movabsq $0x790fb65668c26139, %rdx # imm = 0x790FB65668C26139
imulq %rdx, %rsi
rorq $0x6, %rsi
movabsq $0x10c6f7a0b5ed, %rdx   # imm = 0x10C6F7A0B5ED
cmpq %rdx, %rsi
ja 0xfd27
shrq $0x12, %rcx
movq 0x1bd08(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
leaq 0x12768(%rip), %rsi     # 0x22a62
leaq 0x1268c(%rip), %rdx     # 0x2298d
movq 0x88(%rsp), %r8
xorl %eax, %eax
callq 0x22c0
jmp 0xfd27
movq %rbx, %rdi
movq 0xf0(%rsp), %rsi
movl %eax, %edx
callq 0x2a8b
jmp 0x10262
movq 0x30(%rsp), %rdi
movq 0xf0(%rsp), %rsi
movl %eax, %edx
callq 0x2a49
jmp 0x1028b
movq 0x20(%rsp), %rdi
callq 0x16fc1
movq %rax, %r8
movq %rax, 0x30(%rsp)
movq 0x1bc9a(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
leaq 0x12689(%rip), %rsi     # 0x229f1
leaq 0x1261e(%rip), %rdx     # 0x2298d
movq %rbx, %rcx
movq 0x40(%rsp), %r9
xorl %eax, %eax
callq 0x22c0
shrq %rbx
movq 0x30(%rsp), %rax
cmpq %rbx, %rax
movq %rax, %rbx
ja 0x103a2
movq 0x58(%rsp), %r8
movq 0x70(%rsp), %r9
movq 0x68(%rsp), %r10
jmp 0x10130
movq 0x40(%rsp), %rcx
addq %rcx, %rcx
movq 0x1bc47(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
leaq 0x12672(%rip), %rsi     # 0x22a2d
leaq 0x125cb(%rip), %rdx     # 0x2298d
movq %rcx, 0x40(%rsp)
xorl %eax, %eax
callq 0x22c0
jmp 0x1038e
movl 0x98(%rsp), %eax
testb %al, %al
jne 0x10ae0
movq 0xb8(%rsp), %rax
movq %rax, 0x88(%rsp)
movq %r13, %rax
addq $0x18, %rax
movq %rax, 0xa0(%rsp)
movl $0x7ffffff, %eax        # imm = 0x7FFFFFF
movq %rax, 0x40(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x48(%rsp)
movq $0x0, 0xb0(%rsp)
movq $0x0, 0xa8(%rsp)
movq $0x0, 0x38(%rsp)
movq 0x20(%rsp), %rbx
movq %r13, 0xd0(%rsp)
movq %r12, 0xc8(%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x5195
testl %eax, %eax
js 0x108e9
movq 0x8(%r15), %rax
shrq $0x20, %rax
testl $0xf0c, %eax            # imm = 0xF0C
setne %cl
testw %ax, %ax
sete %al
orb %cl, %al
jne 0x10450
movq 0x90(%rsp), %rbx
movq 0x8(%rbx), %rax
movslq (%r15), %rcx
movq (%rax,%rcx,8), %rbp
movl 0x4(%r15), %r13d
movl %r13d, 0xc(%rsp)
movq %r15, %rdi
callq 0x5589
movl %eax, %r14d
movq 0x8(%rbx), %rax
movslq 0x14(%r15), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x98(%rsp)
movl 0x18(%r15), %r12d
movq 0x8(%r15), %rax
movq %rax, 0x50(%rsp)
movq 0x78(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, 0x30(%rsp)
movq %rbp, %rsi
callq 0x12707
movl %eax, 0x18(%rsp)
cmpl $-0x1, %eax
movl %r12d, 0x70(%rsp)
je 0x10641
testl %r13d, %r13d
movl $0x0, %edx
cmovlel %edx, %r13d
movq 0x8(%rbx), %rsi
movl %eax, %edi
leaq (,%rdi,8), %rcx
leaq (%rcx,%rcx,2), %rbp
movl 0x10(%rsi,%rbp), %esi
decl %esi
cmpl %esi, %r13d
cmovael %esi, %r13d
testl %r14d, %r14d
movl $0x0, %ecx
movq %rcx, 0x28(%rsp)
cmovlel %edx, %r14d
movl %r13d, 0xc(%rsp)
cmpl %esi, %r14d
cmovael %esi, %r14d
movq 0x20(%rsp), %rbx
movq 0x8(%rbx), %rcx
movq (%rcx,%rbp), %rdx
cmpq 0x8(%rcx,%rbp), %rdx
movq %r13, %r8
movl %eax, 0x58(%rsp)
jne 0x1058e
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %eax
cmoveq %rax, %rsi
leaq (%rcx,%rbp), %rax
movq %rsi, 0x8(%rcx,%rbp)
movq %rdi, %r12
movq 0x10(%rax), %rdi
shlq $0x3, %rsi
movq %r8, %r13
callq 0x2390
movq %r12, %rdi
movq %r13, %r8
movq 0x8(%rbx), %rcx
movq %rax, 0x10(%rcx,%rbp)
movq (%rcx,%rbp), %rdx
movq 0xd0(%rsp), %r13
movq 0xc8(%rsp), %r12
movq %r8, %rsi
shlq $0x20, %rsi
incq %rsi
leaq (%rdi,%rdi,2), %rbx
movq 0x10(%rcx,%rbx,8), %rax
leaq 0x1(%rdx), %rdi
movq %rdi, (%rcx,%rbx,8)
movq %rsi, (%rax,%rdx,8)
movq (%rcx,%rbx,8), %rdx
cmpq 0x8(%rcx,%rbx,8), %rdx
movq %r8, 0x68(%rsp)
jne 0x10600
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %edx
cmoveq %rdx, %rsi
movq %rsi, 0x8(%rcx,%rbp)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2390
movq 0x20(%rsp), %rcx
movq 0x8(%rcx), %rcx
movq %rax, 0x10(%rcx,%rbp)
movq (%rcx,%rbp), %rdx
movq 0x50(%rsp), %rbp
shlq $0x20, %r14
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
orq %rsi, %r14
leaq 0x1(%rdx), %rsi
movq %rsi, (%rcx,%rbx,8)
movq %r14, (%rax,%rdx,8)
movq 0x48(%rsp), %rcx
addq $0x2, %rcx
movq %rcx, 0x48(%rsp)
cmpq 0x40(%rsp), %rcx
ja 0x10844
movq 0x20(%rsp), %rbx
movl 0x58(%rsp), %eax
jmp 0x10660
movq %r13, 0x68(%rsp)
movq 0x20(%rsp), %rbx
movq 0xd0(%rsp), %r13
movq 0xc8(%rsp), %r12
movq 0x50(%rsp), %rbp
btq $0x26, %rbp
movq 0x30(%rsp), %r14
jb 0x107cf
movq 0x78(%rsp), %rdi
movl %eax, %ebp
movq 0x98(%rsp), %rsi
callq 0x12707
movl %eax, 0x14(%rsp)
cmpl $-0x1, %ebp
je 0x10781
cmpl $-0x1, %eax
je 0x107ac
movl 0x70(%rsp), %edi
testl %edi, %edi
movl $0x0, %ecx
cmovlel %ecx, %edi
movq 0x78(%rsp), %rcx
movq 0x8(%rcx), %rcx
movl %eax, %edx
leaq (%rdx,%rdx,2), %rdx
movl 0x10(%rcx,%rdx,8), %ecx
decl %ecx
cmpl %ecx, %edi
cmovbl %edi, %ecx
movl %ecx, 0x1c(%rsp)
cmpl %eax, %ebp
jbe 0x106df
movl %eax, 0x18(%rsp)
movl %ebp, 0x14(%rsp)
movl %ecx, 0xc(%rsp)
movq 0x68(%rsp), %rax
movl %eax, 0x1c(%rsp)
movl $0x4, %esi
movl $0x1, %edx
leaq 0x18(%rsp), %rdi
movq 0xc0(%rsp), %rbx
movq %rbx, %rcx
callq 0x24d0
movl $0x4, %esi
movl $0x1, %edx
leaq 0xc(%rsp), %rdi
movq %rbx, %rcx
callq 0x24d0
movl $0x4, %esi
movl $0x1, %edx
leaq 0x14(%rsp), %rdi
movq %rbx, %rcx
callq 0x24d0
movl $0x4, %esi
movl $0x1, %edx
leaq 0x1c(%rsp), %rdi
movq %rbx, %rcx
callq 0x24d0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rbx, %rsi
callq 0x2260
movl 0x18(%rsp), %eax
xorl %ecx, %ecx
xorl %edx, %edx
cmpl 0x14(%rsp), %eax
setne %cl
sete %dl
addq %rdx, 0xb0(%rsp)
addq %rcx, 0xa8(%rsp)
incq 0x88(%rsp)
movq 0x20(%rsp), %rbx
jmp 0x107cf
movq %r13, %rdi
movq %r14, %rsi
leaq 0x10(%rsp), %rdx
callq 0x10b5c
cmpl $0x0, 0x10(%rsp)
je 0x107cf
movq %r14, %rdi
movq 0xa0(%rsp), %rsi
movl %eax, %edx
callq 0x2a07
jmp 0x107cf
movq %r13, %rdi
movq 0x98(%rsp), %r14
movq %r14, %rsi
leaq 0x10(%rsp), %rdx
callq 0x10b5c
cmpl $0x0, 0x10(%rsp)
jne 0x1089f
movq 0x38(%rsp), %rsi
incq %rsi
movq %rsi, %rax
movabsq $0x431bde82d7b634db, %rcx # imm = 0x431BDE82D7B634DB
mulq %rcx
movq %rdx, %rcx
movq %rsi, 0x38(%rsp)
movabsq $0x790fb65668c26139, %rdx # imm = 0x790FB65668C26139
imulq %rdx, %rsi
rorq $0x6, %rsi
movabsq $0x10c6f7a0b5ed, %rdx   # imm = 0x10C6F7A0B5ED
cmpq %rdx, %rsi
ja 0x10450
shrq $0x12, %rcx
movq 0x1b7d9(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
leaq 0x12239(%rip), %rsi     # 0x22a62
leaq 0x1215d(%rip), %rdx     # 0x2298d
movq 0x88(%rsp), %r8
xorl %eax, %eax
callq 0x22c0
jmp 0x10450
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x16fc1
movq %rax, %r8
movq %rax, 0x50(%rsp)
movq 0x1b798(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
leaq 0x12187(%rip), %rsi     # 0x229f1
leaq 0x1211c(%rip), %rdx     # 0x2298d
movq 0x48(%rsp), %r14
movq %r14, %rcx
movq 0x40(%rsp), %r9
xorl %eax, %eax
callq 0x22c0
shrq %r14
movq 0x50(%rsp), %rax
cmpq %r14, %rax
movq %rax, %r14
ja 0x108b6
movq %r14, 0x48(%rsp)
jmp 0x1063b
movq %r14, %rdi
movq 0xa0(%rsp), %rsi
movl %eax, %edx
callq 0x29c5
jmp 0x107cf
movq 0x40(%rsp), %rcx
addq %rcx, %rcx
movq 0x1b733(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
leaq 0x1215e(%rip), %rsi     # 0x22a2d
leaq 0x120b7(%rip), %rdx     # 0x2298d
movq %rcx, 0x40(%rsp)
xorl %eax, %eax
callq 0x22c0
jmp 0x10895
movq 0x20(%rsp), %rbx
movq 0x88(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq %rbx, %rdi
callq 0x16fc1
movq 0x1b6f0(%rip), %r14     # 0x2bff8
movq (%r14), %rdi
leaq 0x120df(%rip), %rsi     # 0x229f1
leaq 0x12074(%rip), %rdx     # 0x2298d
xorl %ebx, %ebx
movq 0x48(%rsp), %rcx
movq %rax, %r8
movq 0x40(%rsp), %r9
xorl %eax, %eax
callq 0x22c0
movl (%r13), %eax
testl %eax, %eax
je 0x10971
xorl %ebp, %ebp
movq 0x10(%r13), %rcx
movq %rbp, %rdx
shrq $0x4, %rdx
movl (%rcx,%rdx,4), %edx
movl %ebx, %ecx
andb $0x1e, %cl
shrl %cl, %edx
testb $0x3, %dl
jne 0x10964
movq 0x18(%r13), %rax
movq (%rax,%rbp,8), %rdi
callq 0x2060
movl (%r13), %eax
incq %rbp
movl %eax, %ecx
addl $0x2, %ebx
cmpq %rcx, %rbp
jb 0x10939
movq 0x18(%r13), %rsi
xorl %edi, %edi
callq 0xc01f
movq 0x10(%r13), %rsi
xorl %edi, %edi
callq 0xc01f
movq 0x20(%r13), %rsi
xorl %edi, %edi
callq 0xc01f
xorl %edi, %edi
movq %r13, %rsi
callq 0xc01f
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x109ab
callq 0x2060
testq %r15, %r15
movq 0x78(%rsp), %r13
movq 0x90(%rsp), %rbx
je 0x109ce
movq 0x30(%r15), %rdi
callq 0x2060
movq %r15, %rdi
callq 0x2060
movq %rbx, %rdi
callq 0x4f25
movq %r12, %rdi
callq 0x5640
movq 0x108(%rsp), %rsi
addq $0x8, %rsi
movq 0xc0(%rsp), %r15
movq %r15, %rdi
xorl %edx, %edx
callq 0x2370
leaq 0xb8(%rsp), %rbx
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rdi
movq %r15, %rcx
callq 0x24d0
movq (%rbx), %rbx
movq %rbx, %rsi
shlq $0x4, %rsi
addq %rbx, %rsi
movq %r15, %rdi
movl $0x1, %edx
callq 0x2370
movq (%r14), %rdi
movq 0xa8(%rsp), %rax
movq %rax, (%rsp)
leaq 0x120ad(%rip), %rsi     # 0x22af6
leaq 0x11f3d(%rip), %rdx     # 0x2298d
movq %rbx, %rcx
movq 0x38(%rsp), %r8
movq 0xb0(%rsp), %r9
xorl %eax, %eax
callq 0x22c0
movq 0x20(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
movsd 0x110(%rsp), %xmm0
callq 0x3302
movq %rax, %rbx
movl $0x8, %esi
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rcx
callq 0x24d0
movq (%rbx), %rdx
movq 0x10(%rbx), %rax
movq (%rax), %rdi
movl $0x8, %esi
movq %r15, %rcx
callq 0x24d0
movq %r14, %rdi
callq 0x16f4c
movq %rbx, %rdi
callq 0x16f99
movq %r13, %rdi
callq 0x12233
movq %r15, %rdi
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2150
movzbl %al, %edi
callq 0x29a2
jmp 0x103df
movq %r14, %rdi
callq 0x2af8
movq %rbx, %rdi
callq 0x2acd