#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 */
char **malloc(int);
char *strtok(char *, char *);
char **parseInput(char *cmdLine) {
  char **tokenList = malloc(514 * sizeof(char *));
  char *token = strtok(cmdLine, " \t\n\r");
  int i = 0;
  while (token != NULL) {
    tokenList[i] = token;
    i++;
    token = strtok(NULL, " \t\n\r");
  }
  tokenList[i] = NULL;
  return tokenList;
}


x86 assembly (clang, -O0):
<parseInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x1010,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xebb(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1192 <parseInput+0x72>
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe7c(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
jmp    1155 <parseInput+0x35>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseInput>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x1010,%edi
call   1030 <malloc@plt>
mov    %rax,%r15
lea    0xec4(%rip),%rsi
mov    %r14,%rdi
call   1040 <strtok@plt>
test   %rax,%rax
je     117b <parseInput+0x5b>
xor    %ebx,%ebx
lea    0xeae(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rax,(%r15,%rbx,8)
add    $0x1,%rbx
xor    %edi,%edi
mov    %r14,%rsi
call   1040 <strtok@plt>
test   %rax,%rax
jne    1160 <parseInput+0x40>
mov    %ebx,%eax
jmp    117d <parseInput+0x5d>
xor    %eax,%eax
movq   $0x0,(%r15,%rax,8)
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c" \09\0A\0D\00"
define noalias i8** @parseInput(i8* %0) {
%2 = tail call i8** @malloc(i32 4112)
%3 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %14, label %5
5: ; preds = %1, %5
%6 = phi i64 [ %9, %5 ], [ 0, %1 ]
%7 = phi i8* [ %10, %5 ], [ %3, %1 ]
%8 = getelementptr inbounds i8*, i8** %2, i64 %6
store i8* %7, i8** %8
%9 = add nuw i64 %6, 1
%10 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %5
12: ; preds = %5
%13 = and i64 %9, 4294967295
br label %14
14: ; preds = %12, %1
%15 = phi i64 [ 0, %1 ], [ %13, %12 ]
%16 = getelementptr inbounds i8*, i8** %2, i64 %15
store i8* null, i8** %16
ret i8** %2
}