#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 split(char *str, const char *delim, char *outlist[]) {
  char *token;
  int count = 0;
  token = strtok(str, delim);
  while (token != NULL && count < (100)) {
    outlist[count++] = token;
    token = strtok(NULL, delim);
  }
  return count;
}


x86 assembly (clang, -O0):
<split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x25(%rbp)
je     1156 <split+0x46>
cmpl   $0x64,-0x24(%rbp)
setl   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    1166 <split+0x56>
jmp    1196 <split+0x86>
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x24(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1030 <strtok@plt>
mov    %rax,-0x20(%rbp)
jmp    113c <split+0x2c>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
call   1030 <strtok@plt>
test   %rax,%rax
je     1152 <split+0x42>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
lea    0x1(%rbx),%r12
mov    %rax,(%r14,%rbx,8)
xor    %edi,%edi
mov    %r15,%rsi
call   1030 <strtok@plt>
test   %rax,%rax
je     1155 <split+0x45>
cmp    $0x63,%rbx
mov    %r12,%rbx
jb     1130 <split+0x20>
jmp    1155 <split+0x45>
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @split(i8* %0, i8* nocapture %1, i8** nocapture writeonly %2) {
%4 = tail call i8* @strtok(i8* %0, i8* %1)
%5 = icmp eq i8* %4, null
br i1 %5, label %17, label %6
6: ; preds = %3, %6
%7 = phi i64 [ %9, %6 ], [ 0, %3 ]
%8 = phi i8* [ %11, %6 ], [ %4, %3 ]
%9 = add nuw nsw i64 %7, 1
%10 = getelementptr inbounds i8*, i8** %2, i64 %7
store i8* %8, i8** %10
%11 = tail call i8* @strtok(i8* null, i8* %1)
%12 = icmp ne i8* %11, null
%13 = icmp ult i64 %7, 99
%14 = select i1 %12, i1 %13, i1 false
br i1 %14, label %6, label %15
15: ; preds = %6
%16 = trunc i64 %9 to i32
br label %17
17: ; preds = %15, %3
%18 = phi i32 [ 0, %3 ], [ %16, %15 ]
ret i32 %18
}