// File: /workspace/github_c_makefile_star2_O1/Cyan4973[P]FiniteStateEntropy/programs/commandline.c
// Function: main
int main(int argc, const char** argv)
{
    int   i,
          forceCompress = 1,  /* default action if no argument */
          decode= 0,
          bench = 0;
    int   indexFileNames = 0;
    const char* input_filename = NULL;
    const char* output_filename= NULL;
    char*  tmpFilenameBuffer   = NULL;
    size_t tmpFilenameSize     = 0;
    const char extension[] = FSE_EXTENSION;
    const char* const programName = argv[0];
    FIO_compressor_t compressor = FIO_fse;

    DISPLAY(WELCOME_MESSAGE);
    if (argc<2) badusage(programName);

    for(i = 1; i <= argc; i++) {
        const char* argument = argv[i];

        if(!argument) continue;   /* Protection if argument empty */

        // Decode command (note : aggregated commands are allowed)
        if (argument[0]=='-') {
            // '-' means stdin/stdout
            if (argument[1]==0) {
                if (!input_filename) input_filename=stdinmark;
                else output_filename=stdoutmark;
            }

            while (argument[1]!=0) {
                argument ++;

                switch(argument[0])
                {
                    // Display help
                case 'V': DISPLAY(WELCOME_MESSAGE); return 0;   // Version
                case 'H': usage(programName); return 0;

                    // Decoding
                case 'd': decode=1; bench=0; break;

                    // Benchmark full mode
                case 'b': bench=1; break;

                    // FSE selection (default)
                case 'e':
                    BMK_SetByteCompressor(1);
                    compressor = FIO_fse;
                    break;

                    // HUF selection
                case 'h':
                    BMK_SetByteCompressor(2);
                    compressor = FIO_huf;
                    break;

                    // zlib mode
                case 'z':
                    BMK_SetByteCompressor(3);
                    compressor = FIO_zlibh;
                    break;

                    // Test
                case 't': decode=1; output_filename=nulmark; break;

                    // Overwrite
                case 'f': FIO_overwriteMode(); break;

                    // Verbose mode
                case 'v': displayLevel++; break;

                    // Quiet mode
                case 'q': displayLevel--; break;

                    // keep source file (default anyway, so useless) (for xz/lzma compatibility)
                case 'k': break;

                    // Modify Block Properties
                case 'B':
                    {   unsigned bSize = 0;
                        while ((argument[1] >='0') && (argument[1] <='9'))
                        {
                            unsigned digit = argument[1] - '0';
                            bSize *= 10;
                            bSize += digit;
                            argument++;
                        }
                        if (argument[1]=='K') bSize<<=10, argument++;  /* allows using KB notation */
                        if (argument[1]=='M') bSize<<=20, argument++;
                        if (argument[1]=='B') argument++;
                        BMK_SetBlocksize(bSize);
                    }
                    break;

                    // Modify Stream properties
                case 'S': break;   // to be completed later

                    // Modify Nb Iterations (benchmark only)
                case 'i':
                    if ((argument[1] >='1') && (argument[1] <='9')) {
                        int iters = argument[1] - '0';
                        BMK_SetNbIterations(iters);
                        argument++;
                    }
                    break;

                    // Pause at the end (hidden option)
                case 'p': fse_pause=1; break;

                    /* Change FSE tableLog size (hidden option) */
                case 'M':
                    if ((argument[1] >='1') && (argument[1] <='9')) {
                        int tableLog = argument[1] - '0';
                        BMK_SetTableLog(tableLog);
                        argument++;
                    }
                    break;

                    /* Unrecognised command */
                default : badusage(programName);
                }
            }
            continue;
        }

        /* first provided filename is input */
        if (!input_filename) { input_filename=argument; indexFileNames=i; continue; }

        /* second provided filename is output */
        if (!output_filename) { output_filename=argument; continue; }
    }

    /* No input filename ==> use stdin */
    if(!input_filename) { input_filename=stdinmark; }

    /* Check if input is defined as console; trigger an error in this case */
    if (!strcmp(input_filename, stdinmark) && IS_CONSOLE(stdin) ) badusage(programName);

    /* Check if benchmark is selected */
    if (bench==1) { BMK_benchFiles(argv+indexFileNames, argc-indexFileNames); goto _end; }
    if (bench==3) { BMK_benchCore_Files(argv+indexFileNames, argc-indexFileNames); goto _end; }   /* no longer possible */

    /* No output filename ==> try to select one automatically (when possible) */
    while (!output_filename) {
        if (!IS_CONSOLE(stdout)) { output_filename=stdoutmark; break; }   // Default to stdout whenever possible (i.e. not a console)
        if ((!decode) && !(forceCompress)) {   // auto-determine compression or decompression, based on file extension
            size_t const l = strlen(input_filename);
            if (!strcmp(input_filename+(l-4), FSE_EXTENSION)) decode=1;
        }
        if (!decode) {   /* compression to file */
            size_t const l = strlen(input_filename);
            if (tmpFilenameSize < l+6) tmpFilenameSize = l+6;
            tmpFilenameBuffer = (char*)calloc(1,tmpFilenameSize);
            if (tmpFilenameBuffer==NULL) {
                DISPLAY("Not enough memory, exiting ... \n");
                exit(1);
            }
            strcpy(tmpFilenameBuffer, input_filename);
            strcpy(tmpFilenameBuffer+l, FSE_EXTENSION);
            output_filename = tmpFilenameBuffer;
            DISPLAYLEVEL(2, "Compressed filename will be : %s \n", output_filename);
            break;
        }
        /* decompression to file (automatic name will work only if input filename has correct format extension) */
        {   size_t outl;
            size_t const inl = strlen(input_filename);
            if (tmpFilenameSize < inl+2) tmpFilenameSize = inl+2;
            tmpFilenameBuffer = (char*)calloc(1,tmpFilenameSize);
            strcpy(tmpFilenameBuffer, input_filename);
            outl = inl;
            if (inl>4)
                while ((outl >= inl-4) && (input_filename[outl] ==  extension[outl-inl+4])) tmpFilenameBuffer[outl--]=0;
            if (outl != inl-5) { DISPLAYLEVEL(1, "Cannot determine an output filename\n"); badusage(programName); }
            output_filename = tmpFilenameBuffer;
            DISPLAYLEVEL(2, "Decoding into filename : %s \n", output_filename);
        }
    }   /* (!output_filename) */

    /* No warning message in pure pipe mode (stdin + stdout) */
    if (!strcmp(input_filename, stdinmark) && !strcmp(output_filename,stdoutmark) && (displayLevel==2)) displayLevel=1;

    /* Check if input or output are defined as console; trigger an error in this case */
    if (!strcmp(input_filename, stdinmark)  && IS_CONSOLE(stdin) ) badusage(programName);
    if (!strcmp(output_filename,stdoutmark) && IS_CONSOLE(stdout)) badusage(programName);

    FIO_setDisplayLevel(displayLevel);
    if (decode) FIO_decompressFilename(output_filename, input_filename);
    else {
        FIO_setCompressor(compressor);
        FIO_compressFilename(output_filename, input_filename);
    }

_end:
    if (fse_pause) waitEnter();
    free(tmpFilenameBuffer);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edi, %ebx
movq %rsi, 0x18(%rsp)
movq (%rsi), %rax
movq %rax, 0x8(%rsp)
movq 0x176ea(%rip), %rax     # 0x18ff8
movq (%rax), %rdi
leaq 0x10d65(%rip), %rsi     # 0x1267d
leaq 0x10d7b(%rip), %rdx     # 0x1269a
leaq 0x10d8f(%rip), %r8      # 0x126b5
leaq 0x10d94(%rip), %r9      # 0x126c1
pushq $0x40
popq %rcx
xorl %eax, %eax
callq 0x1110
cmpl $0x2, %ebx
jl 0x1f14
movq %rbx, 0x40(%rsp)
leal 0x1(%rbx), %edi
pushq $0x1
popq %r8
pushq $0x1
popq %rbp
leaq 0x10cb6(%rip), %r15     # 0x1260c
xorl %r12d, %r12d
xorl %r13d, %r13d
movl $0x0, 0x24(%rsp)
xorl %r14d, %r14d
movl $0x0, 0x4(%rsp)
xorl %ecx, %ecx
movq 0x18(%rsp), %rdx
movq %rdi, 0x30(%rsp)
movq (%rdx,%r8,8), %rbx
testq %rbx, %rbx
je 0x1b38
cmpb $0x2d, (%rbx)
jne 0x1b3d
movq %r8, 0x38(%rsp)
testq %r14, %r14
leaq 0x10cd6(%rip), %rax     # 0x12676
cmoveq %rcx, %rax
movq %rcx, %rdx
movq %r14, %rcx
leaq 0x10cbf(%rip), %rsi     # 0x12670
cmoveq %rsi, %rcx
cmpb $0x0, 0x1(%rbx)
cmoveq %rax, %rdx
movq %rdx, 0x28(%rsp)
cmoveq %rcx, %r14
movq %r14, 0x10(%rsp)
movq %rbx, %r14
incq %rbx
movzbl 0x1(%r14), %eax
leal -0x62(%rax), %ecx
cmpl $0x18, %ecx
ja 0x19ec
movslq (%r15,%rcx,4), %rax
addq %r15, %rax
jmpq *%rax
movl %ebp, %r13d
jmp 0x19cb
cmpl $0x42, %eax
je 0x1ac8
cmpl $0x4d, %eax
je 0x1aa2
cmpl $0x53, %eax
je 0x19cb
jmp 0x1b53
incl 0x176e2(%rip)           # 0x190f0
jmp 0x19cb
movb $0x1, 0x17725(%rip)     # 0x1913c
jmp 0x19cb
movb 0x2(%r14), %al
leal -0x31(%rax), %ecx
cmpb $0x8, %cl
ja 0x19cb
addq $0x2, %r14
addb $-0x30, %al
movzbl %al, %edi
callq 0x11d3
movq %r14, %rbx
jmp 0x19cb
pushq $0x2
popq %rdi
callq 0x2abc
movl %ebp, 0x4(%rsp)
jmp 0x19cb
callq 0x40d4
jmp 0x19cb
movl %ebp, %edi
callq 0x2abc
movl $0x0, 0x4(%rsp)
jmp 0x19cb
xorl %r13d, %r13d
movl %ebp, %r12d
jmp 0x19cb
leaq 0x10c57(%rip), %rax     # 0x126cd
movq %rax, 0x28(%rsp)
movl %ebp, %r12d
jmp 0x19cb
decl 0x17667(%rip)           # 0x190f0
jmp 0x19cb
pushq $0x3
popq %rdi
callq 0x2abc
pushq $0x2
popq %rax
movl %eax, 0x4(%rsp)
jmp 0x19cb
movb 0x2(%r14), %al
leal -0x31(%rax), %ecx
cmpb $0x8, %cl
ja 0x19cb
addq $0x2, %r14
addb $-0x30, %al
movzbl %al, %edi
callq 0x2ac3
movq %r14, %rbx
jmp 0x19cb
movb 0x2(%r14), %al
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0x1afa
incq %r14
xorl %ecx, %ecx
movq %r14, %rbx
addb $-0x30, %al
movzbl %al, %eax
imull $0xa, %ecx, %ecx
addl %eax, %ecx
movb 0x2(%rbx), %al
leal -0x30(%rax), %edx
incq %rbx
cmpb $0xa, %dl
jb 0x1adc
leaq 0x1(%rbx), %r14
jmp 0x1b00
addq $0x2, %r14
xorl %ecx, %ecx
movl %ecx, %edx
shll $0xa, %edx
cmpb $0x4b, %al
cmoveq %r14, %rbx
cmovnel %ecx, %edx
leaq 0x1(%rbx), %rax
movl %edx, %edi
shll $0x14, %edi
cmpb $0x4d, 0x1(%rbx)
cmovneq %rbx, %rax
cmovnel %edx, %edi
leaq 0x1(%rax), %rbx
cmpb $0x42, 0x1(%rax)
cmovneq %rax, %rbx
callq 0x11b0
jmp 0x19cb
pushq $0x4
popq %rax
jmp 0x1b80
testq %r14, %r14
je 0x1b75
xorl %eax, %eax
testq %rcx, %rcx
sete %al
cmoveq %rbx, %rcx
shll $0x2, %eax
jmp 0x1b80
testl %eax, %eax
jne 0x1b96
pushq $0x4
popq %rax
movq 0x10(%rsp), %r14
movq 0x28(%rsp), %rcx
movq 0x18(%rsp), %rdx
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %r8
jmp 0x1b80
pushq $0x4
popq %rax
movq %rbx, %r14
movl %r8d, 0x24(%rsp)
testb $0x3, %al
jne 0x1e9d
incq %r8
cmpq %rdi, %r8
jne 0x197b
jmp 0x1be7
cmpl $0x48, %eax
je 0x1bd6
cmpl $0x56, %eax
jne 0x1f14
movq 0x1744d(%rip), %rax     # 0x18ff8
movq (%rax), %rdi
leaq 0x10ac8(%rip), %rsi     # 0x1267d
leaq 0x10ade(%rip), %rdx     # 0x1269a
pushq $0x40
popq %rcx
leaq 0x10aef(%rip), %r8      # 0x126b5
leaq 0x10af4(%rip), %r9      # 0x126c1
xorl %eax, %eax
callq 0x1110
jmp 0x1be0
movq 0x8(%rsp), %rdi
callq 0x1f42
movl %ebp, %eax
jmp 0x1b5a
movq %rcx, %r15
testq %r14, %r14
leaq 0x10a7c(%rip), %rsi     # 0x12670
cmoveq %rsi, %r14
movq %r14, %rdi
callq 0x10f0
testl %eax, %eax
jne 0x1c22
movq 0x173cd(%rip), %rax     # 0x18fd8
movq (%rax), %rdi
callq 0x1140
movl %eax, %edi
callq 0x1050
testl %eax, %eax
jne 0x1f14
cmpl $0x1, %r13d
movq 0x18(%rsp), %rcx
jne 0x1c49
movslq 0x24(%rsp), %rax
leaq (%rcx,%rax,8), %rdi
movq 0x40(%rsp), %rsi
subl %eax, %esi
callq 0x3369
xorl %ebx, %ebx
jmp 0x1e8c
testq %r15, %r15
je 0x1c55
xorl %ebx, %ebx
jmp 0x1dc0
movq 0x17374(%rip), %rax     # 0x18fd0
movq (%rax), %rdi
callq 0x1140
movl %eax, %edi
callq 0x1050
testl %eax, %eax
je 0x1d56
movq %r14, 0x10(%rsp)
testl %r12d, %r12d
sete %r15b
pushq $0x1
popq %r12
xorl %r13d, %r13d
movq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x1090
movq %rax, %rbp
testb $0x1, %r15b
jne 0x1d61
leaq 0x2(%rbp), %rax
cmpq %rax, %r13
cmovbeq %rax, %r13
pushq $0x1
popq %rdi
movq %r13, %rsi
callq 0x10e0
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x1040
cmpq $0x5, %rbp
jb 0x1cf2
leaq -0x4(%rbp), %rcx
leaq 0x10a06(%rip), %rdx     # 0x126db
movq %rbp, %rax
movb (%r14,%rax), %sil
cmpb (%rdx), %sil
jne 0x1cf5
movb $0x0, (%rbx,%rax)
decq %rax
decq %rdx
cmpq %rcx, %rax
jae 0x1cd8
jmp 0x1cf5
movq %rbp, %rax
addq $-0x5, %rbp
movl 0x173f1(%rip), %ecx     # 0x190f0
cmpq %rbp, %rax
jne 0x1ef4
cmpl $0x2, %ecx
jge 0x1d39
testq %rbx, %rbx
jne 0x1daf
movq 0x172b3(%rip), %rax     # 0x18fd0
movq (%rax), %rdi
callq 0x1140
movl %eax, %edi
callq 0x1050
xorl %r15d, %r15d
testl %eax, %eax
jne 0x1c8b
jmp 0x1db4
movq 0x172b8(%rip), %rax     # 0x18ff8
movq (%rax), %rdi
leaq 0x109fb(%rip), %rsi     # 0x12745
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1110
jmp 0x1d0d
xorl %ebx, %ebx
leaq 0x10917(%rip), %r15     # 0x12676
jmp 0x1dc0
movq %rbp, %rsi
addq $0x6, %rsi
cmpq %rsi, %r13
cmovaq %r13, %rsi
pushq $0x1
popq %rdi
callq 0x10e0
testq %rax, %rax
je 0x1f1e
movq %rax, %rbx
movq %rax, %rdi
movq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0x1040
movl $0x6573662e, (%rbx,%rbp) # imm = 0x6573662E
movb $0x0, 0x4(%rbx,%rbp)
xorl %r12d, %r12d
cmpl $0x2, 0x17347(%rip)     # 0x190f0
jge 0x1ed1
movq %rbx, %r15
jmp 0x1dc0
leaq 0x108bb(%rip), %r15     # 0x12676
movq 0x10(%rsp), %r14
leaq 0x108a9(%rip), %rsi     # 0x12670
movq %r14, %rdi
callq 0x10f0
testl %eax, %eax
jne 0x1df9
leaq 0x1089c(%rip), %rsi     # 0x12676
movq %r15, %rdi
callq 0x10f0
testl %eax, %eax
jne 0x1df9
cmpl $0x2, 0x17303(%rip)     # 0x190f0
jne 0x1df9
movl $0x1, 0x172f7(%rip)     # 0x190f0
leaq 0x10870(%rip), %rsi     # 0x12670
movq %r14, %rdi
callq 0x10f0
testl %eax, %eax
jne 0x1e2a
movq 0x171c5(%rip), %rax     # 0x18fd8
movq (%rax), %rdi
callq 0x1140
movl %eax, %edi
callq 0x1050
testl %eax, %eax
jne 0x1f14
leaq 0x10845(%rip), %rsi     # 0x12676
movq %r15, %rdi
callq 0x10f0
testl %eax, %eax
jne 0x1e5b
movq 0x1718c(%rip), %rax     # 0x18fd0
movq (%rax), %rdi
callq 0x1140
movl %eax, %edi
callq 0x1050
testl %eax, %eax
jne 0x1f14
movl 0x1728f(%rip), %edi     # 0x190f0
callq 0x40e3
testl %r12d, %r12d
je 0x1e78
movq %r15, %rdi
movq %r14, %rsi
callq 0x4a49
jmp 0x1e8c
movl 0x4(%rsp), %edi
callq 0x40dc
movq %r15, %rdi
movq %r14, %rsi
callq 0x40f9
cmpb $0x1, 0x172a9(%rip)     # 0x1913c
je 0x1eae
movq %rbx, %rdi
callq 0x1030
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x17143(%rip), %rax     # 0x18ff8
movq (%rax), %rcx
leaq 0x10a3d(%rip), %rdi     # 0x128fc
pushq $0x1b
popq %rsi
pushq $0x1
popq %rdx
callq 0x1190
callq 0x1100
jmp 0x1e95
movq 0x17120(%rip), %rax     # 0x18ff8
movq (%rax), %rdi
leaq 0x1081b(%rip), %rsi     # 0x126fd
xorl %r12d, %r12d
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1110
jmp 0x1daf
testl %ecx, %ecx
jle 0x1f14
movq 0x170f9(%rip), %rax     # 0x18ff8
movq (%rax), %rcx
leaq 0x10817(%rip), %rdi     # 0x12720
pushq $0x24
popq %rsi
pushq $0x1
popq %rdx
callq 0x1190
movq 0x8(%rsp), %rdi
callq 0x408c
movq 0x170d3(%rip), %rax     # 0x18ff8
movq (%rax), %rcx
leaq 0x107ad(%rip), %rdi     # 0x126dc
pushq $0x20
popq %rsi
pushq $0x1
popq %rdx
callq 0x1190
pushq $0x1
popq %rdi
callq 0x1180