// File: /workspace/github_c_makefile_star2_O1/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 0x166bb
leaq 0x4(%rbp), %rax
movq %rax, 0x8(%rsp)
leaq 0x8(%rbp), %r12
leaq 0xc(%rbp), %r13
movq 0x8(%rbx), %rsi
cmpb $0x2d, (%rsi)
jne 0x166bb
cmpl $0x2, %r14d
je 0x169e0
movzbl 0x1(%rsi), %eax
cmpl $0x6e, %eax
je 0x1666a
cmpl $0x6d, %eax
jne 0x169fe
movq 0x10(%rbx), %r15
movq %r15, %rdi
leaq 0xa60a(%rip), %rsi      # 0x20c15
callq 0x2130
testl %eax, %eax
je 0x1668e
movq %r15, %rdi
leaq 0xa5fb(%rip), %rsi      # 0x20c19
callq 0x2130
testl %eax, %eax
je 0x16694
movq %r15, %rdi
leaq 0xa5ef(%rip), %rsi      # 0x20c20
callq 0x2130
testl %eax, %eax
je 0x1669a
movq %r15, %rdi
leaq 0xa5e0(%rip), %rsi      # 0x20c24
callq 0x2130
testl %eax, %eax
je 0x166a0
movq %r15, %rdi
leaq 0xa5d1(%rip), %rsi      # 0x20c28
callq 0x2130
testl %eax, %eax
jne 0x16a16
movb $0x67, (%rbp)
jmp 0x166a4
movq 0x10(%rbx), %rdi
movl $0x3, %esi
leaq 0xa5c2(%rip), %rdx      # 0x20c3c
movq 0x8(%rsp), %rcx
movq %r12, %r8
movq %r13, %r9
xorl %eax, %eax
callq 0x9370
jmp 0x166a4
movb $0x69, (%rbp)
jmp 0x166a4
movb $0x73, (%rbp)
jmp 0x166a4
movb $0x6f, (%rbp)
jmp 0x166a4
movb $0x6d, (%rbp)
addq $0x10, %rbx
leal -0x2(%r14), %eax
cmpl $0x3, %r14d
movl %eax, %r14d
jg 0x165d4
jmp 0x166be
movl %r14d, %eax
cmpl $0x1, %eax
je 0x166d5
movq 0x8(%rbx), %rsi
leaq 0xa577(%rip), %rdi      # 0x20c45
xorl %eax, %eax
callq 0x8f21
movsbl (%rbp), %eax
addl $-0x67, %eax
rorl %eax
leal -0x3(%rax), %ecx
cmpl $0x2, %ecx
jb 0x16960
cmpl $0x6, %eax
movq (%rsp), %rcx
je 0x169a6
cmpl $0x1, %eax
jne 0x169cc
movq %rbp, 0x8(%rsp)
leaq 0x3c19(%rip), %rbx      # 0x1a325
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9051
leaq 0xa54f(%rip), %rdi      # 0x20c6c
xorl %eax, %eax
callq 0x9051
leaq 0x3c40(%rip), %rdi      # 0x1a36b
xorl %eax, %eax
callq 0x9051
leaq 0x3c70(%rip), %rdi      # 0x1a3a9
xorl %eax, %eax
callq 0x9051
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9051
leaq 0x3c96(%rip), %rdi      # 0x1a3e7
xorl %eax, %eax
callq 0x9051
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9051
leaq 0x10(%rsp), %r15
movl $0xc8, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x20d0
leaq 0xa52d(%rip), %r12      # 0x20caa
movq 0xe854(%rip), %rbx      # 0x24fd8
leaq 0x87da(%rip), %r13      # 0x1ef65
movl $0x706c6568, %r14d      # imm = 0x706C6568
movl $0x74696e69, %ebp       # imm = 0x74696E69
movq %r12, %rdi
xorl %eax, %eax
callq 0x9051
movq (%rbx), %rdx
movq %r15, %rdi
movl $0xc8, %esi
callq 0x2120
movq %rax, %rdi
callq 0x8e6c
movq %r13, %rdi
xorl %eax, %eax
callq 0x9051
movl 0x10(%rsp), %eax
xorl %r14d, %eax
movzbl 0x14(%rsp), %ecx
orl %eax, %ecx
je 0x16873
movl 0x10(%rsp), %eax
xorl %ebp, %eax
movzbl 0x14(%rsp), %ecx
orl %eax, %ecx
je 0x168d3
movl 0x10(%rsp), %eax
movl $0x636c6163, %ecx       # imm = 0x636C6163
xorl %ecx, %eax
movzbl 0x14(%rsp), %ecx
orl %eax, %ecx
je 0x168e1
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 0x168eb
cmpb $0x0, 0x10(%rsp)
je 0x16796
movl 0x10(%rsp), %eax
movl $0x766c6f73, %ecx       # imm = 0x766C6F73
xorl %ecx, %eax
movzwl 0x14(%rsp), %ecx
xorl $0x65, %ecx
orl %eax, %ecx
je 0x1698c
movl 0x10(%rsp), %eax
movl $0x74697865, %ecx       # imm = 0x74697865
xorl %ecx, %eax
movzbl 0x14(%rsp), %ecx
orl %eax, %ecx
je 0x169e9
leaq 0xa57d(%rip), %rdi      # 0x20de1
movq %r15, %rsi
xorl %eax, %eax
callq 0x8f21
jmp 0x16796
leaq 0xa43e(%rip), %rdi      # 0x20cb8
xorl %eax, %eax
callq 0x9051
leaq 0xa44d(%rip), %rdi      # 0x20cd5
xorl %eax, %eax
callq 0x9051
leaq 0xa460(%rip), %rdi      # 0x20cf6
xorl %eax, %eax
callq 0x9051
leaq 0xa47e(%rip), %rdi      # 0x20d22
xorl %eax, %eax
callq 0x9051
leaq 0xa49d(%rip), %rdi      # 0x20d4f
xorl %eax, %eax
callq 0x9051
leaq 0xa4b7(%rip), %rdi      # 0x20d77
xorl %eax, %eax
callq 0x9051
leaq 0xa4c5(%rip), %rdi      # 0x20d93
jmp 0x16954
callq 0x3a2c
leaq 0xa4d1(%rip), %rdi      # 0x20db0
jmp 0x16954
callq 0x2c28
jmp 0x16796
leaq 0xa504(%rip), %rdi      # 0x20df6
xorl %eax, %eax
callq 0x9051
leaq 0xa519(%rip), %rdi      # 0x20e19
xorl %eax, %eax
callq 0x9051
leaq 0xa516(%rip), %rdi      # 0x20e24
xorl %eax, %eax
callq 0x9051
leaq 0xa538(%rip), %rdi      # 0x20e54
xorl %eax, %eax
callq 0x9051
leaq 0xa534(%rip), %rdi      # 0x20e5e
xorl %eax, %eax
callq 0x9051
leaq 0xa566(%rip), %rdi      # 0x20e9e
xorl %eax, %eax
callq 0x9051
leaq 0xa596(%rip), %rdi      # 0x20edc
xorl %eax, %eax
callq 0x9051
leaq 0xa590(%rip), %rdi      # 0x20ee4
xorl %eax, %eax
callq 0x9051
jmp 0x16796
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)
movl 0x8(%rbp), %eax
imull 0x4(%rbp), %eax
imull 0xc(%rbp), %eax
jmp 0x169c6
movq 0x8(%rsp), %rax
movb $0x73, (%rax)
leaq 0x398a(%rip), %rdi      # 0x1a325
xorl %eax, %eax
callq 0x9051
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 0xa217(%rip), %rdi      # 0x20bfe
jmp 0x16a05
leaq 0x3935(%rip), %rdi      # 0x1a325
xorl %eax, %eax
callq 0x9051
xorl %edi, %edi
callq 0x21f0
leaq 0xa227(%rip), %rdi      # 0x20c2c
xorl %eax, %eax
callq 0x8fba
movl $0x1, %edi
callq 0x21f0
leaq 0xa20f(%rip), %rdi      # 0x20c2c
movq %r15, %rsi
jmp 0x16a05
nop