#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 execute(char **);
char *makestring(char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok(char *, char *);
int tokenizeInput(char *input) {
  char buf[255];
  strcpy(buf, input);
  int numargs = 0;
  char *arglist[20 + 1];
  int flag;
  char *token = strtok(buf, " ");
  while (token != NULL) {
    arglist[numargs++] = makestring(token);
    token = strtok(NULL, " ");
  }
  arglist[numargs] = NULL;
  flag = execute(arglist);
  return flag;
}


x86 assembly (clang, -O0):
<tokenizeInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x114(%rbp)
lea    -0x110(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x1d0(%rbp)
cmpq   $0x0,-0x1d0(%rbp)
je     11d7 <tokenizeInput+0x97>
mov    -0x1d0(%rbp),%rdi
call   1050 <makestring@plt>
mov    %rax,%rcx
mov    -0x114(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x114(%rbp)
cltq
mov    %rcx,-0x1c0(%rbp,%rax,8)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xe3a(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x1d0(%rbp)
jmp    1183 <tokenizeInput+0x43>
movslq -0x114(%rbp),%rax
movq   $0x0,-0x1c0(%rbp,%rax,8)
lea    -0x1c0(%rbp),%rdi
call   1040 <execute@plt>
mov    %eax,-0x1c4(%rbp)
mov    -0x1c4(%rbp),%eax
add    $0x1d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tokenizeInput>:
push   %r14
push   %rbx
sub    $0x1b8,%rsp
mov    %rdi,%rsi
lea    0xb0(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xe9c(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strtok@plt>
test   %rax,%rax
je     11a3 <tokenizeInput+0x63>
xor    %ebx,%ebx
lea    0xe86(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %rax,%rdi
call   1050 <makestring@plt>
mov    %rax,(%rsp,%rbx,8)
add    $0x1,%rbx
xor    %edi,%edi
mov    %r14,%rsi
call   1060 <strtok@plt>
test   %rax,%rax
jne    1180 <tokenizeInput+0x40>
mov    %ebx,%eax
jmp    11a5 <tokenizeInput+0x65>
xor    %eax,%eax
movq   $0x0,(%rsp,%rax,8)
mov    %rsp,%rdi
call   1040 <execute@plt>
add    $0x1b8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define i32 @tokenizeInput(i8* %0) {
%2 = alloca [255 x i8]
%3 = alloca [21 x i8*]
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* %0)
%6 = bitcast [21 x i8*]* %3 to i8*
%7 = call i8* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %19, label %9
9: ; preds = %1, %9
%10 = phi i64 [ %13, %9 ], [ 0, %1 ]
%11 = phi i8* [ %15, %9 ], [ %7, %1 ]
%12 = call i8* @makestring(i8* %11)
%13 = add nuw i64 %10, 1
%14 = getelementptr inbounds [21 x i8*], [21 x i8*]* %3, i64 0, i64 %10
store i8* %12, i8** %14
%15 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %9
17: ; preds = %9
%18 = and i64 %13, 4294967295
br label %19
19: ; preds = %17, %1
%20 = phi i64 [ 0, %1 ], [ %18, %17 ]
%21 = getelementptr inbounds [21 x i8*], [21 x i8*]* %3, i64 0, i64 %20
store i8* null, i8** %21
%22 = getelementptr inbounds [21 x i8*], [21 x i8*]* %3, i64 0, i64 0
%23 = call i32 @execute(i8** %22)
ret i32 %23
}