// File: /workspace/github_c_makefile_star2_O2/c-zhou[P]oatk/rotate.c
// Function: main
int main(int argc, char *argv[])
{
    const char *opt_str = "l:s:o:rVv:h";
    ketopt_t opt = KETOPT_INIT;
    int c, line_width, absent, ret = 0;
    sstream_t *fin;
    kh_str_t *reg_list;
    khint32_t k;
    FILE *fp_help;
    char *rotate_file, *seq_id, *seq;
    int seq_pos, strand, ln;
    
    sys_init();

    fp_help = stderr;
    line_width = 60;
    rotate_file = seq_id = 0;
    seq_pos = 0;
    strand = 0;

    while ((c = ketopt(&opt, argc, argv, 1, opt_str, long_options)) >=0 ) {
        if (c == 's') rotate_file = opt.arg;
        else if (c == 'l') line_width = atoi(opt.arg);
        else if (c == 'r') strand = 1;
        else if (c == 'v') VERBOSE = atoi(opt.arg);
        else if (c == 'h') fp_help = stdout;
        else if (c == 'o') {
            if (strcmp(opt.arg, "-") != 0) {
                if (freopen(opt.arg, "wb", stdout) == NULL) {
                    fprintf(stderr, "[ERROR]\033[1;31m failed to write the output to file '%s'\033[0m: %s\n", opt.arg, strerror(errno));
                    return 1;
                }
            }
        }
        else if (c == 'V') {
            puts(SEQROTATE_VERSION);
            return 0;
        }
        else if (c == '?') {
            fprintf(stderr, "[E::%s] unknown option: \"%s\"\n", __func__, argv[opt.i - 1]);
            return 1;
        }
        else if (c == ':') {
            fprintf(stderr, "[E::%s] missing option: \"%s\"\n", __func__, argv[opt.i - 1]);
            return 1;
        }
    }
    
    if (argc == opt.ind || fp_help == stdout) {
        fprintf(fp_help, "\n");
        fprintf(fp_help, "Usage: rotate [options] <file>[.fa[.gz]] [seq pos]\n");
        fprintf(fp_help, "Options:\n");
        fprintf(fp_help, "    -s STR        two/three-column rotation file\n");
        fprintf(fp_help, "    -r STR        rotate in reverse strand (effective without -s)\n");
        fprintf(fp_help, "    -l INT        number of residues per line; 0 for 2^31-1 [%d]\n", line_width);
        fprintf(fp_help, "    -o FILE       output results to FILE [stdout]\n");
        fprintf(fp_help, "    -v INT        verbose level [%d]\n", VERBOSE);
        fprintf(fp_help, "    --version     show version number\n");
        fprintf(fp_help, "\n");
        fprintf(fp_help, "Example: ./rotate asm.fa ctg1 100\n\n");
        return fp_help == stdout? 0 : 1;
    }

    if (argc - opt.ind < 1) {
        fprintf(stderr, "[E::%s] missing input: please specify the input FASTA file\n", __func__);
        return 1;
    }

    if (argc - opt.ind > 2) {
        seq_id  = argv[opt.ind + 1];
        seq_pos = atoll(argv[opt.ind + 2]);
        if (seq_pos <= 0) {
            fprintf(stderr, "[E::%s] rotate position must be positive: %d\n", __func__, seq_pos);
            exit(1);
        }
        if (rotate_file) {
            fprintf(stderr, "[W::%s] rotate file %s ignored\n", __func__, rotate_file);
            fprintf(stderr, "[W::%s] using positional parameters: %s %u\n", __func__, seq_id, seq_pos);
        }
    } else {
        if (!rotate_file) {
            fprintf(stderr, "[E::%s] need a file (-s) or two rotation parameters\n", __func__);
            return 1;
        }
    }

    if (line_width == 0) line_width = INT32_MAX;

    reg_list = kh_str_init();
    if (seq_id) {
        k = kh_str_put(reg_list, strdup(seq_id), &absent);
        kh_val(reg_list, k) = (uint64_t) seq_pos << 1 | strand;
    } else {
        gzFile fp;
        kstring_t s = {0,0,0};
        kstream_t *ks;
        int dret;
        int64_t pos, lineno = 0;
        char *p, *q, *sid;

        if (strand)
            fprintf(stderr, "[W::%s] the option '-r' is not effective with '-s' \n", __func__);

        fp = gzopen(rotate_file, "r");
        if (!fp) {
            fprintf(stderr, "[E::%s] failed to open file %s to read\n", __func__, rotate_file);
            exit(1);
        }
        ks = ks_init(fp);
        while (ks_getuntil(ks, KS_SEP_LINE, &s, &dret) >= 0) {
            ++lineno;
            
            p = q = s.s;
            while (isspace(*q) && *q != '\0') ++q;
            p = q;
            while (!isspace(*q) && *q != '\0') ++q;
            if (p == q) continue; // empty line
            MYMALLOC(sid, q - p + 1);
            memcpy(sid, p, q - p);
            sid[q-p] = '\0';

            while (isspace(*q) && *q != '\0') ++q;
            p = q;
            while (!isspace(*q) && *q != '\0') ++q;
            pos = atoll(p);
            if (p == q) {
                // no second column found
                fprintf(stderr, "[E::%s] invalid line at line %ld: %s\n", __func__, (long) lineno, s.s);
                fprintf(stderr, "[E::%s] need at least two columns\n", __func__);
                exit(1);
            }
            if (pos <= 0) {
                fprintf(stderr, "[E::%s] rotate position must be positive: %ld\n", __func__, pos);
                exit(1);
            }
            pos <<= 1;

            while (isspace(*q) && *q != '\0') ++q;
            p = q;
            while (!isspace(*q) && *q != '\0') ++q;
            
            if (p != q) {
                if (*p == '-') pos |= 1;
                else if (*p != '+') {
                    fprintf(stderr, "[E::%s] invalid line at line %ld: %s\n", __func__, (long) lineno, s.s);
                    fprintf(stderr, "[E::%s] the third column (strand) must be '+' or '-'\n", __func__);
                    exit(1);
                }
            }
            
            absent = 1;
            k = kh_str_put(reg_list, sid, &absent);
            if (absent)
                kh_val(reg_list, k) = (uint64_t) pos;
            else {
                fprintf(stderr, "[E::%s] invalid line at line %ld: %s\n", __func__, (long) lineno, s.s);
                fprintf(stderr, "[E::%s] duplicate sequence '%s'\n", __func__, sid);
                exit(1);
            }
        }

        ks_destroy(ks);
        gzclose(fp);
    }

    fin = sstream_open(&argv[opt.ind], 1);
    if (fin == 0) {
        fprintf(stderr, "[E::%s] failed to open files: %s\n", __func__, strerror(errno));
        exit(1);
    }
    while ((ln = sstream_read(fin)) >= 0) {
        seq_id = fin->s->ks->name.s;
        seq = fin->s->ks->seq.s;
        k = kh_str_get(reg_list, seq_id);
        fprintf(stdout, ">%s\n", seq_id);
        if (k != kh_end(reg_list)) {
            seq_pos = (kh_val(reg_list, k)) >> 1;
            strand = (kh_val(reg_list, k)) & 1;
            if (seq_pos > ln) {
                fprintf(stderr, "[E::%s] rotation position (%d) larger than sequence length (%d)\n", __func__, seq_pos, ln);
                exit(1);
            }
            if (strand) {
                print_seq(seq, seq_pos, 1, 0, line_width, stdout);
                print_seq(seq + seq_pos, ln - seq_pos, 1, seq_pos, line_width, stdout);
            } else {
                seq_pos -= 1;
                print_seq(seq + seq_pos, ln - seq_pos, 0, 0, line_width, stdout);
                print_seq(seq, seq_pos, 0, ln - seq_pos, line_width, stdout);
            }
            free((void *)kh_key(reg_list, k));
            kh_str_del(reg_list, k);
        } else
            print_seq(seq, ln, 0, 0, line_width, stdout);
        if (ln % line_width != 0) fputc('\n', stdout);
    }
    sstream_close(fin);

    for (k = (khint32_t) 0; k < kh_end(reg_list); k++) {
        if (kh_exist(reg_list, k)) {
            seq_id = (char *) kh_key(reg_list, k);
            fprintf(stderr, "[W::%s] sequence '%s' not found in the FASTA file\n", __func__, seq_id);
            free(seq_id);
        }
    }
    kh_str_destroy(reg_list);

    if (fflush(stdout) == EOF) {
        fprintf(stderr, "[E::%s] failed to write the results\n", __func__);
        exit(1);
    }

    if (VERBOSE >= 0 && !ret) {
        fprintf(stderr, "[M::%s] Version: %s\n", __func__, SEQROTATE_VERSION);
        fprintf(stderr, "[M::%s] CMD:", __func__);
        int i;
        for (i = 0; i < argc; ++i)
            fprintf(stderr, " %s", argv[i]);
        fprintf(stderr, "\n[M::%s] Real time: %.3f sec; CPU: %.3f sec; Peak RSS: %.3f GB\n", __func__, realtime() - realtime0, cputime(), peakrss() / 1024.0 / 1024.0 / 1024.0);
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %rbx
movl %edi, %r14d
movabsq $0x100000000, %r15      # imm = 0x100000000
callq 0x428e
movq %r15, %rdi
movq %rbx, %r8
movq 0x6ab4(%rip), %rax      # 0x8ff0
movq (%rax), %rbp
movq %r14, 0x70(%rsp)
movslq %r14d, %r9
leal -0x1(%r9), %eax
movl %eax, 0x60(%rsp)
pushq $0x3c
popq %r12
pushq $0x1
popq %rax
movq $0x0, 0x40(%rsp)
xorl %r15d, %r15d
movl %eax, %r14d
movq $0x0, 0x48(%rsp)
xorl %ebx, %ebx
movq %r8, 0x28(%rsp)
movq %r9, (%rsp)
movq %r14, 0x30(%rsp)
movslq %r14d, %rcx
movq %rcx, %r14
shlq $0x20, %r14
leaq (%r8,%rcx,8), %rdx
xorl %r13d, %r13d
movq %rcx, %rax
leaq (%rcx,%r13), %rsi
cmpq %r9, %rsi
jge 0x298a
movq (%rdx,%r13,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x25ae
cmpb $0x0, 0x1(%rsi)
jne 0x25b9
incq %rax
incq %r13
addq %rdi, %r14
jmp 0x2592
movl %r15d, %edx
sarq $0x1d, %r14
movq (%r8,%r14), %r15
cmpb $0x2d, (%r15)
jne 0x3443
movq %rbp, 0x68(%rsp)
movl %r12d, 0x20(%rsp)
movl 0x30(%rsp), %ebp
addq %r13, %rbp
movl 0x40(%rsp), %ecx
addq %r13, %rcx
movq %rcx, 0x10(%rsp)
movzbl 0x1(%r15), %ecx
cmpl $0x2d, %ecx
movl %ebx, 0x38(%rsp)
je 0x265c
testl %ecx, %ecx
je 0x349b
cmpl $0x1, %edx
adcl $0x0, %edx
movl %edx, 0x18(%rsp)
movslq %edx, %r12
movsbl (%r15,%r12), %esi
incq %r12
leaq 0x3ab3(%rip), %rdi      # 0x60d0
movl %esi, 0x8(%rsp)
pushq $0xc
popq %rdx
callq 0x21a0
movq 0x28(%rsp), %r8
pushq $0x3f
popq %rcx
testq %rax, %rax
je 0x277d
cmpb $0x3a, 0x1(%rax)
jne 0x2777
cmpb $0x0, (%r15,%r12)
je 0x2955
addq %r12, %r15
movq %r15, 0x18(%rsp)
jmp 0x2791
movb 0x2(%r15), %r12b
testb %r12b, %r12b
je 0x34a0
movq %r15, %rcx
leaq 0x2(%r15), %rax
movq %rax, 0x8(%rsp)
addq $0x3, %rcx
xorl %r15d, %r15d
testb %r12b, %r12b
je 0x2695
movzbl %r12b, %eax
cmpl $0x3d, %eax
je 0x2695
movb (%rcx), %r12b
incq %rcx
addq %rdi, %r15
jmp 0x267c
movq %rcx, 0x18(%rsp)
movq %r13, 0x58(%rsp)
sarq $0x20, %r15
xorl %ebx, %ebx
leaq 0x66d4(%rip), %r14      # 0x8d80
xorl %r13d, %r13d
movq (%r14), %rsi
testq %rsi, %rsi
je 0x26db
movq 0x8(%rsp), %rdi
movq %r15, %rdx
callq 0x20a0
movq (%rsp), %r9
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
cmoveq %r14, %r13
addl %ecx, %ebx
addq $0x10, %r14
jmp 0x26af
cmpl $0x1, %ebx
jne 0x2746
movl 0xc(%r13), %eax
movl %eax, 0x8(%rsp)
cmpb $0x3d, %r12b
movq 0x28(%rsp), %r8
movabsq $0x100000000, %rdi      # imm = 0x100000000
je 0x27f5
testb %r12b, %r12b
jne 0x27ec
cmpl $0x1, 0x8(%r13)
jne 0x27ec
cmpl %ebp, 0x60(%rsp)
movq 0x58(%rsp), %r13
movl 0x20(%rsp), %r12d
jle 0x2972
movq 0x30(%rsp), %rax
leal (%rax,%r13), %r14d
incl %r14d
movslq %r14d, %rax
movq (%r8,%rax,8), %rax
movq %rax, 0x18(%rsp)
jmp 0x2802
movq $0x0, 0x18(%rsp)
pushq $0x3f
popq %rax
movl %eax, 0x8(%rsp)
movl %ebp, %r14d
movq 0x28(%rsp), %r8
movq 0x58(%rsp), %r13
movl 0x20(%rsp), %r12d
movabsq $0x100000000, %rdi      # imm = 0x100000000
jmp 0x2802
movl 0x8(%rsp), %eax
movl %eax, %ecx
cmpl $-0x2, 0x18(%rsp)
jg 0x27a9
movq $0x0, 0x18(%rsp)
movl %ecx, 0x8(%rsp)
movl %ebp, %r14d
movl 0x20(%rsp), %r12d
movabsq $0x100000000, %rdi      # imm = 0x100000000
movq (%rsp), %r9
jmp 0x2802
movq (%r8,%r14), %rax
movl %r12d, %edx
cmpb $0x0, (%rax,%rdx)
movabsq $0x100000000, %rdi      # imm = 0x100000000
movq (%rsp), %r9
je 0x27da
movl %r12d, %r15d
movl %ebp, %r14d
movq $0x0, 0x18(%rsp)
movl 0x20(%rsp), %r12d
jmp 0x2844
movq $0x0, 0x18(%rsp)
movl %ecx, 0x8(%rsp)
movl %ebp, %r14d
jmp 0x27fd
movq $0x0, 0x18(%rsp)
movl %ebp, %r14d
movq 0x58(%rsp), %r13
movl 0x20(%rsp), %r12d
leal 0x1(%r14), %ebx
xorl %r15d, %r15d
cmpl $0x0, 0x10(%rsp)
jle 0x283b
cmpl %r14d, %ebp
jg 0x283b
movq %r8, %rdi
movl %ebp, %esi
movq 0x10(%rsp), %rdx
callq 0x3af6
movq (%rsp), %r9
movabsq $0x100000000, %rdi      # imm = 0x100000000
movq 0x28(%rsp), %r8
incl %ebp
jmp 0x2810
movl 0x8(%rsp), %eax
movl %eax, %ecx
movq %rbx, %r14
testl %ecx, %ecx
movq 0x68(%rsp), %rbp
movl 0x38(%rsp), %ebx
js 0x2994
leal -0x68(%rcx), %eax
cmpl $0xe, %eax
ja 0x292b
leaq 0x37a8(%rip), %rcx      # 0x6010
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x6758(%rip), %rax      # 0x8fd0
movq (%rax), %rbp
jmp 0x2946
pushq $0x1
popq %rbx
jmp 0x2946
movq 0x18(%rsp), %rdi
callq 0x2340
movq (%rsp), %r9
movabsq $0x100000000, %rdi      # imm = 0x100000000
movq 0x28(%rsp), %r8
movl %eax, %r12d
jmp 0x2946
movq 0x18(%rsp), %r13
cmpb $0x2d, (%r13)
jne 0x28c4
cmpb $0x0, 0x1(%r13)
je 0x2946
movq 0x6705(%rip), %rax      # 0x8fd0
movq (%rax), %rdx
movq %r13, %rdi
leaq 0x3804(%rip), %rsi      # 0x60dc
callq 0x2160
movq (%rsp), %r9
movabsq $0x100000000, %rdi      # imm = 0x100000000
movq 0x28(%rsp), %r8
testq %rax, %rax
jne 0x2946
jmp 0x34e5
movq 0x18(%rsp), %rax
movq %rax, 0x48(%rsp)
jmp 0x2946
movq 0x18(%rsp), %rdi
callq 0x2340
movq (%rsp), %r9
movabsq $0x100000000, %rdi      # imm = 0x100000000
movq 0x28(%rsp), %r8
movl %eax, 0x68f3(%rip)      # 0x921c
jmp 0x2946
cmpl $0x56, %ecx
je 0x34d4
cmpl $0x3a, %ecx
je 0x350d
cmpl $0x3f, %ecx
je 0x3528
movq 0x10(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x2579
cmpl %ebp, 0x60(%rsp)
movl 0x20(%rsp), %r12d
movabsq $0x100000000, %rdi      # imm = 0x100000000
movq (%rsp), %r9
jg 0x2729
movq $0x0, 0x18(%rsp)
pushq $0x3a
popq %rax
movl %eax, 0x8(%rsp)
movl %ebp, %r14d
jmp 0x2802
cmpq %r9, %rcx
cmovgq %rcx, %r9
movl %r9d, %r14d
movq 0x70(%rsp), %rax
movq 0x40(%rsp), %rsi
addl %esi, %eax
movl %eax, %ecx
subl %r14d, %ecx
movl %r13d, %edx
addl %ecx, %edx
je 0x2a76
movq 0x6619(%rip), %rcx      # 0x8fd0
cmpq (%rcx), %rbp
je 0x2a76
movl %r14d, %ecx
negl %ecx
addq %r13, %rax
addq %rcx, %rax
testl %eax, %eax
jle 0x3345
movl %ebx, 0x38(%rsp)
movslq %r14d, %r15
movslq %esi, %rbp
cmpl $0x3, %eax
movq %r15, 0x60(%rsp)
movq %rbp, 0x20(%rsp)
jb 0x2b65
movq %r15, %rax
subq %rbp, %rax
subq %r13, %rax
movq 0x8(%r8,%rax,8), %r14
movq 0x10(%r8,%rax,8), %rdi
callq 0x21d0
movq %rax, %rbx
testl %ebx, %ebx
jle 0x36a6
movq 0x48(%rsp), %r15
testq %r15, %r15
je 0x2b7b
movq 0x65c8(%rip), %rax      # 0x8ff0
movl %r12d, %ebp
movq %rax, %r12
movq (%rax), %rdi
leaq 0x392f(%rip), %rsi      # 0x6367
leaq 0x3702(%rip), %r15      # 0x6141
movq %r15, %rdx
movq 0x48(%rsp), %rcx
xorl %eax, %eax
callq 0x2200
movq (%r12), %rdi
movl %ebp, %r12d
leaq 0x392b(%rip), %rsi      # 0x6387
movq %r15, %rdx
movq 0x48(%rsp), %r15
movq %r14, %rcx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x2200
jmp 0x2b7b
movq %rbp, %r14
pushq $0xa
popq %rbp
movl %ebp, %edi
movq %r14, %rsi
callq 0x2190
leaq 0x36d7(%rip), %rdi      # 0x6164
pushq $0x33
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2380
leaq 0x36f3(%rip), %rdi      # 0x6198
pushq $0x9
popq %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2380
leaq 0x36e8(%rip), %rdi      # 0x61a2
pushq $0x31
popq %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2380
leaq 0x3705(%rip), %rdi      # 0x61d4
pushq $0x42
popq %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2380
leaq 0x3733(%rip), %rsi      # 0x6217
movq %r14, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0x2200
leaq 0x3761(%rip), %rdi      # 0x6259
pushq $0x32
popq %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2380
movl 0x6710(%rip), %edx      # 0x921c
leaq 0x3779(%rip), %rsi      # 0x628c
movq %r14, %rdi
xorl %eax, %eax
callq 0x2200
leaq 0x378e(%rip), %rdi      # 0x62b2
pushq $0x26
popq %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2380
movl %ebp, %edi
movq %r14, %rsi
callq 0x2190
leaq 0x3796(%rip), %rdi      # 0x62d9
pushq $0x23
popq %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2380
xorl %eax, %eax
movq 0x6476(%rip), %rcx      # 0x8fd0
cmpq (%rcx), %r14
setne %al
jmp 0x3336
xorl %r14d, %r14d
movl $0x0, %ebx
movq 0x48(%rsp), %r15
testq %r15, %r15
je 0x3450
testl %r12d, %r12d
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmovnel %r12d, %eax
movl %eax, 0x40(%rsp)
pushq $0x1
popq %rsi
pushq $0x20
popq %rdx
xorl %edi, %edi
callq 0x46d4
movq %rax, %rbp
andq $0x0, 0x18(%rax)
testq %r14, %r14
movq %rax, (%rsp)
je 0x2bdb
movq %r14, %rdi
callq 0x23b0
leaq 0x54(%rsp), %rdx
movq %rbp, %rdi
movq %rax, %rsi
callq 0x36e9
addl %ebx, %ebx
orl 0x38(%rsp), %ebx
movq 0x10(%rbp), %rcx
movl %eax, %eax
shlq $0x4, %rax
movq %rbx, 0x8(%rcx,%rax)
jmp 0x2f81
cmpl $0x0, 0x38(%rsp)
jne 0x3477
movq %r13, 0x58(%rsp)
leaq 0x382b(%rip), %rsi      # 0x641d
movq %r15, %rdi
callq 0x22b0
testq %rax, %rax
je 0x36c9
movq %rax, %rbx
pushq $0x20
popq %rsi
pushq $0x1
popq %rdi
callq 0x21c0
movq %rax, %r14
movq %rbx, 0x48(%rsp)
movq %rbx, 0x10(%rax)
movl $0x10000, 0x8(%rax)     # imm = 0x10000
movl $0x4000, %edi           # imm = 0x4000
callq 0x2260
movq %rax, 0x18(%r14)
xorl %eax, %eax
xorl %ecx, %ecx
xorl %r12d, %r12d
movq $0x0, 0x10(%rsp)
xorl %r15d, %r15d
cmpl %eax, %ecx
jl 0x2c54
testb $0x3, 0x8(%r14)
jne 0x2f61
xorl %r13d, %r13d
cmpl %eax, %ecx
jl 0x2c9e
movl 0x8(%r14), %ebp
testb $0x3, %bpl
jne 0x2d67
andl $0x0, (%r14)
movq 0x10(%r14), %rdi
movq 0x18(%r14), %rsi
movl %ebp, %ebx
sarl $0x2, %ebx
movl %ebx, %edx
callq 0x21f0
movl %eax, 0x4(%r14)
cmpl %ebx, %eax
jge 0x2c90
orl $0x1, %ebp
movl %ebp, 0x8(%r14)
testl %eax, %eax
movq (%rsp), %rbp
je 0x2d6b
xorl %ecx, %ecx
movslq %ecx, %rsi
cltq
cmpl %esi, %eax
movl %esi, %ebx
cmovgl %eax, %ebx
movq %rsi, %rdx
cmpq %rax, %rdx
jge 0x2cc3
movq 0x18(%r14), %rdi
cmpb $0xa, (%rdi,%rdx)
je 0x2cc1
incq %rdx
jmp 0x2cad
movl %edx, %ebx
movq %r12, %rdx
subq %r13, %rdx
movl %ebx, %r8d
subl %ecx, %r8d
leal 0x1(%r8), %ecx
movslq %ecx, %rcx
cmpq %rcx, %rdx
jae 0x2d2d
movslq %r8d, %rax
addq %r13, %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %r12
shrq $0x10, %r12
orq %rax, %r12
incq %r12
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x22a0
movslq (%r14), %rsi
movl %ebx, %r8d
subl %esi, %r8d
jmp 0x2d32
movq 0x10(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq (%rax,%r13), %rdi
addq 0x18(%r14), %rsi
movslq %r8d, %rdx
callq 0x2230
movslq (%r14), %rax
movslq %ebx, %rcx
subq %rax, %rcx
addq %rcx, %r13
leal 0x1(%rbx), %ecx
movl %ecx, (%r14)
movl 0x4(%r14), %eax
cmpl %eax, %ebx
jge 0x2c57
jmp 0x2d6b
movq (%rsp), %rbp
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x2d8b
cmpq $0x2, %r13
jb 0x2d9a
xorl %ecx, %ecx
cmpb $0xd, -0x1(%rax,%r13)
sete %cl
subq %rcx, %r13
jmp 0x2d9a
pushq $0x1
popq %r12
movq %r12, %rdi
movq %r12, %rsi
callq 0x21c0
movq %rax, 0x10(%rsp)
movb $0x0, (%rax,%r13)
testl %r13d, %r13d
js 0x2f61
callq 0x23e0
movq (%rax), %r8
movq 0x10(%rsp), %rcx
leaq -0x1(%rcx), %r13
leaq 0x1(%rcx), %rsi
movq %r13, %rdx
movq %rsi, %rcx
incq %r13
movsbq 0x1(%rdx), %rsi
testq %rsi, %rsi
je 0x2de9
movzwl (%r8,%rsi,2), %edi
andl $0x2000, %edi           # imm = 0x2000
leaq 0x1(%rcx), %rsi
testw %di, %di
jne 0x2dc2
pushq $-0x1
popq %rbx
movq %rdx, %rbp
movsbq -0x1(%rcx), %rdx
incq %rbx
testq %rdx, %rdx
je 0x2e13
movzwl (%r8,%rdx,2), %esi
andl $0x2000, %esi           # imm = 0x2000
incq %rcx
leaq 0x1(%rbp), %rdx
testw %si, %si
je 0x2dec
incq %r15
testq %rbx, %rbx
je 0x2f51
movq %r15, 0x8(%rsp)
leaq 0x1(%rbx), %rdi
movq %rax, 0x30(%rsp)
callq 0x2260
movq %rax, %r15
movq %rax, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x2230
movq %r15, 0x38(%rsp)
movb $0x0, (%r15,%rbx)
movq 0x30(%rsp), %rax
movq (%rax), %rbx
movq %rbp, %rax
incq %rbp
movsbq 0x1(%rax), %rcx
testq %rcx, %rcx
je 0x2e71
movzwl (%rbx,%rcx,2), %ecx
andl $0x2000, %ecx           # imm = 0x2000
jne 0x2e55
pushq $0x1
popq %r15
movq %rax, %r13
movsbq 0x1(%rax), %rcx
decq %r15
testq %rcx, %rcx
je 0x2e95
leaq 0x1(%r13), %rax
movzwl (%rbx,%rcx,2), %ecx
andl $0x2000, %ecx           # imm = 0x2000
je 0x2e75
movq %rbp, %rdi
callq 0x21d0
testq %r15, %r15
je 0x357f
movq %rax, %rbp
testq %rax, %rax
movq 0x8(%rsp), %r15
jle 0x35ba
movsbq 0x1(%r13), %rax
incq %r13
testq %rax, %rax
je 0x2ed0
movzwl (%rbx,%rax,2), %ecx
andl $0x2000, %ecx           # imm = 0x2000
jne 0x2eb7
movzbl %al, %eax
pushq $0x1
popq %rcx
movsbq (%r13), %rdx
decq %rcx
testq %rdx, %rdx
je 0x2ef5
movzwl (%rbx,%rdx,2), %edx
andl $0x2000, %edx           # imm = 0x2000
incq %r13
testw %dx, %dx
je 0x2ed6
addq %rbp, %rbp
testq %rcx, %rcx
je 0x2f16
cmpl $0x2b, %eax
movq 0x38(%rsp), %r13
je 0x2f1b
cmpl $0x2d, %eax
jne 0x361a
orq $0x1, %rbp
jmp 0x2f1b
movq 0x38(%rsp), %r13
movl $0x1, 0x54(%rsp)
movq (%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x54(%rsp), %rdx
callq 0x36e9
cmpl $0x0, 0x54(%rsp)
je 0x35d7
movq 0x10(%rbx), %rcx
movl %eax, %eax
shlq $0x4, %rax
movq %rbp, 0x8(%rcx,%rax)
movl (%r14), %ecx
movl 0x4(%r14), %eax
movq (%rsp), %rbp
jmp 0x2c45
movq 0x18(%r14), %rdi
callq 0x2060
movq %r14, %rdi
callq 0x2060
movq 0x48(%rsp), %rdi
callq 0x2050
movq 0x58(%rsp), %r13
movq 0x60(%rsp), %rcx
subq 0x20(%rsp), %rcx
subq %r13, %rcx
movq 0x28(%rsp), %rax
leaq (%rax,%rcx,8), %rdi
pushq $0x1
popq %rsi
callq 0x3bd3
testq %rax, %rax
je 0x3660
movq %rax, %rbx
movq %rax, 0x38(%rsp)
movq %rbx, %rdi
callq 0x3cc7
movl %eax, 0x8(%rsp)
testl %eax, %eax
js 0x3274
movq 0x18(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rdx
movq 0x40(%rax), %r13
movq 0x10(%rbp), %r15
xorl %r14d, %r14d
movl $0x0, %r12d
testq %r15, %r15
je 0x3072
movq %r13, 0x30(%rsp)
movb (%rbp), %r13b
pushq $0x1
popq %rax
movl %eax, %r12d
movl %r13d, %ecx
shll %cl, %r12d
leal -0x1(%r12), %eax
movl %eax, 0x10(%rsp)
movq %rdx, %rbx
movq %rdx, %rdi
callq 0x3b2c
imull $0x9e3779b9, %eax, %r14d # imm = 0x9E3779B9
negb %r13b
movl %r13d, %ecx
shrl %cl, %r14d
movq 0x8(%rbp), %rbp
movl %r14d, %r13d
movl %r13d, %eax
shrl $0x5, %eax
movl (%rbp,%rax,4), %eax
btl %r13d, %eax
jae 0x3063
movl %r13d, %eax
shlq $0x4, %rax
movq (%r15,%rax), %rdi
movq %rbx, %rsi
callq 0x21e0
testl %eax, %eax
je 0x3060
incl %r13d
andl 0x10(%rsp), %r13d
cmpl %r14d, %r13d
jne 0x302a
jmp 0x3063
movl %r13d, %r12d
movq (%rsp), %rbp
movq 0x30(%rsp), %r13
xorl %r14d, %r14d
movq %rbx, %rdx
movq 0x5f57(%rip), %rax      # 0x8fd0
movq (%rax), %rdi
leaq 0x34b5(%rip), %rsi      # 0x6538
xorl %eax, %eax
callq 0x2200
movq 0x10(%rbp), %rax
testq %rax, %rax
je 0x309d
movb (%rbp), %cl
pushq $0x1
popq %r14
shll %cl, %r14d
cmpl %r14d, %r12d
jne 0x30c6
movq 0x5f27(%rip), %rax      # 0x8fd0
movq (%rax), %r9
movq %r13, %rdi
movl 0x8(%rsp), %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl 0x40(%rsp), %r8d
callq 0x3a4d
jmp 0x3247
movq %r13, %rbx
movl %r12d, %r14d
shlq $0x4, %r14
movq 0x8(%rax,%r14), %rax
movq %rax, %rbp
shrq %rbp
movl 0x8(%rsp), %r13d
subl %ebp, %r13d
jl 0x3554
testb $0x1, %al
jne 0x3135
movslq %ebp, %rax
decl %ebp
leaq (%rax,%rbx), %rdi
decq %rdi
movl 0x8(%rsp), %r13d
subl %ebp, %r13d
movq 0x5ec8(%rip), %rax      # 0x8fd0
movq (%rax), %r9
movl %r13d, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl 0x40(%rsp), %r15d
movl %r15d, %r8d
callq 0x3a4d
movq 0x5eaa(%rip), %rax      # 0x8fd0
movq (%rax), %r9
movq %rbx, %rdi
movl %ebp, %esi
xorl %edx, %edx
movl %r13d, %ecx
jmp 0x316e
movq 0x5e94(%rip), %rax      # 0x8fd0
movq (%rax), %r9
movq %rbx, %rdi
movl %ebp, %esi
pushq $0x1
popq %rdx
xorl %ecx, %ecx
movl 0x40(%rsp), %r15d
movl %r15d, %r8d
callq 0x3a4d
movslq %ebp, %rdi
addq %rbx, %rdi
movq 0x5e6d(%rip), %rax      # 0x8fd0
movq (%rax), %r9
movl %r13d, %esi
pushq $0x1
popq %rdx
movl %ebp, %ecx
movl %r15d, %r8d
callq 0x3a4d
movq (%rsp), %rbp
movq 0x10(%rbp), %rax
movq (%rax,%r14), %rdi
callq 0x2060
cmpq $0x0, 0x10(%rbp)
je 0x3247
movb (%rbp), %cl
movq %rbp, %rax
pushq $-0x1
popq %rbp
shll %cl, %ebp
notl %ebp
movl %r12d, %r14d
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
incl %r12d
andl %ebp, %r12d
cmpl %r14d, %r12d
je 0x322b
movl %r12d, %eax
shrl $0x5, %eax
movq 0x10(%rsp), %rcx
movl (%rcx,%rax,4), %eax
btl %r12d, %eax
jae 0x322b
movq (%rsp), %r13
movq 0x10(%r13), %r15
movl %r12d, %ebx
shlq $0x4, %rbx
movq (%r15,%rbx), %rdi
callq 0x3b2c
imull $0x9e3779b9, %eax, %eax # imm = 0x9E3779B9
movb (%r13), %dl
xorl %ecx, %ecx
subb %dl, %cl
shrl %cl, %eax
cmpl %r14d, %r12d
jbe 0x3201
cmpl %r14d, %eax
jbe 0x3210
cmpl %r12d, %eax
ja 0x3210
cmpl %r14d, %r12d
jae 0x31ab
cmpl %r14d, %eax
ja 0x31ab
cmpl %r12d, %eax
jbe 0x31ab
addq %r15, %rbx
movl %r14d, %eax
shlq $0x4, %rax
movups (%rbx), %xmm0
movups %xmm0, (%r15,%rax)
movq (%rsp), %rax
jmp 0x319f
pushq $-0x2
popq %rax
movl %r14d, %ecx
roll %cl, %eax
shrl $0x5, %r14d
movq 0x10(%rsp), %rcx
andl %eax, (%rcx,%r14,4)
movq (%rsp), %rbp
decl 0x4(%rbp)
movl 0x8(%rsp), %eax
cltd
idivl 0x40(%rsp)
testl %edx, %edx
movq 0x38(%rsp), %rbx
je 0x2fb0
movq 0x5d6c(%rip), %rax      # 0x8fd0
movq (%rax), %rsi
pushq $0xa
popq %rdi
callq 0x2190
jmp 0x2fb0
movq %rbx, %rdi
callq 0x3b48
leaq 0x32fb(%rip), %rbx      # 0x657e
leaq 0x2eb7(%rip), %r14      # 0x6141
xorl %r15d, %r15d
xorl %r13d, %r13d
movq 0x10(%rbp), %rsi
testq %rsi, %rsi
je 0x32a4
movb (%rbp), %cl
pushq $0x1
popq %rax
shlq %cl, %rax
jmp 0x32a6
xorl %eax, %eax
cmpq %rax, %r13
jae 0x32f0
movq 0x8(%rbp), %rax
movq %r13, %rcx
shrq $0x5, %rcx
movl (%rax,%rcx,4), %eax
btl %r13d, %eax
jb 0x32c8
incq %r13
addq $0x10, %r15
jmp 0x3290
movq (%rsi,%r15), %r12
movq 0x5d1d(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x2200
movq %r12, %rdi
callq 0x2060
jmp 0x32bf
movq 0x18(%rbp), %rbx
movq %rbx, %rdi
callq 0x475b
movq 0x8(%rbp), %rsi
movq %rbx, %rdi
callq 0x475b
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x475b
movq 0x5cb6(%rip), %rax      # 0x8fd0
movq (%rax), %rdi
callq 0x2270
cmpl $-0x1, %eax
je 0x368c
xorl %eax, %eax
cmpl $0x0, 0x5ee8(%rip)      # 0x921c
jns 0x335b
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5ca4(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x2fa7(%rip), %rsi      # 0x62fd
jmp 0x3461
movq 0x5c8e(%rip), %r15      # 0x8ff0
movq (%r15), %rdi
leaq 0x326a(%rip), %rsi      # 0x65d6
leaq 0x2dce(%rip), %rbx      # 0x6141
leaq 0x2da5(%rip), %rcx      # 0x611f
xorl %r14d, %r14d
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2200
movq (%r15), %rdi
leaq 0x325a(%rip), %rsi      # 0x65eb
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2200
movq 0x70(%rsp), %r12
testl %r12d, %r12d
cmovlel %r14d, %r12d
leaq 0x324a(%rip), %r14      # 0x65f8
xorl %r15d, %r15d
movq 0x5c38(%rip), %rax      # 0x8ff0
movq (%rax), %rbx
cmpq %r15, %r12
movq 0x28(%rsp), %rax
je 0x33db
movq (%rax,%r15,8), %rdx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2200
incq %r15
jmp 0x33b1
callq 0x422d
leaq 0x5e39(%rip), %rax      # 0x9220
subsd (%rax), %xmm0
movsd %xmm0, (%rsp)
callq 0x41c4
movsd %xmm0, 0x10(%rsp)
callq 0x4207
cvtsi2sd %rax, %xmm2
movsd 0x2bfb(%rip), %xmm0     # 0x6008
mulsd %xmm0, %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm0, %xmm2
leaq 0x31dc(%rip), %rsi      # 0x65fc
leaq 0x2d1a(%rip), %rdx      # 0x6141
movq %rbx, %rdi
movsd (%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
movb $0x3, %al
callq 0x2200
xorl %eax, %eax
jmp 0x3336
movq 0x30(%rsp), %r14
addl %r13d, %r14d
jmp 0x2994
movq 0x5b99(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x2f52(%rip), %rsi      # 0x63b3
leaq 0x2cd9(%rip), %rdx      # 0x6141
xorl %eax, %eax
callq 0x2200
pushq $0x1
popq %rax
jmp 0x3336
movq 0x5b72(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x2f60(%rip), %rsi      # 0x63e8
leaq 0x2cb2(%rip), %rdx      # 0x6141
xorl %eax, %eax
callq 0x2200
jmp 0x2be6
movl %eax, %r14d
jmp 0x34c5
movq 0x40(%rsp), %rax
leal (%rax,%r13), %edx
movq 0x30(%rsp), %r14
leal (%r14,%r13), %esi
movq %r8, %rdi
callq 0x3af6
movq 0x28(%rsp), %r8
addl %r13d, %r14d
incl %r14d
movl 0x20(%rsp), %r12d
movq 0x68(%rsp), %rbp
jmp 0x2994
leaq 0x2c44(%rip), %rdi      # 0x611f
callq 0x20b0
jmp 0x343c
movq 0x5b04(%rip), %rax      # 0x8ff0
movq (%rax), %rbx
callq 0x2080
movl (%rax), %edi
callq 0x23c0
leaq 0x2bdd(%rip), %rsi      # 0x60df
movq %rbx, %rdi
movq %r13, %rdx
movq %rax, %rcx
jmp 0x3548
movq 0x5adc(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
movslq %r14d, %rax
movq -0x8(%r8,%rax,8), %rcx
leaq 0x2c20(%rip), %rsi      # 0x6146
jmp 0x3541
movq 0x5ac1(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
movslq %r14d, %rax
movq -0x8(%r8,%rax,8), %rcx
leaq 0x2be2(%rip), %rsi      # 0x6123
leaq 0x2bf9(%rip), %rdx      # 0x6141
xorl %eax, %eax
callq 0x2200
jmp 0x346f
movq 0x5a95(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x2fd8(%rip), %rsi      # 0x653d
leaq 0x2bd5(%rip), %rdx      # 0x6141
movl %ebp, %ecx
movl 0x8(%rsp), %r8d
xorl %eax, %eax
callq 0x2200
jmp 0x3658
movq 0x5a6a(%rip), %r14      # 0x8ff0
movq (%r14), %rdi
leaq 0x2eb7(%rip), %rsi      # 0x6447
leaq 0x2baa(%rip), %rbx      # 0x6141
movq %rbx, %rdx
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %r8
xorl %eax, %eax
callq 0x2200
movq (%r14), %rdi
leaq 0x2eb8(%rip), %rsi      # 0x646d
jmp 0x364e
movq 0x5a2f(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x2ec5(%rip), %rsi      # 0x6490
leaq 0x2b6f(%rip), %rdx      # 0x6141
movq %rbp, %rcx
jmp 0x3611
movq 0x5a12(%rip), %r14      # 0x8ff0
movq (%r14), %rdi
leaq 0x2e5f(%rip), %rsi      # 0x6447
leaq 0x2b52(%rip), %rbx      # 0x6141
movq %rbx, %rdx
movq %r15, %rcx
movq 0x10(%rsp), %r8
xorl %eax, %eax
callq 0x2200
movq (%r14), %rdi
leaq 0x2eea(%rip), %rsi      # 0x64f5
movq %rbx, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x2200
jmp 0x3658
movq 0x59cf(%rip), %r14      # 0x8ff0
movq (%r14), %rdi
leaq 0x2e1c(%rip), %rsi      # 0x6447
leaq 0x2b0f(%rip), %rbx      # 0x6141
movq %rbx, %rdx
movq %r15, %rcx
movq 0x10(%rsp), %r8
xorl %eax, %eax
callq 0x2200
movq (%r14), %rdi
leaq 0x2e71(%rip), %rsi      # 0x64bf
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2200
pushq $0x1
popq %rdi
callq 0x2360
movq 0x5989(%rip), %rax      # 0x8ff0
movq (%rax), %rbx
callq 0x2080
movl (%rax), %edi
callq 0x23c0
leaq 0x2e99(%rip), %rsi      # 0x6516
leaq 0x2abd(%rip), %rdx      # 0x6141
movq %rbx, %rdi
movq %rax, %rcx
jmp 0x3611
movq 0x595d(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x2f14(%rip), %rsi      # 0x65b1
leaq 0x2a9d(%rip), %rdx      # 0x6141
jmp 0x3651
movq 0x5943(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x2c82(%rip), %rsi      # 0x6339
leaq 0x2a83(%rip), %rdx      # 0x6141
movl %ebx, %ecx
xorl %eax, %eax
callq 0x2200
jmp 0x3658
movq 0x5920(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x2d45(%rip), %rsi      # 0x641f
leaq 0x2a60(%rip), %rdx      # 0x6141
movq %r15, %rcx
jmp 0x3611