#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ callCommand(char *, char *);
int /*<<< orphan*/ printMessage(char *);
char *strtok(char *, char *);
void parseInput(char *input) {
  char *v = strtok(input, " \n");
  if (!v) {
    return;
  }
  char *n = strtok(NULL, " \n");
  char *overflow = strtok(NULL, " \n");
  if (overflow != NULL) {
    printMessage("Invalid command!");
    return;
  }
  if (n == NULL) {
    n = "!n";
  }
  callCommand(v, n);
}


x86 assembly (clang, -O0):
<parseInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1160 <parseInput+0x30>
jmp    11c7 <parseInput+0x97>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe95(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe81(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11a4 <parseInput+0x74>
lea    0xe69(%rip),%rdi
call   1030 <printMessage@plt>
jmp    11c7 <parseInput+0x97>
cmpq   $0x0,-0x18(%rbp)
jne    11ba <parseInput+0x8a>
lea    0xe5e(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <callCommand@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseInput>:
push   %r15
push   %r14
push   %rbx
lea    0xec4(%rip),%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     117d <parseInput+0x4d>
mov    %rax,%rbx
lea    0xeb0(%rip),%r15
xor    %edi,%edi
mov    %r15,%rsi
call   1040 <strtok@plt>
mov    %rax,%r14
xor    %edi,%edi
mov    %r15,%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     1183 <parseInput+0x53>
lea    0xe90(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printMessage@plt>
pop    %rbx
pop    %r14
pop    %r15
ret
test   %r14,%r14
lea    0xe87(%rip),%rsi
cmovne %r14,%rsi
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <callCommand@plt>

LLVM IR (-O0):
@.str = [3 x i8] c" \0A\00"
@.str.1 = [17 x i8] c"Invalid command!\00"
@.str.2 = [3 x i8] c"!n\00"
define void @parseInput(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i8* @strtok(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %1
br label %26
11: ; preds = %1
%12 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %4
%13 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %5
%14 = load i8*, i8** %5
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 @printMessage(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %26
18: ; preds = %11
%19 = load i8*, i8** %4
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %22
21: ; preds = %18
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %4
br label %22
22: ; preds = %21, %18
%23 = load i8*, i8** %3
%24 = load i8*, i8** %4
%25 = call i32 @callCommand(i8* %23, i8* %24)
br label %26
26: ; preds = %22, %16, %10
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c" \0A\00"
@.str.1 = [17 x i8] c"Invalid command!\00"
@.str.2 = [3 x i8] c"!n\00"
define void @parseInput(i8* %0) {
%2 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %14, label %4
4: ; preds = %1
%5 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = tail call i32 @printMessage(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %14
10: ; preds = %4
%11 = icmp eq i8* %5, null
%12 = select i1 %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5
%13 = tail call i32 @callCommand(i8* %2, i8* %12)
br label %14
14: ; preds = %8, %10, %1
ret void
}