#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*/ strcpy(char *, char *);
char *strtok(char *, char const *);
void splitStr(char *src, const char *sep, char *des[], int *total) {
  int i = 0;
  char *token = NULL;
  i = 0;
  token = strtok(src, sep);
  while (token != NULL) {
    strcpy(des[i], token);
    token = strtok(NULL, sep);
    i++;
  }
  *total = i;
}


x86 assembly (clang, -O0):
<splitStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     119e <splitStr+0x7e>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1040 <strtok@plt>
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115f <splitStr+0x3f>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<splitStr>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
call   1040 <strtok@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     115f <splitStr+0x3f>
nopl   (%rax)
mov    (%r15,%rbx,8),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   1040 <strtok@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1140 <splitStr+0x20>
mov    %ebx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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