#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 **calloc(size_t, int);
char **realloc(char **, size_t);
char *strtok(char *, char *);
char **tokenize(char *line, size_t *ntok) {
  size_t alloc = 16;
  char **buf = calloc(alloc, sizeof(char *));
  buf[0] = strtok(line, " \n\t\v\f");
  *ntok = 0;
  while (buf[*ntok] != NULL) {
    *ntok += 1;
    if (*ntok >= alloc) {
      alloc *= 2;
      buf = realloc(buf, alloc * sizeof(char *));
    }
    buf[*ntok] = strtok(NULL, " \n\t\v\f");
  }
  return buf;
}


x86 assembly (clang, -O0):
<tokenize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x10,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11fc <tokenize+0xcc>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmp    -0x18(%rbp),%rax
jb     11d5 <tokenize+0xa5>
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
shl    $0x3,%rsi
call   1040 <realloc@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe20(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    117f <tokenize+0x4f>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tokenize>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
mov    $0x10,%ebx
mov    $0x10,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%r15
lea    0xea3(%rip),%rsi
mov    %r12,%rdi
call   1050 <strtok@plt>
mov    %rax,(%r15)
movq   $0x0,(%r14)
test   %rax,%rax
je     11bd <tokenize+0x8d>
xor    %ecx,%ecx
lea    0xe83(%rip),%r12
jmp    1196 <tokenize+0x66>
nop
xor    %edi,%edi
mov    %r12,%rsi
call   1050 <strtok@plt>
mov    (%r14),%rcx
mov    %rax,(%r15,%rcx,8)
test   %rax,%rax
je     11bd <tokenize+0x8d>
add    $0x1,%rcx
mov    %rcx,(%r14)
cmp    %rbx,%rcx
jb     1180 <tokenize+0x50>
lea    (%rbx,%rbx,1),%r13
shl    $0x4,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <realloc@plt>
mov    %rax,%r15
mov    %r13,%rbx
jmp    1180 <tokenize+0x50>
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c" \0A\09\0B\0C\00"
define i8** @tokenize(i8* %0, i64* %1) {
%3 = alloca i8*
%4 = alloca i64*
%5 = alloca i64
%6 = alloca i8**
store i8* %0, i8** %3
store i64* %1, i64** %4
store i64 16, i64* %5
%7 = load i64, i64* %5
%8 = call i8** @calloc(i64 %7, i32 8)
store i8** %8, i8*** %6
%9 = load i8*, i8** %3
%10 = call i8* @strtok(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%11 = load i8**, i8*** %6
%12 = getelementptr inbounds i8*, i8** %11, i64 0
store i8* %10, i8** %12
%13 = load i64*, i64** %4
store i64 0, i64* %13
br label %14
14: ; preds = %36, %2
%15 = load i8**, i8*** %6
%16 = load i64*, i64** %4
%17 = load i64, i64* %16
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %42
21: ; preds = %14
%22 = load i64*, i64** %4
%23 = load i64, i64* %22
%24 = add i64 %23, 1
store i64 %24, i64* %22
%25 = load i64*, i64** %4
%26 = load i64, i64* %25
%27 = load i64, i64* %5
%28 = icmp uge i64 %26, %27
br i1 %28, label %29, label %36
29: ; preds = %21
%30 = load i64, i64* %5
%31 = mul i64 %30, 2
store i64 %31, i64* %5
%32 = load i8**, i8*** %6
%33 = load i64, i64* %5
%34 = mul i64 %33, 8
%35 = call i8** @realloc(i8** %32, i64 %34)
store i8** %35, i8*** %6
br label %36
36: ; preds = %29, %21
%37 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%38 = load i8**, i8*** %6
%39 = load i64*, i64** %4
%40 = load i64, i64* %39
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
store i8* %37, i8** %41
br label %14
42: ; preds = %14
%43 = load i8**, i8*** %6
ret i8** %43
}

LLVM IR (-O2):
@.str = [6 x i8] c" \0A\09\0B\0C\00"
define i8** @tokenize(i8* %0, i64* nocapture %1) {
%3 = tail call i8** @calloc(i64 16, i32 8)
%4 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %3
store i64 0, i64* %1
%5 = icmp eq i8* %4, null
br i1 %5, label %23, label %6
6: ; preds = %2, %16
%7 = phi i64 [ %20, %16 ], [ 0, %2 ]
%8 = phi i8** [ %18, %16 ], [ %3, %2 ]
%9 = phi i64 [ %17, %16 ], [ 16, %2 ]
%10 = add i64 %7, 1
store i64 %10, i64* %1
%11 = icmp ult i64 %10, %9
br i1 %11, label %16, label %12
12: ; preds = %6
%13 = shl i64 %9, 1
%14 = shl i64 %9, 4
%15 = tail call i8** @realloc(i8** %8, i64 %14)
br label %16
16: ; preds = %12, %6
%17 = phi i64 [ %13, %12 ], [ %9, %6 ]
%18 = phi i8** [ %15, %12 ], [ %8, %6 ]
%19 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%20 = load i64, i64* %1
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
store i8* %19, i8** %21
%22 = icmp eq i8* %19, null
br i1 %22, label %23, label %6
23: ; preds = %16, %2
%24 = phi i8** [ %3, %2 ], [ %18, %16 ]
ret i8** %24
}