#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 *);
int toten(char *argv, char **rs) {
  const char *delim = " \t\r\n";
  char *toten;
  toten = strtok(argv, delim);
  rs[0] = toten;
  int i = 1;
  while ((toten = strtok(NULL, delim)) != NULL) {
    rs[i] = toten;
    i++;
  }
  rs[i] = NULL;
  return 0;
}


x86 assembly (clang, -O0):
<toten>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xed9(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x24(%rbp)
mov    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1030 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1187 <toten+0x77>
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114e <toten+0x3e>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<toten>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
lea    0xee1(%rip),%r14
mov    %r14,%rsi
call   1030 <strtok@plt>
mov    %rax,(%r15)
xor    %edi,%edi
mov    %r14,%rsi
call   1030 <strtok@plt>
test   %rax,%rax
je     116b <toten+0x5b>
mov    $0x1,%ebx
lea    0xebb(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rax,(%r15,%rbx,8)
add    $0x1,%rbx
xor    %edi,%edi
mov    %r14,%rsi
call   1030 <strtok@plt>
test   %rax,%rax
jne    1150 <toten+0x40>
mov    %ebx,%eax
jmp    1170 <toten+0x60>
mov    $0x1,%eax
movq   $0x0,(%r15,%rax,8)
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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