// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/src/params.cpp
// Function: ococo::params_t::parse_commandline(int, char const**)
void ococo::params_t::parse_commandline(int argc, const char **argv) {
    /* Parse cmd parameters */
    std::stringstream cmd;
    for (int32_t i = 0; i < argc; i++) {
        cmd << argv[i];
        if (i != argc - 1) {
            cmd << " ";
        }
    }
    command=cmd.str();


    if (argc == 1) {
        print_help();
        exit(1);
    }

    const struct option lopts[] = {
        {"version", no_argument, nullptr, 'v'},
        {"help", no_argument, nullptr, 'h'},
        //
        {"input", required_argument, nullptr, 'i'},
        {"fasta-ref", required_argument, nullptr, 'f'},
        {"stats-in", required_argument, nullptr, 's'},
        //
        {"fasta-cons", required_argument, nullptr, 'F'},
        {"stats-out", required_argument, nullptr, 'S'},
        {"vcf-cons", required_argument, nullptr, 'V'},
        {"pileup", required_argument, nullptr, 'P'},
        {"log", required_argument, nullptr, 'L'},
        {"verbose", no_argument, nullptr, 'W'},
        //
        {"counters", required_argument, nullptr, 'x'},
        {"mode", required_argument, nullptr, 'm'},
        {"strategy", required_argument, nullptr, 't'},
        {"min-MQ", required_argument, nullptr, 'q'},
        {"min-BQ", required_argument, nullptr, 'Q'},
        {"ref-weight", required_argument, nullptr, 'w'},
        {"min-cov", required_argument, nullptr, 'c'},
        {"min-coverage", required_argument, nullptr, 'c'},  // deprec
        {"maj-thres", required_argument, nullptr, 'M'},
        {"majority-threshold", required_argument, nullptr, 'M'},  // deprec
        //
        {nullptr, 0, nullptr, 0}};

    int c;
    using std::string;
    while ((c = getopt_long(argc, (char *const *)argv,
                            "vhi:f:s:F:S:V:P:L:W:x:m:t:q:Q:w:c:M:", lopts,
                            nullptr)) >= 0) {
        switch (c) {
            case 'v': {
                print_version();
                exit(0);
                break;
            }
            case 'h': {
                print_help();
                exit(0);
                break;
            }
            case 'i': {
                sam_fn = optarg;
                break;
            }
            case 'f': {
                fasta_in_fn = optarg;
                break;
            }
            case 's': {
                stats_in_fn = optarg;
                break;
            }
            case 'F': {
                fasta_out_fn = optarg;
                break;
            }
            case 'S': {
                stats_out_fn = optarg;
                break;
            }
            case 'V': {
                vcf_fn = optarg;
                break;
            }
            case 'P': {
                pileup_fn = optarg;
                break;
            }
            case 'L': {
                log_fn = optarg;
                break;
            }
            case 'W': {
                verbose = true;
                break;
            }
            case 'x': {
                counters_str = optarg;

                if (counters_str.compare("ococo16") == 0) {
                    counter_configuration = OCOCO16;
                    counters_str_descr =
                        "ococo16 (16 bits per position, 3bits per nucleotide "
                        "counter)";
                } else if (counters_str.compare("ococo32") == 0) {
                    counter_configuration = OCOCO32;
                    counters_str_descr =
                        "ococo32 (32 bits per position, 7bits per nucleotide "
                        "counter)";
                } else if (counters_str.compare("ococo64") == 0) {
                    counter_configuration = OCOCO64;
                    counters_str_descr =
                        "ococo64 (64 bits per position, 15bits per nucleotide "
                        "counter)";
                } else {
                    ococo::error(
                        "Unknown counter configuration '%s'. Possible modes "
                        "are 'ococo16', 'ococo32', and 'ococo64'.\n",
                        counters_str.c_str());
                    exit(1);
                }

                break;
            }
            case 'm': {
                mode_str = optarg;

                if (mode_str.compare("batch") == 0) {
                    mode = ococo::mode_t::BATCH;
                } else if (mode_str.compare("real-time") == 0) {
                    mode = ococo::mode_t::REALTIME;
                } else {
                    ococo::error(
                        "Unknown mode '%s'. Possible modes are 'batch' and "
                        "'real-time'.\n",
                        mode_str.c_str());
                    exit(1);
                }

                break;
            }
            case 't': {
                strategy_str = optarg;

                if (strategy_str.compare("stochastic") == 0) {
                    strategy = ococo::strategy_t::STOCHASTIC;
                } else if (strategy_str.compare("no-updates") == 0) {
                    strategy = ococo::strategy_t::NO_UPDATES;
                } else if (strategy_str.compare("majority") == 0) {
                    strategy = ococo::strategy_t::MAJORITY;
                } else {
                    ococo::error(
                        "Unknown strategy '%s'. Possible strategies are "
                        "'majority', 'stochastic', and 'no-updates'.\n",
                        strategy_str.c_str());
                    exit(1);
                }

                break;
            }
            case 'q': {
                min_mapq = atoi(optarg);
                break;
            }
            case 'Q': {
                min_baseq = atoi(optarg);
                break;
            }
            case 'w': {
                init_ref_weight = atoi(optarg);
                break;
            }
            case 'c': {
                min_coverage = atoi(optarg);
                break;
            }
            case 'M': {
                majority_threshold = atof(optarg);
                break;
            }
            case '?': {
                ococo::error("Unknown error");
                exit(1);
                break;
            }
        }
    }
    if (sam_fn.size()==0){
        ococo::error("SAM/BAM file must be specified (option '-i').\n");
        exit(1);
    }

    if(pileup_fn.size()!=0 && pileup_fn.compare(vcf_fn)==0){
        ococo::error("Pileup and VCF files cannot be the same (both currently '%s').\n", pileup_fn.c_str());
        exit(1);
    }

    ococo::info("Ococo starting: %s\n", counters_str_descr.c_str());
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4b8, %rsp            # imm = 0x4B8
movq %rdx, %r14
movl %esi, %r13d
movq %rdi, 0x10(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x4390
leaq 0x78(%rsp), %r12
leal -0x1(%r13), %ebp
xorl %ebx, %ebx
testl %r13d, %r13d
movl $0x0, %r15d
movq %r13, 0x38(%rsp)
cmovgl %r13d, %r15d
leaq 0x37f61(%rip), %r13     # 0x42c69
cmpq %rbx, %r15
je 0xad2e
movq (%r14,%rbx,8), %rsi
movq %r12, %rdi
callq 0x4520
cmpq %rbx, %rbp
je 0xad29
movq %r12, %rdi
movq %r13, %rsi
callq 0x4520
incq %rbx
jmp 0xad08
leaq 0x80(%rsp), %rsi
leaq 0x1f0(%rsp), %rdi
callq 0x4860
movq 0x10(%rsp), %rbx
leaq 0x8(%rbx), %rdi
leaq 0x1f0(%rsp), %r12
movq %r12, %rsi
callq 0x4650
movq %r12, %rdi
callq 0x4230
movq 0x38(%rsp), %r15
cmpl $0x1, %r15d
je 0xb17e
leaq 0x4bba6(%rip), %rsi     # 0x56920
leaq 0x1f0(%rsp), %rdi
movl $0x2c0, %edx            # imm = 0x2C0
callq 0x4420
leaq 0x1c8(%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0x1e8(%rbx), %rax
movq %rax, 0x20(%rsp)
leaq 0x30(%rbx), %rax
movq %rax, (%rsp)
leaq 0x50(%rbx), %rax
movq %rax, 0x30(%rsp)
leaq 0x160(%rbx), %rax
movq %rax, 0x58(%rsp)
leaq 0x140(%rbx), %rax
movq %rax, 0x8(%rsp)
leaq 0xe0(%rbx), %rax
movq %rax, 0x28(%rsp)
leaq 0x120(%rbx), %rax
movq %rax, 0x50(%rsp)
leaq 0x100(%rbx), %rax
movq %rax, 0x60(%rsp)
leaq 0xb8(%rbx), %rax
movq %rax, 0x48(%rsp)
leaq 0x98(%rbx), %r12
leaq 0x78(%rbx), %rax
movq %rax, 0x40(%rsp)
leaq 0x387e4(%rip), %r13     # 0x435f8
leaq 0x37e75(%rip), %rbp     # 0x42c90
movl %r15d, %edi
movq %r14, %rsi
movq %r13, %rdx
leaq 0x1f0(%rsp), %rcx
xorl %r8d, %r8d
callq 0x48e0
testl %eax, %eax
js 0xb0e2
leal -0x4c(%rax), %ecx
cmpl $0x2c, %ecx
ja 0xae5b
movslq (%rbp,%rcx,4), %rax
addq %rbp, %rax
movq %r12, %rdi
jmpq *%rax
movq 0x58(%rsp), %rdi
jmp 0xb03e
movq 0x60(%rsp), %rdi
cmpl $0x46, %eax
je 0xb03e
cmpl $0x3f, %eax
jne 0xae1b
jmp 0xb156
movq 0x4c13e(%rip), %rax     # 0x56fb8
movq (%rax), %rsi
movq 0x18(%rsp), %rdi
callq 0x4a00
movq 0x18(%rsp), %r13
movq %r13, %rdi
leaq 0x388f6(%rip), %rsi     # 0x4378c
callq 0x4150
testl %eax, %eax
je 0xb086
movq %r13, %rdi
leaq 0x388ea(%rip), %rsi     # 0x43797
callq 0x4150
testl %eax, %eax
je 0xb0cf
movq %r13, %rdi
leaq 0x37ea2(%rip), %rsi     # 0x42d66
callq 0x4150
testl %eax, %eax
jne 0xb1ac
movl $0x3, 0x1ac(%rbx)
leaq 0x38716(%rip), %r13     # 0x435f8
jmp 0xae1b
movq 0x48(%rsp), %rdi
jmp 0xb03e
movq 0x4c0c0(%rip), %rax     # 0x56fb8
movq (%rax), %rdi
callq 0x4830
movl %eax, 0x1b4(%rbx)
jmp 0xae1b
movq 0x4c0a6(%rip), %rax     # 0x56fb8
movq (%rax), %rdi
callq 0x4670
movsd %xmm0, 0x1c0(%rbx)
jmp 0xae1b
movq 0x4c08a(%rip), %rax     # 0x56fb8
movq (%rax), %rsi
movq (%rsp), %rdi
callq 0x4a00
movq (%rsp), %r13
movq %r13, %rdi
leaq 0x386d5(%rip), %rsi     # 0x4361d
callq 0x4150
testl %eax, %eax
je 0xb09c
movq %r13, %rdi
leaq 0x37df9(%rip), %rsi     # 0x42d58
callq 0x4150
pushq $0x1
popq %rcx
leaq 0x386f4(%rip), %rsi     # 0x43662
testl %eax, %eax
je 0xb0a5
movq (%rsp), %rdi
leaq 0x3871e(%rip), %rsi     # 0x4369f
callq 0x4150
pushq $0x2
popq %rcx
leaq 0x38717(%rip), %rsi     # 0x436a7
testl %eax, %eax
je 0xb0a5
jmp 0xb195
movq 0x8(%rsp), %rdi
jmp 0xb03e
movb $0x1, 0xd8(%rbx)
jmp 0xae1b
movq 0x50(%rsp), %rdi
jmp 0xb03e
movq 0x28(%rsp), %rdi
jmp 0xb03e
movq 0x4bfed(%rip), %rax     # 0x56fb8
movq (%rax), %rdi
callq 0x4830
movl %eax, 0x1bc(%rbx)
jmp 0xae1b
movq 0x4bfd3(%rip), %rax     # 0x56fb8
movq (%rax), %rsi
movq 0x20(%rsp), %rdi
callq 0x4a00
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
leaq 0x37d5f(%rip), %rsi     # 0x42d60
callq 0x4150
testl %eax, %eax
je 0xb0be
movq %rbx, %rdi
leaq 0x3872a(%rip), %rsi     # 0x43742
callq 0x4150
testl %eax, %eax
jne 0xb166
movq 0x10(%rsp), %rbx
movl $0x1, 0x1a8(%rbx)
jmp 0xae1b
movq 0x40(%rsp), %rdi
movq 0x4bf73(%rip), %rax     # 0x56fb8
movq (%rax), %rsi
callq 0x4a00
jmp 0xae1b
movq 0x4bf5f(%rip), %rax     # 0x56fb8
movq (%rax), %rdi
callq 0x4830
movl %eax, 0x1b8(%rbx)
jmp 0xae1b
movq 0x4bf45(%rip), %rax     # 0x56fb8
movq (%rax), %rdi
callq 0x4830
movl %eax, 0x1b0(%rbx)
jmp 0xae1b
movl $0x1, 0x1ac(%rbx)
leaq 0x38561(%rip), %r13     # 0x435f8
jmp 0xae1b
xorl %ecx, %ecx
leaq 0x38580(%rip), %rsi     # 0x43625
movl %ecx, 0x28(%rbx)
movq 0x30(%rsp), %rdi
callq 0x4a00
leaq 0x3853f(%rip), %r13     # 0x435f8
jmp 0xae1b
movq 0x10(%rsp), %rbx
andl $0x0, 0x1a8(%rbx)
jmp 0xae1b
andl $0x0, 0x1ac(%rbx)
leaq 0x3851b(%rip), %r13     # 0x435f8
jmp 0xae1b
cmpq $0x0, 0x80(%rbx)
je 0xb185
cmpq $0x0, 0x148(%rbx)
je 0xb111
movq 0x8(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x4050
testl %eax, %eax
je 0xb1c4
movq 0x30(%rsp), %rax
movq (%rax), %rsi
leaq 0x3875b(%rip), %rdi     # 0x4387b
xorl %eax, %eax
callq 0xa59c
leaq 0x68(%rsp), %rdi
callq 0x43e0
addq $0x4b8, %rsp            # imm = 0x4B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xb350
jmp 0xb14f
callq 0xa330
xorl %edi, %edi
callq 0x4620
leaq 0x386a1(%rip), %rdi     # 0x437fe
xorl %eax, %eax
callq 0xa428
jmp 0xb1da
movq 0x20(%rsp), %rax
movq (%rax), %rsi
leaq 0x385d7(%rip), %rdi     # 0x4374c
xorl %eax, %eax
callq 0xa428
jmp 0xb1da
callq 0xb350
jmp 0xb1da
leaq 0x38680(%rip), %rdi     # 0x4380c
xorl %eax, %eax
callq 0xa428
jmp 0xb1da
movq (%rsp), %rax
movq (%rax), %rsi
leaq 0x38542(%rip), %rdi     # 0x436e5
xorl %eax, %eax
callq 0xa428
jmp 0xb1da
movq 0x18(%rsp), %rax
movq (%rax), %rsi
leaq 0x385e7(%rip), %rdi     # 0x437a2
xorl %eax, %eax
callq 0xa428
jmp 0xb1da
movq 0x8(%rsp), %rax
movq (%rax), %rsi
leaq 0x38668(%rip), %rdi     # 0x4383b
xorl %eax, %eax
callq 0xa428
pushq $0x1
popq %rdi
callq 0x4620
jmp 0xb1ea
jmp 0xb1ea
jmp 0xb1ea
jmp 0xb1ea
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x43e0
movq %rbx, %rdi
callq 0x4950
nop