#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 *strtok(char *, char const *);
char **tokenize(char *word, const char ch) {
  char *result[5];
  char **tmp;
  char *token = strtok(word, &ch);
  int count = 0;
  while (token) {
    result[count++] = token;
    token = strtok(NULL, " ");
  }
  result[count] = NULL;
  return result;
}


x86 assembly (clang, -O0):
<tokenize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x9(%rbp),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1174 <tokenize+0x64>
mov    -0x50(%rbp),%rcx
mov    -0x54(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x54(%rbp)
cltq
mov    %rcx,-0x40(%rbp,%rax,8)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe9a(%rip),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x50(%rbp)
jmp    113a <tokenize+0x2a>
movslq -0x54(%rbp),%rax
movq   $0x0,-0x40(%rbp,%rax,8)
lea    -0x40(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tokenize>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %sil,0xf(%rsp)
lea    0xf(%rsp),%rsi
call   1030 <strtok@plt>
test   %rax,%rax
je     1156 <tokenize+0x46>
lea    0x10(%rsp),%rbx
lea    0xec9(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %rax,(%rbx)
xor    %edi,%edi
mov    %r14,%rsi
call   1030 <strtok@plt>
add    $0x8,%rbx
test   %rax,%rax
jne    1140 <tokenize+0x30>
lea    0x10(%rsp),%rax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

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

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