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


x86 assembly (clang, -O0):
<tokenize2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x9(%rbp),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     117c <tokenize2+0x6c>
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x24(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe92(%rip),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x20(%rbp)
jmp    113e <tokenize2+0x2e>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tokenize2>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r15
mov    %sil,0xf(%rsp)
lea    0xf(%rsp),%rsi
call   1030 <strtok@plt>
test   %rax,%rax
je     115b <tokenize2+0x4b>
xor    %ebx,%ebx
lea    0xec7(%rip),%r14
nopl   0x0(%rax)
mov    %rax,(%r15,%rbx,8)
add    $0x1,%rbx
xor    %edi,%edi
mov    %r14,%rsi
call   1030 <strtok@plt>
test   %rax,%rax
jne    1140 <tokenize2+0x30>
mov    %ebx,%eax
jmp    115d <tokenize2+0x4d>
xor    %eax,%eax
movq   $0x0,(%r15,%rax,8)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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