// File: /workspace/github_cpp_makefile_star2_O2/Infinidat[P]slimfastq/config.cpp
// Function: Config::init(int, char**)
void Config::init(int argc, char **argv) {
    if (initialized)
        croak("Internal error: 2nd Config init");

    initialized = true;

    std::string usr, fil;
    bool overwrite = false;
    bool statistics = false;

    if (argc == 1) usage();
    // TODO? long options
    // const char* short_opt = "POvhd 1234 u:f:s:p:l:";
    const char* short_opt = "qPsvhdO 1234 u:f:l:";
    for ( int opt = getopt(argc, argv, short_opt);
          opt != -1;
          opt     = getopt(argc, argv, short_opt))
        switch (opt) {
        case 'u': usr = optarg ; break;
        case 'f': fil = optarg ; break;

        case 'l': level = strtoll(optarg, 0, 0);  break;
        case '1': case '2' : case '3': case '4':
            level = opt - '0'; break;

        case 'd': encode     = false; break;
        case 'O': overwrite  = true ; break;
        case 'P': profiling  = true ; break;
        case 'q': quiet      = true ; break;
        case 'v':
            printf("Version %s\nInternal format version=%u\n", user_version, version);
            exit(0);
        case 'h':
            usage();
        case 's': statistics = true; encode = false; break;

        default:
            croak("Ilagal args: use -h for help");
        }

    while (optind < argc) {
        // DWIM guessing ...
        char *file = argv[optind ++];
        FILE* fh = fopen(file, "rb");
        if (! fh) {
            if  (not encode and not usr.length())
                usr = file;
            else if (encode and not fil.length())
                fil = file;
            else {
                fprintf(stderr, "What am I suppose to do with '%s'?\n (please specify explicitly with -f/-u prefix)\n(Note: not an existing file)\n",
                        file);
                exit(1);
            }
            continue;
        }
        const char* sfqstamp = "whoami=slimfastq" ;
        char initline[20];
        BZERO(initline);
        size_t cnt = fread(initline, 1, 19, fh);
        if (cnt and
            not fil.length() and
            0 == strncmp(initline, sfqstamp, strlen(sfqstamp))) {
            fil = file;
            encode = !! usr.length();
        }
        else if (cnt and
                 not usr.length() and
                 initline[0] == '@') {
            usr = file;
        }
        else if (not usr.length() and
                 not encode and
                 (not cnt or overwrite)) {
            usr = file;
        }
        else if (encode and
                 usr.length() and
                 not fil.length() and
                 (not cnt or overwrite)) {
            fil = file;
        }
        else {
            fprintf(stderr, "What am I suppose to do with '%s'?\n (please specify explicitly with -f/-u prefix)\n(Note: file exists!)\n", file);
            exit(1);
        }
    }
    check_op(fil.length(), 'f');

    const char* wr_flags = overwrite ? "wb" : "wbx" ;
    if (encode) {
        FILE* fh = fopen(fil.c_str(), wr_flags);
        check_fh(fh, fil, false);
        FilerSave::init(fh);
        m_info_filer = new FilerSave(42);
        set_info("whoami", "slimfastq");
        set_info("version", version);
        set_info("config.level", range_level(level));

        if (usr.length()) {
            set_info("orig.filename", usr.c_str());
            f_usr = fopen(usr.c_str(), "rb") ;
            check_fh(f_usr, usr, true);
            fseek(f_usr, 0L, SEEK_END);
            set_info("orig.size", ftell(f_usr));
            fseek(f_usr, 0L, SEEK_SET);
          }
        else {
            set_info("orig.filename", "<< stdin >>");
            f_usr = stdin ;
        }
    }
    else {
        FILE* fh = fopen(fil.c_str(), "rb");
        check_fh(fh, fil, true);
        fseek(fh, 0L, SEEK_END);
        UINT64 file_size = ftell(fh);
        fseek(fh, 0L, SEEK_SET);

        FilerLoad::init(fh);
        load_info();
        if (statistics)
            statistics_dump();

        level = range_level(get_long("config.level", 2));

        f_usr = usr.length() ? fopen(usr.c_str(), wr_flags) : stdout;
        check_fh(f_usr, usr);

        UINT64 comp_size = get_long("comp.size", 0);
        if (comp_size > 0 and
            comp_size != file_size)
            croak("expected compressed file size to be %lld", comp_size);

        decoder_version = conf.get_long("version");
        if (decoder_version and
            decoder_version > version)
            croak("%s was compressed with slimfastq version %d. My version is %d. Please upgrade me before decoing",
                  fil.c_str(), decoder_version, version);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
cmpb $0x1, 0xc0ea(%rip)      # 0xf210
je 0x36e5
movq %rdx, %r14
movl %esi, %ebp
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
leaq 0x30(%rsp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
movb %cl, (%rax)
movb $0x1, 0xc0b8(%rip)      # 0xf210
movb %cl, (%rdx)
cmpl $0x1, %esi
je 0x368c
movq %rdi, %rbx
leaq 0x67c1(%rip), %r15      # 0x992e
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x20b0
movq $0x0, 0x40(%rsp)
leaq 0x20(%rsp), %r12
leaq 0x5ea1(%rip), %r13      # 0x9030
movq $0x0, 0x48(%rsp)
leal -0x64(%rax), %ecx
cmpl $0x12, %ecx
jbe 0x31ad
leal -0x31(%rax), %ecx
cmpl $0x4, %ecx
jae 0x31c0
addl $-0x30, %eax
jmp 0x31e3
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
movq %r12, %rdi
jmpq *%rax
movb $0x0, 0xc(%rbx)
jmp 0x3216
cmpl $0x4f, %eax
je 0x320f
cmpl $0x50, %eax
jne 0x3228
movb $0x1, 0xd(%rbx)
jmp 0x3216
movq 0xbde1(%rip), %rax      # 0xefb8
movq (%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2080
movl %eax, 0x4(%rbx)
jmp 0x3216
movb $0x1, 0xe(%rbx)
jmp 0x3216
movb $0x0, 0xc(%rbx)
movb $0x1, %al
movq %rax, 0x40(%rsp)
jmp 0x3216
movq %rsp, %rdi
movq 0xbdb3(%rip), %rax      # 0xefb8
movq (%rax), %rsi
callq 0x2320
jmp 0x3216
movb $0x1, %al
movq %rax, 0x48(%rsp)
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x20b0
jmp 0x3198
cmpl $-0x1, %eax
jne 0x367e
movq 0xbda0(%rip), %r15      # 0xefd8
movq 0x48(%rsp), %r13
movslq (%r15), %rax
cmpl %ebp, %eax
jge 0x3377
leal 0x1(%rax), %ecx
movl %ecx, (%r15)
movq (%r14,%rax,8), %r12
movq %r12, %rdi
leaq 0x672a(%rip), %rsi      # 0x9986
callq 0x2230
testq %rax, %rax
je 0x32cd
pxor %xmm0, %xmm0
movdqa %xmm0, 0x50(%rsp)
andl $0x0, 0x60(%rsp)
leaq 0x50(%rsp), %rdi
pushq $0x1
popq %rsi
pushq $0x13
popq %rdx
movq %rax, %rcx
callq 0x22c0
testq %rax, %rax
je 0x32e5
cmpq $0x0, 0x28(%rsp)
jne 0x32b3
movdqa 0x50(%rsp), %xmm0
pcmpeqb 0x5d6d(%rip), %xmm0     # 0x9010
pmovmskb %xmm0, %ecx
cmpl $0xffff, %ecx           # imm = 0xFFFF
je 0x335b
movq 0x8(%rsp), %rcx
testq %rcx, %rcx
jne 0x32ea
cmpb $0x40, 0x50(%rsp)
movq %rsp, %rdi
je 0x334e
jmp 0x32ea
cmpb $0x0, 0xc(%rbx)
je 0x3316
cmpq $0x0, 0x28(%rsp)
leaq 0x20(%rsp), %rdi
je 0x3325
jmp 0x36c2
movq 0x8(%rsp), %rcx
movb 0xc(%rbx), %dl
testq %rcx, %rcx
je 0x3332
testq %rax, %rax
sete %al
testb %dl, %dl
je 0x36af
cmpq $0x0, 0x28(%rsp)
jne 0x36af
orb %r13b, %al
leaq 0x20(%rsp), %rdi
jmp 0x3346
cmpq $0x0, 0x8(%rsp)
movq %rsp, %rdi
jne 0x36c2
movq %r12, %rsi
callq 0x2320
jmp 0x323d
testq %rax, %rax
sete %al
testb %dl, %dl
jne 0x36af
orb %r13b, %al
movq %rsp, %rdi
testb $0x1, %al
je 0x36af
movq %r12, %rsi
callq 0x2320
jmp 0x323d
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x2320
cmpq $0x0, 0x8(%rsp)
setne 0xc(%rbx)
jmp 0x323d
cmpl $0x0, 0x28(%rsp)
je 0x36f3
leaq 0x66e9(%rip), %rax      # 0x9a72
leaq 0x66e5(%rip), %r14      # 0x9a75
testb $0x1, %r13b
cmovneq %rax, %r14
movq 0x20(%rsp), %rdi
cmpb $0x1, 0xc(%rbx)
jne 0x34f2
movq %r14, %rsi
callq 0x2230
movq %rax, %r14
leaq 0xc8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x2290
leaq 0xc8(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x3763
movq %r15, %rdi
callq 0x2110
movq %r14, %rdi
callq 0x3f3c
movl $0x4040, %edi           # imm = 0x4040
callq 0x21e0
movq %rax, %r14
pushq $0x2a
popq %rsi
movq %rax, %rdi
callq 0x40c4
movq %r14, 0x18(%rbx)
leaq 0x666d(%rip), %rsi      # 0x9a79
leaq 0x65ed(%rip), %rdx      # 0x9a00
movq %rbx, %rdi
callq 0x3000
movslq (%rbx), %rdx
leaq 0x665b(%rip), %rsi      # 0x9a80
movq %rbx, %rdi
callq 0x309e
movl 0x4(%rbx), %eax
cmpl $0x2, %eax
pushq $0x1
popq %rcx
cmovgel %eax, %ecx
cmpl $0x4, %ecx
pushq $0x4
popq %rdx
cmovll %ecx, %edx
leaq 0x663f(%rip), %rsi      # 0x9a88
movq %rbx, %rdi
callq 0x309e
cmpq $0x0, 0x8(%rsp)
je 0x3636
movq (%rsp), %rdx
leaq 0x5c39(%rip), %rsi      # 0x90a1
movq %rbx, %rdi
callq 0x3000
movq %rsp, %r15
movq (%r15), %rdi
leaq 0x6509(%rip), %rsi      # 0x9986
callq 0x2230
movq %rax, %r14
movq %rax, 0x10(%rbx)
leaq 0xa8(%rsp), %rdi
movq %r15, %rsi
callq 0x2290
leaq 0xa8(%rsp), %r15
pushq $0x1
popq %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x3763
movq %r15, %rdi
callq 0x2110
movq 0x10(%rbx), %rdi
pushq $0x2
popq %rdx
xorl %esi, %esi
callq 0x2220
movq 0x10(%rbx), %rdi
callq 0x2030
leaq 0x65c0(%rip), %rsi      # 0x9a95
movq %rbx, %rdi
movq %rax, %rdx
callq 0x309e
movq 0x10(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2220
jmp 0x365a
leaq 0x648d(%rip), %rsi      # 0x9986
callq 0x2230
movq %rax, %r12
leaq 0x88(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x2290
leaq 0x88(%rsp), %r15
pushq $0x1
popq %rbp
movq %r12, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x3763
movq %r15, %rdi
callq 0x2110
pushq $0x2
popq %rdx
movq %r12, %rdi
xorl %esi, %esi
callq 0x2220
movq %r12, %rdi
callq 0x2030
movq %rax, %r15
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2220
movq %r12, %rdi
callq 0x3f7e
callq 0x2d98
testb $0x1, 0x40(%rsp)
jne 0x3710
leaq 0x6512(%rip), %rsi      # 0x9a88
pushq $0x2
popq %rdx
callq 0x2f54
cmpl $0x2, %eax
cmovgel %eax, %ebp
cmpl $0x4, %ebp
pushq $0x4
popq %rax
cmovll %ebp, %eax
movl %eax, 0x4(%rbx)
cmpq $0x0, 0x8(%rsp)
je 0x35a9
movq (%rsp), %rdi
movq %r14, %rsi
callq 0x2230
movq %rax, %r14
jmp 0x35b3
movq 0xb9f8(%rip), %rax      # 0xefa8
movq (%rax), %r14
movq %r14, 0x10(%rbx)
leaq 0x68(%rsp), %rdi
movq %rsp, %rsi
callq 0x2290
leaq 0x68(%rsp), %r12
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x3763
movq %r12, %rdi
callq 0x2110
leaq 0x64c6(%rip), %rsi      # 0x9aab
xorl %edx, %edx
callq 0x2f54
testq %rax, %rax
je 0x35fa
cmpq %r15, %rax
jne 0x3715
leaq 0x647f(%rip), %rsi      # 0x9a80
xorl %edx, %edx
callq 0x2f54
movl %eax, 0x8(%rbx)
testl %eax, %eax
setne %dl
movl (%rbx), %ecx
cmpl %eax, %ecx
setl %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x365a
movq 0x20(%rsp), %rsi
leaq 0x64b1(%rip), %rdi      # 0x9ade
movl %eax, %edx
xorl %eax, %eax
callq 0x2350
leaq 0x5a64(%rip), %rsi      # 0x90a1
leaq 0x645b(%rip), %rdx      # 0x9a9f
movq %rbx, %rdi
callq 0x3000
movq 0xb975(%rip), %rax      # 0xefc8
movq (%rax), %rax
movq %rax, 0x10(%rbx)
leaq 0x20(%rsp), %rdi
callq 0x2110
movq %rsp, %rdi
callq 0x2110
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x62e4(%rip), %rdi      # 0x9969
xorl %eax, %eax
callq 0x2350
callq 0x30da
movl (%rbx), %edx
leaq 0x62a8(%rip), %rdi      # 0x9942
leaq 0x649d(%rip), %rsi      # 0x9b3e
xorl %eax, %eax
callq 0x2070
xorl %edi, %edi
callq 0x2240
movq 0xb91a(%rip), %rax      # 0xefd0
movq (%rax), %rdi
leaq 0x634a(%rip), %rsi      # 0x9a0a
jmp 0x36d3
movq 0xb907(%rip), %rax      # 0xefd0
movq (%rax), %rdi
leaq 0x62b6(%rip), %rsi      # 0x9989
movq %r12, %rdx
xorl %eax, %eax
callq 0x22a0
pushq $0x1
popq %rdi
callq 0x2240
leaq 0x6222(%rip), %rdi      # 0x990e
xorl %eax, %eax
callq 0x2350
movq 0xb8d6(%rip), %rax      # 0xefd0
movq (%rax), %rdi
leaq 0x643f(%rip), %rsi      # 0x9b43
pushq $0x66
popq %rdx
xorl %eax, %eax
callq 0x22a0
jmp 0x36dd
callq 0x2d14
leaq 0x6399(%rip), %rdi      # 0x9ab5
movq %rax, %rsi
xorl %eax, %eax
callq 0x2350
movq %rax, %rbx
movl $0x4040, %esi           # imm = 0x4040
movq %r14, %rdi
callq 0x21f0
jmp 0x3749
jmp 0x3746
jmp 0x3746
jmp 0x3746
jmp 0x3746
jmp 0x3746
jmp 0x3746
jmp 0x3746
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x2110
movq %rsp, %rdi
callq 0x2110
movq %rbx, %rdi
callq 0x2300