// File: /workspace/github_c_makefile_star2_O0/mohuangrui[P]ArtraCFD/commons.c
// Function: ParseCommand
int ParseCommand(char *cmdstr)
{
    char *scanner = cmdstr;
    char *receiver = cmdstr;
    if (NULL == cmdstr) {
        ShowWarning("parse a NULL pointer");
        return 1;
    }
    if ('\0' == *cmdstr) {
        return 1;
    }
    /* skip tabs and spaces at the front */
    while ((' ' == *scanner) || ('\t' == *scanner)) {
        *scanner = ' ';
        ++scanner;
    }
    /* process valid text */
    while ('\0' != *scanner) {
        /* skip special characters */
        if (('\r' == *scanner) || ('\n' == *scanner)) {
            ++scanner;
            continue;
        }
        /* stop at commenting text */
        if ('#' == *scanner) {
            break;
        }
        /* replace tabs with spaces and keep only one space between two words */
        if ((' ' == *scanner) || ('\t' == *scanner)) {
            *scanner = ' ';
            if (' ' != *(scanner - 1)) { /* only check space; tabs are all replaced */
                /* receive the first space between words */
                *receiver = ' ';
                ++receiver;
                ++scanner;
                continue;
            }
            /* otherwise, skip the redundant spaces */
            ++scanner;
            continue;
        }
        /* receive the normal character */
        *receiver = *scanner;
        ++receiver;
        ++scanner;
    }
    /* if received nothing, produce an empty string */
    if (receiver == cmdstr) {
        *receiver = '\0';
        return 1;
    }
    /* if ended with a space, skip it */
    if (' ' == *(receiver - 1)) {
        *(receiver - 1) = '\0';
        return 0;
    }
    *receiver = '\0';
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
xorl %eax, %eax
cmpq -0x10(%rbp), %rax
jne 0xb97e
leaq 0x1be45(%rip), %rdi     # 0x277b0
movb $0x0, %al
callq 0xbb20
movl $0x1, -0x4(%rbp)
jmp 0xbb16
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0xb997
movl $0x1, -0x4(%rbp)
jmp 0xbb16
jmp 0xb999
movq -0x18(%rbp), %rax
movsbl (%rax), %edx
movb $0x1, %al
movl $0x20, %ecx
cmpl %edx, %ecx
movb %al, -0x21(%rbp)
je 0xb9c2
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
movl $0x9, %eax
cmpl %ecx, %eax
sete %al
movb %al, -0x21(%rbp)
movb -0x21(%rbp), %al
testb $0x1, %al
jne 0xb9cb
jmp 0xb9e0
movq -0x18(%rbp), %rax
movb $0x20, (%rax)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0xb999
jmp 0xb9e2
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0xbacc
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
movl $0xd, %eax
cmpl %ecx, %eax
je 0xba13
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
movl $0xa, %eax
cmpl %ecx, %eax
jne 0xba21
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0xb9e2
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
movl $0x23, %eax
cmpl %ecx, %eax
jne 0xba36
jmp 0xbacc
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
movl $0x20, %eax
cmpl %ecx, %eax
je 0xba56
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
movl $0x9, %eax
cmpl %ecx, %eax
jne 0xbaa3
movq -0x18(%rbp), %rax
movb $0x20, (%rax)
movq -0x18(%rbp), %rax
movsbl -0x1(%rax), %ecx
movl $0x20, %eax
cmpl %ecx, %eax
je 0xba92
movq -0x20(%rbp), %rax
movb $0x20, (%rax)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0xb9e2
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0xb9e2
movq -0x18(%rbp), %rax
movb (%rax), %cl
movq -0x20(%rbp), %rax
movb %cl, (%rax)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0xb9e2
movq -0x20(%rbp), %rax
cmpq -0x10(%rbp), %rax
jne 0xbae6
movq -0x20(%rbp), %rax
movb $0x0, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0xbb16
movq -0x20(%rbp), %rax
movsbl -0x1(%rax), %ecx
movl $0x20, %eax
cmpl %ecx, %eax
jne 0xbb08
movq -0x20(%rbp), %rax
movb $0x0, -0x1(%rax)
movl $0x0, -0x4(%rbp)
jmp 0xbb16
movq -0x20(%rbp), %rax
movb $0x0, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop