// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
xorl %eax, %eax
movl $0x1, %ecx
cmpl -0x4(%rbp), %ecx
movb %al, -0x21(%rbp)
jge 0x1f73e
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsbl (%rax), %ecx
movl $0x2d, %eax
cmpl %ecx, %eax
sete %al
movb %al, -0x21(%rbp)
movb -0x21(%rbp), %al
testb $0x1, %al
jne 0x1f74a
jmp 0x1f924
movl $0x3, %eax
cmpl -0x4(%rbp), %eax
jle 0x1f774
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0xb2d9(%rip), %rdi      # 0x2aa3c
movb $0x0, %al
callq 0xbbd0
movl $0x1, %edi
callq 0x21e0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x1(%rax), %eax
movl %eax, -0x28(%rbp)
subl $0x6d, %eax
je 0x1f79b
jmp 0x1f78a
movl -0x28(%rbp), %eax
subl $0x6e, %eax
je 0x1f898
jmp 0x1f8ea
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
movl -0x4(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xb294(%rip), %rsi      # 0x2aa53
callq 0x2120
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x1f7d8
movq -0x18(%rbp), %rax
movb $0x69, (%rax)
jmp 0x1f90a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xb270(%rip), %rsi      # 0x2aa57
callq 0x2120
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x1f800
movq -0x18(%rbp), %rax
movb $0x73, (%rax)
jmp 0x1f90a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xb24f(%rip), %rsi      # 0x2aa5e
callq 0x2120
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x1f828
movq -0x18(%rbp), %rax
movb $0x6f, (%rax)
jmp 0x1f90a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xb22b(%rip), %rsi      # 0x2aa62
callq 0x2120
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x1f850
movq -0x18(%rbp), %rax
movb $0x6d, (%rax)
jmp 0x1f90a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xb207(%rip), %rsi      # 0x2aa66
callq 0x2120
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x1f878
movq -0x18(%rbp), %rax
movb $0x67, (%rax)
jmp 0x1f90a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0xb1e3(%rip), %rdi      # 0x2aa6a
movb $0x0, %al
callq 0xbbd0
movl $0x1, %edi
callq 0x21e0
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
movl -0x4(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rcx
addq $0x4, %rcx
movq -0x18(%rbp), %r8
addq $0x4, %r8
addq $0x4, %r8
movq -0x18(%rbp), %r9
addq $0x4, %r9
addq $0x8, %r9
movl $0x3, %esi
leaq 0xb199(%rip), %rdx      # 0x2aa7a
movb $0x0, %al
callq 0xc110
jmp 0x1f90a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0xb171(%rip), %rdi      # 0x2aa6a
movb $0x0, %al
callq 0xbbd0
movl $0x1, %edi
callq 0x21e0
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
movl -0x4(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x1f717
movl $0x1, %eax
cmpl -0x4(%rbp), %eax
je 0x1f944
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0xb146(%rip), %rdi      # 0x2aa83
movb $0x0, %al
callq 0xbb20
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x1f960
xorl %eax, %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)