#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 *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    $0x50,%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,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     1174 <tokenize+0x64>
mov    -0x48(%rbp),%rcx
mov    -0x4c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x4c(%rbp)
cltq
mov    %rcx,-0x40(%rbp,%rax,8)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe9a(%rip),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x48(%rbp)
jmp    113a <tokenize+0x2a>
movslq -0x4c(%rbp),%rax
movq   $0x0,-0x40(%rbp,%rax,8)
lea    -0x40(%rbp),%rax
add    $0x50,%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 i32
store i8* %0, i8** %3
store i8 %1, i8* %4
%8 = load i8*, i8** %3
%9 = call i8* @strtok(i8* %8, i8* %4)
store i8* %9, i8** %6
store i32 0, i32* %7
br label %10
10: ; preds = %13, %2
%11 = load i8*, i8** %6
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i8*, i8** %6
%15 = load i32, i32* %7
%16 = add nsw i32 %15, 1
store i32 %16, i32* %7
%17 = sext i32 %15 to i64
%18 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 %17
store i8* %14, i8** %18
%19 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %19, i8** %6
br label %10
20: ; preds = %10
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 %22
store i8* null, i8** %23
%24 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 0
ret i8** %24
}

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
}