#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_r(char *, char *, char **);
void tokenize(char *s, char *argv[]) {
  char *saveptr;
  size_t i = 0;
  argv[i++] = strtok_r(s, " ", &saveptr);
  while (argv[i - 1]) {
    argv[i++] = strtok_r(NULL, " ", &saveptr);
  }
}


x86 assembly (clang, -O0):
<tokenize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xecd(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <strtok_r@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x20(%rbp)
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11a0 <tokenize+0x90>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe88(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <strtok_r@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x20(%rbp)
mov    %rdx,(%rax,%rcx,8)
jmp    1156 <tokenize+0x46>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tokenize>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
lea    0xedd(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1030 <strtok_r@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     1169 <tokenize+0x59>
add    $0x8,%rbx
lea    0xec0(%rip),%r14
lea    0x8(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nop
xor    %edi,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <strtok_r@plt>
mov    %rax,(%rbx)
add    $0x8,%rbx
test   %rax,%rax
jne    1150 <tokenize+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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