#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*/ strcpy2(char *, char const *);
char *strtok(char *, char *);
int createTokenArray(const char *line, char tokenArray[][20]) {
  int length = 0;
  char str[100];
  char *tokenPtr;
  strcpy2(str, line);
  tokenPtr = strtok(str, " \n");
  while (tokenPtr != NULL) {
    strcpy2(tokenArray[length++], tokenPtr);
    tokenPtr = strtok(NULL, " \n");
  }
  return length;
}


x86 assembly (clang, -O0):
<createTokenArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy2@plt>
lea    -0x80(%rbp),%rdi
lea    0xeae(%rip),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     11ac <createTokenArray+0x8c>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
cltq
imul   $0x14,%rax,%rax
add    %rax,%rdi
mov    -0x88(%rbp),%rsi
call   1040 <strcpy2@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe65(%rip),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x88(%rbp)
jmp    115e <createTokenArray+0x3e>
mov    -0x14(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createTokenArray>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %rsi,%r14
mov    %rdi,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strcpy2@plt>
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strtok@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     1181 <createTokenArray+0x61>
lea    0xea9(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <strcpy2@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1030 <strtok@plt>
add    $0x14,%r14
add    $0x1,%ebx
test   %rax,%rax
jne    1160 <createTokenArray+0x40>
mov    %ebx,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c" \0A\00"
define i32 @createTokenArray(i8* %0, [20 x i8]* %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = call i32 @strcpy2(i8* %4, i8* %0)
%6 = call i8* @strtok(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %18, label %8
8: ; preds = %2, %8
%9 = phi i64 [ %11, %8 ], [ 0, %2 ]
%10 = phi i8* [ %14, %8 ], [ %6, %2 ]
%11 = add nuw i64 %9, 1
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 %9, i64 0
%13 = call i32 @strcpy2(i8* %12, i8* %10)
%14 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %8
16: ; preds = %8
%17 = trunc i64 %11 to i32
br label %18
18: ; preds = %16, %2
%19 = phi i32 [ 0, %2 ], [ %17, %16 ]
ret i32 %19
}