#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 */
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ malloc_strcpy(char **, char const *);
char const *strtok(char *, char const *);
void tokenize(char **strs, int *no_strs, char const *input, char const *delim) {
  char *s;
  int i;
  malloc_strcpy(&s, input);
  malloc_strcpy(&strs[i = 0], strtok(s, delim));
  while (strs[i] != NULL) {
    malloc_strcpy(&strs[++i], strtok(NULL, delim));
  }
  *no_strs = i;
  free(s);
}


x86 assembly (clang, -O0):
<tokenize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
lea    -0x28(%rbp),%rdi
call   1040 <malloc_strcpy@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strtok@plt>
mov    -0x38(%rbp),%rdi
mov    %rax,%rsi
call   1040 <malloc_strcpy@plt>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11c9 <tokenize+0x99>
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x2c(%rbp)
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1050 <strtok@plt>
mov    -0x40(%rbp),%rdi
mov    %rax,%rsi
call   1040 <malloc_strcpy@plt>
jmp    117d <tokenize+0x4d>
mov    -0x2c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tokenize>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
mov    %rsp,%rdi
mov    %rdx,%rsi
call   1040 <malloc_strcpy@plt>
mov    (%rsp),%rdi
mov    %r15,%rsi
call   1050 <strtok@plt>
mov    %r12,%rdi
mov    %rax,%rsi
call   1040 <malloc_strcpy@plt>
cmpq   $0x0,(%r12)
je     1196 <tokenize+0x66>
add    $0x8,%r12
xor    %ebx,%ebx
xor    %edi,%edi
mov    %r15,%rsi
call   1050 <strtok@plt>
mov    %r12,%rdi
mov    %rax,%rsi
call   1040 <malloc_strcpy@plt>
add    $0x1,%ebx
cmpq   $0x0,(%r12)
lea    0x8(%r12),%r12
jne    1170 <tokenize+0x40>
jmp    1198 <tokenize+0x68>
xor    %ebx,%ebx
mov    %ebx,(%r14)
mov    (%rsp),%rdi
call   1030 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @tokenize(i8** %0, i32* nocapture writeonly %1, i8* %2, i8* nocapture %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
%7 = call i32 @malloc_strcpy(i8** %5, i8* %2)
%8 = load i8*, i8** %5
%9 = call i8* @strtok(i8* %8, i8* %3)
%10 = call i32 @malloc_strcpy(i8** %0, i8* %9)
%11 = load i8*, i8** %0
%12 = icmp eq i8* %11, null
br i1 %12, label %23, label %13
13: ; preds = %4, %13
%14 = phi i64 [ %15, %13 ], [ 0, %4 ]
%15 = add nuw nsw i64 %14, 1
%16 = getelementptr inbounds i8*, i8** %0, i64 %15
%17 = call i8* @strtok(i8* null, i8* %3)
%18 = call i32 @malloc_strcpy(i8** %16, i8* %17)
%19 = load i8*, i8** %16
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %13
21: ; preds = %13
%22 = trunc i64 %15 to i32
br label %23
23: ; preds = %21, %4
%24 = phi i32 [ 0, %4 ], [ %22, %21 ]
store i32 %24, i32* %1
%25 = load i8*, i8** %5
%26 = call i32 @free(i8* %25)
ret void
}