#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 *mystrsep(char **, char *);
void strsplit(char *words[50], char *string, char *separator) {
  char *token;
  if (string != NULL) {
    int i = 0;
    while ((token = mystrsep(&string, separator)) != NULL) {
      words[i] = token;
      i++;
    }
  }
}


x86 assembly (clang, -O0):
<strsplit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1174 <strsplit+0x64>
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rsi
lea    -0x10(%rbp),%rdi
call   1030 <mystrsep@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     116f <strsplit+0x5f>
mov    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1136 <strsplit+0x26>
jmp    1174 <strsplit+0x64>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strsplit>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,0x8(%rsp)
test   %rsi,%rsi
je     1157 <strsplit+0x47>
mov    %rdx,%r14
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
mov    %rdx,%rsi
call   1030 <mystrsep@plt>
test   %rax,%rax
je     1157 <strsplit+0x47>
lea    0x8(%rsp),%r15
mov    %rax,(%rbx)
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <mystrsep@plt>
add    $0x8,%rbx
test   %rax,%rax
jne    1140 <strsplit+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @strsplit(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
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %25
11: ; preds = %3
store i32 0, i32* %8
br label %12
12: ; preds = %16, %11
%13 = load i8*, i8** %6
%14 = call i8* @mystrsep(i8** %5, i8* %13)
store i8* %14, i8** %7
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = load i8*, i8** %7
%18 = load i8**, i8*** %4
%19 = load i32, i32* %8
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
store i8* %17, i8** %21
%22 = load i32, i32* %8
%23 = add nsw i32 %22, 1
store i32 %23, i32* %8
br label %12
24: ; preds = %12
br label %25
25: ; preds = %24, %3
ret void
}

LLVM IR (-O2):
define void @strsplit(i8** nocapture writeonly %0, i8* %1, i8* %2) {
%4 = alloca i8*
store i8* %1, i8** %4
%5 = icmp eq i8* %1, null
br i1 %5, label %16, label %6
6: ; preds = %3
%7 = call i8* @mystrsep(i8** %4, i8* %2)
%8 = icmp eq i8* %7, null
br i1 %8, label %16, label %9
9: ; preds = %6, %9
%10 = phi i64 [ %13, %9 ], [ 0, %6 ]
%11 = phi i8* [ %14, %9 ], [ %7, %6 ]
%12 = getelementptr inbounds i8*, i8** %0, i64 %10
store i8* %11, i8** %12
%13 = add nuw i64 %10, 1
%14 = call i8* @mystrsep(i8** %4, i8* %2)
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %9
16: ; preds = %9, %6, %3
ret void
}