// File: /workspace/github_c_makefile_star2_O3/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, 0x20(%rsp)
movq (%rsi), %rax
movq %rax, (%rsp)
movq 0x186e0(%rip), %rax     # 0x19ff8
movq (%rax), %rdi
leaq 0x11e1b(%rip), %rsi     # 0x1373d
leaq 0x11e31(%rip), %rdx     # 0x1375a
leaq 0x11e45(%rip), %r8      # 0x13775
leaq 0x11e4a(%rip), %r9      # 0x13781
movq $0x0, 0x18(%rsp)
pushq $0x40
popq %rcx
xorl %eax, %eax
callq 0x1110
cmpl $0x2, %ebx
jl 0x1efb
movq %rbx, 0x38(%rsp)
leal 0x1(%rbx), %ecx
pushq $0x1
popq %rsi
leaq 0x11d67(%rip), %r15     # 0x136cc
pushq $0x1
popq %rbp
xorl %r13d, %r13d
movl $0x0, 0xc(%rsp)
xorl %ebx, %ebx
xorl %r12d, %r12d
xorl %edx, %edx
movq 0x20(%rsp), %rax
movq %rcx, 0x28(%rsp)
movq %rsi, 0x10(%rsp)
movq (%rax,%rsi,8), %r14
testq %r14, %r14
je 0x1b54
cmpb $0x2d, (%r14)
jne 0x1b48
movb 0x1(%r14), %al
testq %rbx, %rbx
leaq 0x11d88(%rip), %rcx     # 0x13736
cmoveq %rdx, %rcx
movq %rdx, %rsi
movq %rbx, %rdx
leaq 0x11d71(%rip), %rdi     # 0x13730
cmoveq %rdi, %rdx
testb %al, %al
cmoveq %rcx, %rsi
movq %rsi, 0x30(%rsp)
cmoveq %rdx, %rbx
movq %rbx, 0x40(%rsp)
leaq 0x1(%r14), %rbx
movzbl %al, %eax
leal -0x62(%rax), %ecx
cmpl $0x18, %ecx
ja 0x19f7
movslq (%r15,%rcx,4), %rax
addq %r15, %rax
jmpq *%rax
movl %ebp, %r13d
jmp 0x1b3d
cmpl $0x42, %eax
je 0x1ad2
cmpl $0x4d, %eax
je 0x1ab3
cmpl $0x53, %eax
je 0x1b3d
jmp 0x1b5b
leaq 0x11d6f(%rip), %rax     # 0x1378d
movq %rax, 0x30(%rsp)
jmp 0x1a85
movb 0x2(%r14), %al
leal -0x31(%rax), %ecx
cmpb $0x8, %cl
ja 0x1b3d
addq $0x2, %r14
addb $-0x30, %al
movzbl %al, %edi
callq 0x11d3
jmp 0x1acd
pushq $0x2
popq %rdi
callq 0x2d0c
movl %ebp, %r12d
jmp 0x1b3d
pushq $0x3
popq %rdi
callq 0x2d0c
pushq $0x2
popq %r12
jmp 0x1b3d
callq 0x487c
jmp 0x1b3d
movl %ebp, %edi
callq 0x2d0c
xorl %r12d, %r12d
jmp 0x1b3d
xorl %r13d, %r13d
movl %ebp, %eax
movq %rax, 0x18(%rsp)
jmp 0x1b3d
decl 0x18659(%rip)           # 0x1a0f0
jmp 0x1b3d
movb $0x1, 0x18699(%rip)     # 0x1a13c
jmp 0x1b3d
incl 0x18642(%rip)           # 0x1a0f0
jmp 0x1b3d
movb 0x2(%r14), %al
leal -0x31(%rax), %ecx
cmpb $0x8, %cl
ja 0x1b3d
addq $0x2, %r14
addb $-0x30, %al
movzbl %al, %edi
callq 0x2d13
movq %r14, %rbx
jmp 0x1b3d
movb 0x2(%r14), %al
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0x1b04
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 0x1ae6
leaq 0x1(%rbx), %r14
jmp 0x1b0a
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
movb 0x1(%rbx), %al
movq %rbx, %r14
jmp 0x19d7
testq %rbx, %rbx
je 0x1b79
testq %rdx, %rdx
cmoveq %r14, %rdx
movq 0x10(%rsp), %rsi
jmp 0x1b8a
testl %eax, %eax
movq 0x10(%rsp), %rsi
jne 0x1bf8
movq 0x40(%rsp), %rbx
movq 0x30(%rsp), %rdx
movq 0x20(%rsp), %rax
jmp 0x1b85
movq %r14, %rbx
movq 0x10(%rsp), %rsi
movl %esi, 0xc(%rsp)
movq 0x28(%rsp), %rcx
incq %rsi
cmpq %rcx, %rsi
jne 0x1984
movq %rdx, %r15
testq %rbx, %rbx
leaq 0x11b8d(%rip), %rsi     # 0x13730
cmoveq %rsi, %rbx
movq %rbx, %rdi
callq 0x10f0
testl %eax, %eax
jne 0x1bd1
movq 0x1841e(%rip), %rax     # 0x19fd8
movq (%rax), %rdi
callq 0x1140
movl %eax, %edi
callq 0x1050
testl %eax, %eax
jne 0x1efb
cmpl $0x1, %r13d
jne 0x1c49
movslq 0xc(%rsp), %rax
movq 0x20(%rsp), %rcx
leaq (%rcx,%rax,8), %rdi
movq 0x38(%rsp), %rsi
subl %eax, %esi
callq 0x3593
xorl %ebx, %ebx
jmp 0x1e08
cmpl $0x48, %eax
je 0x1c3b
cmpl $0x56, %eax
jne 0x1efb
movq 0x183eb(%rip), %rax     # 0x19ff8
movq (%rax), %rdi
leaq 0x11b26(%rip), %rsi     # 0x1373d
leaq 0x11b3c(%rip), %rdx     # 0x1375a
leaq 0x11b50(%rip), %r8      # 0x13775
leaq 0x11b55(%rip), %r9      # 0x13781
pushq $0x40
popq %rcx
xorl %eax, %eax
callq 0x1110
jmp 0x1e19
movq (%rsp), %rdi
callq 0x1f28
jmp 0x1e19
movq %rbx, %r14
testq %r15, %r15
je 0x1d1b
xorl %ebx, %ebx
movq 0x18(%rsp), %r13
leaq 0x11acd(%rip), %rsi     # 0x13730
movq %r14, %rdi
callq 0x10f0
testl %eax, %eax
jne 0x1c95
leaq 0x11ac0(%rip), %rsi     # 0x13736
movq %r15, %rdi
callq 0x10f0
testl %eax, %eax
jne 0x1c95
cmpl $0x2, 0x18467(%rip)     # 0x1a0f0
jne 0x1c95
movl $0x1, 0x1845b(%rip)     # 0x1a0f0
leaq 0x11a94(%rip), %rsi     # 0x13730
movq %r14, %rdi
callq 0x10f0
testl %eax, %eax
jne 0x1cc6
movq 0x18329(%rip), %rax     # 0x19fd8
movq (%rax), %rdi
callq 0x1140
movl %eax, %edi
callq 0x1050
testl %eax, %eax
jne 0x1efb
leaq 0x11a69(%rip), %rsi     # 0x13736
movq %r15, %rdi
callq 0x10f0
testl %eax, %eax
jne 0x1cf7
movq 0x182f0(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x1140
movl %eax, %edi
callq 0x1050
testl %eax, %eax
jne 0x1efb
movl 0x183f3(%rip), %edi     # 0x1a0f0
callq 0x488b
testl %r13d, %r13d
je 0x1df5
movq %r15, %rdi
movq %r14, %rsi
callq 0x4f79
jmp 0x1e08
xorl %r15d, %r15d
movq 0x18(%rsp), %r13
movq 0x182a6(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x1140
movl %eax, %edi
callq 0x1050
testl %eax, %eax
je 0x1e2a
movq %r13, %rbx
movq %r14, %r13
movq %r14, %rdi
callq 0x1090
movq %rax, %rbp
testl %ebx, %ebx
je 0x1e38
leaq 0x2(%rbp), %rax
cmpq %rax, %r15
cmovbeq %rax, %r15
pushq $0x1
popq %rdi
movq %r15, %rsi
callq 0x10e0
movq %rax, %rbx
movq %rax, %rdi
movq %r13, %rsi
callq 0x1040
cmpq $0x5, %rbp
jb 0x1ed6
leaq -0x4(%rbp), %rcx
leaq 0x11a08(%rip), %rdx     # 0x1379b
movq %rbp, %rax
movb (%r14,%rax), %sil
cmpb (%rdx), %sil
jne 0x1dae
movb $0x0, (%rbx,%rax)
decq %rax
decq %rdx
cmpq %rcx, %rax
jae 0x1d96
addq $-0x5, %rbp
cmpq %rbp, %rax
jne 0x1ed6
cmpl $0x2, 0x1832e(%rip)     # 0x1a0f0
jge 0x1dd8
pushq $0x1
popq %rax
movl %eax, %r13d
testq %rbx, %rbx
je 0x1d23
jmp 0x1e85
movq 0x18219(%rip), %rax     # 0x19ff8
movq (%rax), %rdi
leaq 0x11a1c(%rip), %rsi     # 0x13805
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1110
jmp 0x1dc4
movl %r12d, %edi
callq 0x4884
movq %r15, %rdi
movq %r14, %rsi
callq 0x48a1
cmpb $0x1, 0x1832d(%rip)     # 0x1a13c
je 0x1e90
movq %rbx, %rdi
callq 0x1030
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
leaq 0x11903(%rip), %r15     # 0x13736
jmp 0x1c5c
movq %rbp, %rsi
addq $0x6, %rsi
cmpq %rsi, %r15
cmovaq %r15, %rsi
pushq $0x1
popq %rdi
callq 0x10e0
testq %rax, %rax
je 0x1f04
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x1040
movl $0x6573662e, (%rbx,%rbp) # imm = 0x6573662E
movb $0x0, 0x4(%rbx,%rbp)
xorl %r13d, %r13d
cmpl $0x2, 0x18275(%rip)     # 0x1a0f0
jge 0x1eb6
movq %rbx, %r15
jmp 0x1c5c
movq %rbx, %r15
movl %eax, %r13d
jmp 0x1c5c
movq 0x18161(%rip), %rax     # 0x19ff8
movq (%rax), %rcx
leaq 0x11b1b(%rip), %rdi     # 0x139bc
pushq $0x1b
popq %rsi
pushq $0x1
popq %rdx
callq 0x1190
callq 0x1100
jmp 0x1e11
movq 0x1813b(%rip), %rax     # 0x19ff8
movq (%rax), %rdi
leaq 0x118f6(%rip), %rsi     # 0x137bd
xorl %r13d, %r13d
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1110
jmp 0x1e7d
cmpl $0x0, 0x18213(%rip)     # 0x1a0f0
jle 0x1efb
movq 0x18112(%rip), %rax     # 0x19ff8
movq (%rax), %rcx
leaq 0x118f0(%rip), %rdi     # 0x137e0
pushq $0x24
popq %rsi
pushq $0x1
popq %rdx
callq 0x1190
movq (%rsp), %rdi
callq 0x4834
movq 0x180ed(%rip), %rax     # 0x19ff8
movq (%rax), %rcx
leaq 0x11887(%rip), %rdi     # 0x1379c
pushq $0x20
popq %rsi
pushq $0x1
popq %rdx
callq 0x1190
pushq $0x1
popq %rdi
callq 0x1180