#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 */
size_t i;
char *malloc(scalar_t__);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *strsep(char **, char *);
char **tokenize_input(char *str, char *arr[]) {
  char *str_, *new_string, *cmd, *token;
  int j;
  str_ = " ";
  while ((token = strsep(&str, str_)) != NULL) {
    static i;
    arr[i] = malloc(strlen(token) + 1);
    strcpy(arr[i], token);
    i++;
  }
}


x86 assembly (clang, -O0):
<tokenize_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xea9(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    -0x10(%rbp),%rdi
call   1060 <strsep@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
je     11c9 <tokenize_input+0x89>
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq 0x2eaf(%rip),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq 0x2ea0(%rip),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x38(%rbp),%rsi
call   1030 <strcpy@plt>
mov    0x2e8d(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e84(%rip)
jmp    115b <tokenize_input+0x1b>
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tokenize_input>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,(%rsp)
lea    0xeaa(%rip),%rsi
mov    %rsp,%rdi
call   1060 <strsep@plt>
test   %rax,%rax
je     11b1 <tokenize_input+0x71>
mov    %rax,%rbx
lea    0xe93(%rip),%r14
mov    %rsp,%r15
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
call   1050 <malloc@plt>
movslq 0x2ec0(%rip),%rcx
mov    %rax,(%r12,%rcx,8)
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
addl   $0x1,0x2eaa(%rip)
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <strsep@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1170 <tokenize_input+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@tokenize_input.i = internal unnamed_addr global i32 0
@i = global i64 0
define noalias i8** @tokenize_input(i8* %0, i8** nocapture %1) {
%3 = alloca i8*
store i8* %0, i8** %3
%4 = call i8* @strsep(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %19, label %6
6: ; preds = %2, %6
%7 = phi i8* [ %17, %6 ], [ %4, %2 ]
%8 = call i64 @strlen(i8* %7)
%9 = add nsw i64 %8, 1
%10 = call i8* @malloc(i64 %9)
%11 = load i32, i32* @tokenize_input.i
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
store i8* %10, i8** %13
%14 = call i32 @strcpy(i8* %10, i8* %7)
%15 = load i32, i32* @tokenize_input.i
%16 = add nsw i32 %15, 1
store i32 %16, i32* @tokenize_input.i
%17 = call i8* @strsep(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %6
19: ; preds = %6, %2
ret i8** undef
}