#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 *);
void tokenize(char *str, char *tokens[], char *spliter) {
  int i;
  char *token = strtok(str, spliter);
  for (i = 0; token != NULL; i++) {
    tokens[i] = token;
    token = strtok(NULL, spliter);
  }
  tokens[i] = NULL;
}


x86 assembly (clang, -O0):
<tokenize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1176 <tokenize+0x66>
mov    -0x28(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1030 <strtok@plt>
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113c <tokenize+0x2c>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tokenize>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdx,%rsi
call   1030 <strtok@plt>
test   %rax,%rax
je     114b <tokenize+0x3b>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %rax,(%r14,%rbx,8)
xor    %edi,%edi
mov    %r15,%rsi
call   1030 <strtok@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1130 <tokenize+0x20>
mov    %ebx,%eax
jmp    114d <tokenize+0x3d>
xor    %eax,%eax
movq   $0x0,(%r14,%rax,8)
pop    %rbx
pop    %r14
pop    %r15
ret

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

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