#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 enStrTok(char *, char ***, char *);
int /*<<< orphan*/ free(char **);
int /*<<< orphan*/ printf(char *, int, ...);
int main(int argc, char *argv[]) {
  int num = 0;
  int count = 0;
  char *delim = ",";
  char **strArray = NULL;
  char test[50] = "play,1,1,";
  num = enStrTok(test, &strArray, delim);
  printf("number = %d\n", num);
  for (count = 0; count < num; count++)
    printf("array string[%d] = %s\n", count, strArray[count]);
  free(strArray);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe95(%rip),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xeae(%rip),%rsi
mov    $0x32,%edx
call   1050 <memcpy@plt>
lea    -0x60(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rsi
call   1060 <enStrTok@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ef <main+0xaf>
mov    -0x18(%rbp),%esi
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11b8 <main+0x78>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
movq   $0x0,0x8(%rsp)
movaps 0xf07(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeeb(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xecf(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movw   $0x0,0x40(%rsp)
lea    0xe8c(%rip),%rdx
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1050 <enStrTok@plt>
mov    %eax,%ebx
lea    0xe76(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
jle    11ce <main+0x9e>
mov    %ebx,%r15d
lea    0xe6c(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x8(%rsp),%rax
mov    (%rax,%rbx,8),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11b0 <main+0x80>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c",\00"
@__const.main.test = [50 x i8] c"play,1,1,\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.1 = [13 x i8] c"number = %d\0A\00"
@.str.2 = [23 x i8] c"array string[%d] = %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8**
%10 = alloca [50 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %8
store i8** null, i8*** %9
%11 = bitcast [50 x i8]* %10 to i8*
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
%13 = load i8*, i8** %8
%14 = call i32 @enStrTok(i8* %12, i8*** %9, i8* %13)
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %15)
store i32 0, i32* %7
br label %17
17: ; preds = %29, %2
%18 = load i32, i32* %7
%19 = load i32, i32* %6
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %32
21: ; preds = %17
%22 = load i32, i32* %7
%23 = load i8**, i8*** %9
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %22, i8* %27)
br label %29
29: ; preds = %21
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %17
32: ; preds = %17
%33 = load i8**, i8*** %9
%34 = call i32 @free(i8** %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
@__const.main.test = [50 x i8] c"play,1,1,\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.1 = [13 x i8] c"number = %d\0A\00"
@.str.2 = [23 x i8] c"array string[%d] = %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8**
%4 = alloca [50 x i8]
%5 = bitcast i8*** %3 to i8*
store i8** null, i8*** %3
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%7 = call i32 @enStrTok(i8* %6, i8*** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = icmp sgt i32 %7, 0
br i1 %9, label %10, label %21
10: ; preds = %2
%11 = zext i32 %7 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %19, %12 ]
%14 = load i8**, i8*** %3
%15 = getelementptr inbounds i8*, i8** %14, i64 %13
%16 = load i8*, i8** %15
%17 = trunc i64 %13 to i32
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %17, i8* %16)
%19 = add nuw nsw i64 %13, 1
%20 = icmp eq i64 %19, %11
br i1 %20, label %21, label %12
21: ; preds = %12, %2
%22 = load i8**, i8*** %3
%23 = call i32 @free(i8** %22)
ret i32 0
}