// File: /workspace/github_c_makefile_star2_O3/mohuangrui[P]ArtraCFD/program_entrance.c
// Function: EnterProgram
int EnterProgram(int argc, char *argv[], Control *control, Space *space)
{
    /*
     * Loop through command line to process options
     * The procedure main takes two arguments: argc and argv. The parameter
     * argc is the number of arguments on the command line (including the
     * program name). The array argv contains the actual arguments.
     * A standard command-line format has the form:
     * command options file1 file2 file3 ...
     * Options are preceded by a dash (-) and are usually a single letter.
     * If the option takes a parameter, it follows the letter with a space.
     * A while loop is used to cycle through the command-line options.
     * One argument always exists: the program name. The expression
     * (argc > 1) checks for additional arguments. The first one is
     * numbered 1. The first character of the first argument is argv[1][0].
     * If this is a dash, there is an option. The switch statement is used
     * to decode the options.
     */
    while ((1 < argc) && ('-' == argv[1][0])) { /* options present */
        if (3 > argc) { /* not enough arguments */
            ShowError("empty entry after: %s\n", argv[1]);
            exit(EXIT_FAILURE);
        }
        switch (argv[1][1]) { /* argv[1][1] is the actual option character */
            /* run mode: -m [gui], [serial], [omp], [mpi], [gpu] */
            case 'm':
                ++argv;
                --argc;
                if (0 == strcmp(argv[1], "gui")) {
                    control->runMode = 'i';
                    break;
                }
                if (0 == strcmp(argv[1], "serial")) {
                    control->runMode = 's';
                    break;
                }
                if (0 == strcmp(argv[1], "omp")) {
                    control->runMode = 'o';
                    break;
                }
                if (0 == strcmp(argv[1], "mpi")) {
                    control->runMode = 'm';
                    break;
                }
                if (0 == strcmp(argv[1], "gpu")) {
                    control->runMode = 'g';
                    break;
                }
                ShowError("bad option: %s\n", argv[1]);
                exit(EXIT_FAILURE);
                /* number of processors: -n nx*ny*nz */
            case 'n':
                ++argv;
                --argc;
                Sscanf(argv[1], 3, "%d*%d*%d", &(control->proc[X]),
                        &(control->proc[Y]), &(control->proc[Z]));
                break;
            default:
                ShowError("bad option: %s\n", argv[1]);
                exit(EXIT_FAILURE);
        }
        /* adjust argument list and count to consume an option */
        ++argv;
        --argc;
    }
    /* check information left */
    if (1 != argc) {
        ShowWarning("unidentified arguments ignored: %s...\n", argv[1]);
    }
    /* configure program according to inputted options */
    ConfigureProgram(control, space);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rcx, (%rsp)
movq %rdx, %rbp
movq %rsi, %rbx
movl %edi, %r14d
cmpl $0x2, %edi
jl 0x163b7
leaq 0x4(%rbp), %rax
movq %rax, 0x8(%rsp)
leaq 0x8(%rbp), %r12
leaq 0xc(%rbp), %r13
movq 0x8(%rbx), %rsi
cmpb $0x2d, (%rsi)
jne 0x163c3
cmpl $0x2, %r14d
je 0x166d9
movzbl 0x1(%rsi), %eax
cmpl $0x6e, %eax
je 0x16366
cmpl $0x6d, %eax
jne 0x166f7
movq 0x10(%rbx), %r15
movq %r15, %rdi
leaq 0x999e(%rip), %rsi      # 0x1fca5
callq 0x2140
testl %eax, %eax
je 0x1638a
movq %r15, %rdi
leaq 0x998f(%rip), %rsi      # 0x1fca9
callq 0x2140
testl %eax, %eax
je 0x16390
movq %r15, %rdi
leaq 0x9983(%rip), %rsi      # 0x1fcb0
callq 0x2140
testl %eax, %eax
je 0x16396
movq %r15, %rdi
leaq 0x9974(%rip), %rsi      # 0x1fcb4
callq 0x2140
testl %eax, %eax
je 0x1639c
movq %r15, %rdi
leaq 0x9965(%rip), %rsi      # 0x1fcb8
callq 0x2140
testl %eax, %eax
jne 0x1670f
movb $0x67, (%rbp)
jmp 0x163a0
movq 0x10(%rbx), %rdi
movl $0x3, %esi
leaq 0x9956(%rip), %rdx      # 0x1fccc
movq 0x8(%rsp), %rcx
movq %r12, %r8
movq %r13, %r9
xorl %eax, %eax
callq 0x912d
jmp 0x163a0
movb $0x69, (%rbp)
jmp 0x163a0
movb $0x73, (%rbp)
jmp 0x163a0
movb $0x6f, (%rbp)
jmp 0x163a0
movb $0x6d, (%rbp)
addq $0x10, %rbx
leal -0x2(%r14), %eax
cmpl $0x3, %r14d
movl %eax, %r14d
jg 0x162d0
jmp 0x163ba
movl %r14d, %eax
cmpl $0x1, %eax
je 0x163d1
movq 0x8(%rbx), %rsi
leaq 0x990b(%rip), %rdi      # 0x1fcd5
xorl %eax, %eax
callq 0x8ce5
movsbl (%rbp), %eax
addl $-0x67, %eax
rorl %eax
leal -0x3(%rax), %ecx
cmpl $0x2, %ecx
jb 0x1665c
cmpl $0x6, %eax
movq (%rsp), %rcx
je 0x1669f
cmpl $0x1, %eax
jne 0x166c5
movq %rbp, 0x8(%rsp)
leaq 0x2f1d(%rip), %rbx      # 0x19325
movq %rbx, %rdi
xorl %eax, %eax
callq 0x8e15
leaq 0x98e3(%rip), %rdi      # 0x1fcfc
xorl %eax, %eax
callq 0x8e15
leaq 0x2f44(%rip), %rdi      # 0x1936b
xorl %eax, %eax
callq 0x8e15
leaq 0x2f74(%rip), %rdi      # 0x193a9
xorl %eax, %eax
callq 0x8e15
movq %rbx, %rdi
xorl %eax, %eax
callq 0x8e15
leaq 0x2f9a(%rip), %rdi      # 0x193e7
xorl %eax, %eax
callq 0x8e15
movq %rbx, %rdi
xorl %eax, %eax
callq 0x8e15
leaq 0x10(%rsp), %r15
movl $0xc8, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x20d0
leaq 0x98c1(%rip), %r12      # 0x1fd3a
movq 0xdb58(%rip), %rbx      # 0x23fd8
leaq 0x7b6e(%rip), %r13      # 0x1dff5
movl $0x706c6568, %r14d      # imm = 0x706C6568
movl $0x74696e69, %ebp       # imm = 0x74696E69
movq %r12, %rdi
xorl %eax, %eax
callq 0x8e15
movq (%rbx), %rdx
movq %r15, %rdi
movl $0xc8, %esi
callq 0x2120
movq %rax, %rdi
callq 0x8c2c
movq %r13, %rdi
xorl %eax, %eax
callq 0x8e15
movl 0x10(%rsp), %eax
xorl %r14d, %eax
movzbl 0x14(%rsp), %ecx
orl %eax, %ecx
je 0x1656f
movl 0x10(%rsp), %eax
xorl %ebp, %eax
movzbl 0x14(%rsp), %ecx
orl %eax, %ecx
je 0x165cf
movl 0x10(%rsp), %eax
movl $0x636c6163, %ecx       # imm = 0x636C6163
xorl %ecx, %eax
movzbl 0x14(%rsp), %ecx
orl %eax, %ecx
je 0x165dd
movl 0x10(%rsp), %eax
movl $0x756e616d, %ecx       # imm = 0x756E616D
xorl %ecx, %eax
movl 0x13(%rsp), %ecx
movl $0x6c6175, %edx         # imm = 0x6C6175
xorl %edx, %ecx
orl %eax, %ecx
je 0x165e7
cmpb $0x0, 0x10(%rsp)
je 0x16492
movl 0x10(%rsp), %eax
movl $0x766c6f73, %ecx       # imm = 0x766C6F73
xorl %ecx, %eax
movzwl 0x14(%rsp), %ecx
xorl $0x65, %ecx
orl %eax, %ecx
je 0x16685
movl 0x10(%rsp), %eax
movl $0x74697865, %ecx       # imm = 0x74697865
xorl %ecx, %eax
movzbl 0x14(%rsp), %ecx
orl %eax, %ecx
je 0x166e2
leaq 0x9911(%rip), %rdi      # 0x1fe71
movq %r15, %rsi
xorl %eax, %eax
callq 0x8ce5
jmp 0x16492
leaq 0x97d2(%rip), %rdi      # 0x1fd48
xorl %eax, %eax
callq 0x8e15
leaq 0x97e1(%rip), %rdi      # 0x1fd65
xorl %eax, %eax
callq 0x8e15
leaq 0x97f4(%rip), %rdi      # 0x1fd86
xorl %eax, %eax
callq 0x8e15
leaq 0x9812(%rip), %rdi      # 0x1fdb2
xorl %eax, %eax
callq 0x8e15
leaq 0x9831(%rip), %rdi      # 0x1fddf
xorl %eax, %eax
callq 0x8e15
leaq 0x984b(%rip), %rdi      # 0x1fe07
xorl %eax, %eax
callq 0x8e15
leaq 0x9859(%rip), %rdi      # 0x1fe23
jmp 0x16650
callq 0x389c
leaq 0x9865(%rip), %rdi      # 0x1fe40
jmp 0x16650
callq 0x2c1c
jmp 0x16492
leaq 0x9898(%rip), %rdi      # 0x1fe86
xorl %eax, %eax
callq 0x8e15
leaq 0x98ad(%rip), %rdi      # 0x1fea9
xorl %eax, %eax
callq 0x8e15
leaq 0x98aa(%rip), %rdi      # 0x1feb4
xorl %eax, %eax
callq 0x8e15
leaq 0x98cc(%rip), %rdi      # 0x1fee4
xorl %eax, %eax
callq 0x8e15
leaq 0x98c8(%rip), %rdi      # 0x1feee
xorl %eax, %eax
callq 0x8e15
leaq 0x98fa(%rip), %rdi      # 0x1ff2e
xorl %eax, %eax
callq 0x8e15
leaq 0x992a(%rip), %rdi      # 0x1ff6c
xorl %eax, %eax
callq 0x8e15
leaq 0x9924(%rip), %rdi      # 0x1ff74
xorl %eax, %eax
callq 0x8e15
jmp 0x16492
movl 0x4(%rbp), %eax
movq (%rsp), %rcx
movl %eax, 0x420(%rcx)
movl 0x8(%rbp), %eax
movl %eax, 0x424(%rcx)
movl 0xc(%rbp), %eax
movl %eax, 0x428(%rcx)
imull 0x4(%rbp), %eax
imull 0x8(%rbp), %eax
jmp 0x166bf
movq 0x8(%rsp), %rax
movb $0x73, (%rax)
leaq 0x2c91(%rip), %rdi      # 0x19325
xorl %eax, %eax
callq 0x8e15
movq (%rsp), %rcx
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x420(%rcx)
movl $0x1, 0x428(%rcx)
movl $0x1, %eax
movl %eax, 0x42c(%rcx)
xorl %eax, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x95ae(%rip), %rdi      # 0x1fc8e
jmp 0x166fe
leaq 0x2c3c(%rip), %rdi      # 0x19325
xorl %eax, %eax
callq 0x8e15
xorl %edi, %edi
callq 0x21f0
leaq 0x95be(%rip), %rdi      # 0x1fcbc
xorl %eax, %eax
callq 0x8d7e
movl $0x1, %edi
callq 0x21f0
leaq 0x95a6(%rip), %rdi      # 0x1fcbc
movq %r15, %rsi
jmp 0x166fe
nop