#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strtok(char *, char *);
char **SaveTokenString(char *string, char *delimeters) {
  int NDEX;
  static char *token[500], *TOKEN;
  NDEX = 0;
  TOKEN = strtok(string, delimeters);
  if (TOKEN == NULL)
    return NULL;
  token[NDEX] = (char *)malloc(sizeof(char) * (strlen(TOKEN) + 1));
  strcpy(token[NDEX], TOKEN);
  while (token[NDEX] != NULL) {
    NDEX++;
    TOKEN = strtok(NULL, delimeters);
    if (TOKEN != NULL) {
      token[NDEX] = (char *)malloc(sizeof(char) * (strlen(TOKEN) + 1));
      strcpy(token[NDEX], TOKEN);
    } else
      token[NDEX] = TOKEN;
  }
  return token;
}


x86 assembly (clang, -O0):
<SaveTokenString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strtok@plt>
mov    %rax,0x3e85(%rip)
cmpq   $0x0,0x3e7d(%rip)
jne    1186 <SaveTokenString+0x46>
movq   $0x0,-0x8(%rbp)
jmp    1284 <SaveTokenString+0x144>
mov    0x3e63(%rip),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
movslq -0x1c(%rbp),%rcx
lea    0x2ea0(%rip),%rax
mov    %rdx,(%rax,%rcx,8)
movslq -0x1c(%rbp),%rcx
lea    0x2e91(%rip),%rax
mov    (%rax,%rcx,8),%rdi
mov    0x3e26(%rip),%rsi
call   1030 <strcpy@plt>
movslq -0x1c(%rbp),%rcx
lea    0x2e76(%rip),%rax
cmpq   $0x0,(%rax,%rcx,8)
je     1279 <SaveTokenString+0x139>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1060 <strtok@plt>
mov    %rax,0x3dee(%rip)
cmpq   $0x0,0x3de6(%rip)
je     125e <SaveTokenString+0x11e>
mov    0x3dd9(%rip),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
movslq -0x1c(%rbp),%rcx
lea    0x2e16(%rip),%rax
mov    %rdx,(%rax,%rcx,8)
movslq -0x1c(%rbp),%rcx
lea    0x2e07(%rip),%rax
mov    (%rax,%rcx,8),%rdi
mov    0x3d9c(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1274 <SaveTokenString+0x134>
mov    0x3d8b(%rip),%rdx
movslq -0x1c(%rbp),%rcx
lea    0x2de0(%rip),%rax
mov    %rdx,(%rax,%rcx,8)
jmp    11cf <SaveTokenString+0x8f>
lea    0x2dd0(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SaveTokenString>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
call   1060 <strtok@plt>
mov    %rax,0x3e9c(%rip)
test   %rax,%rax
je     11e4 <SaveTokenString+0xa4>
mov    %rax,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edi
call   1050 <malloc@plt>
mov    %rax,0x2edc(%rip)
lea    0x2ed5(%rip),%r14
mov    0x3e6e(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
cmpq   $0x0,0x2ebe(%rip)
je     11f0 <SaveTokenString+0xb0>
lea    0x2ebd(%rip),%rbx
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %r15,%rsi
call   1060 <strtok@plt>
mov    %rax,0x3e3f(%rip)
test   %rax,%rax
je     11e9 <SaveTokenString+0xa9>
mov    %rax,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edi
call   1050 <malloc@plt>
mov    %rax,(%rbx)
mov    0x3e20(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
cmpq   $0x0,(%rbx)
lea    0x8(%rbx),%rbx
jne    11a0 <SaveTokenString+0x60>
jmp    11f0 <SaveTokenString+0xb0>
xor    %r14d,%r14d
jmp    11f0 <SaveTokenString+0xb0>
movq   $0x0,(%rbx)
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SaveTokenString.token = internal global [500 x i8*] zeroinitializer
@SaveTokenString.TOKEN = internal global i8* null
define i8** @SaveTokenString(i8* %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
%7 = load i8*, i8** %4
%8 = load i8*, i8** %5
%9 = call i8* @strtok(i8* %7, i8* %8)
store i8* %9, i8** @SaveTokenString.TOKEN
%10 = load i8*, i8** @SaveTokenString.TOKEN
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %13
12: ; preds = %2
store i8** null, i8*** %3
br label %69
13: ; preds = %2
%14 = load i8*, i8** @SaveTokenString.TOKEN
%15 = call i32 @strlen(i8* %14)
%16 = add nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = mul i64 1, %17
%19 = trunc i64 %18 to i32
%20 = call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to i8*
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [500 x i8*], [500 x i8*]* @SaveTokenString.token, i64 0, i64 %23
store i8* %21, i8** %24
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [500 x i8*], [500 x i8*]* @SaveTokenString.token, i64 0, i64 %26
%28 = load i8*, i8** %27
%29 = load i8*, i8** @SaveTokenString.TOKEN
%30 = call i32 @strcpy(i8* %28, i8* %29)
br label %31
31: ; preds = %67, %13
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [500 x i8*], [500 x i8*]* @SaveTokenString.token, i64 0, i64 %33
%35 = load i8*, i8** %34
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %68
37: ; preds = %31
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
%40 = load i8*, i8** %5
%41 = call i8* @strtok(i8* null, i8* %40)
store i8* %41, i8** @SaveTokenString.TOKEN
%42 = load i8*, i8** @SaveTokenString.TOKEN
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %62
44: ; preds = %37
%45 = load i8*, i8** @SaveTokenString.TOKEN
%46 = call i32 @strlen(i8* %45)
%47 = add nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = mul i64 1, %48
%50 = trunc i64 %49 to i32
%51 = call i64 @malloc(i32 %50)
%52 = inttoptr i64 %51 to i8*
%53 = load i32, i32* %6
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [500 x i8*], [500 x i8*]* @SaveTokenString.token, i64 0, i64 %54
store i8* %52, i8** %55
%56 = load i32, i32* %6
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [500 x i8*], [500 x i8*]* @SaveTokenString.token, i64 0, i64 %57
%59 = load i8*, i8** %58
%60 = load i8*, i8** @SaveTokenString.TOKEN
%61 = call i32 @strcpy(i8* %59, i8* %60)
br label %67
62: ; preds = %37
%63 = load i8*, i8** @SaveTokenString.TOKEN
%64 = load i32, i32* %6
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [500 x i8*], [500 x i8*]* @SaveTokenString.token, i64 0, i64 %65
store i8* %63, i8** %66
br label %67
67: ; preds = %62, %44
br label %31
68: ; preds = %31
store i8** getelementptr inbounds ([500 x i8*], [500 x i8*]* @SaveTokenString.token, i64 0, i64 0), i8*** %3
br label %69
69: ; preds = %68, %12
%70 = load i8**, i8*** %3
ret i8** %70
}

LLVM IR (-O2):
@SaveTokenString.token = internal global [500 x i8*] zeroinitializer
@SaveTokenString.TOKEN = internal unnamed_addr global i8* null
define i8** @SaveTokenString(i8* %0, i8* nocapture %1) {
%3 = tail call i8* @strtok(i8* %0, i8* %1)
store i8* %3, i8** @SaveTokenString.TOKEN
%4 = icmp eq i8* %3, null
br i1 %4, label %31, label %5
5: ; preds = %2
%6 = tail call i32 @strlen(i8* %3)
%7 = add nsw i32 %6, 1
%8 = tail call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** getelementptr inbounds ([500 x i8*], [500 x i8*]* @SaveTokenString.token, i64 0, i64 0)
%10 = load i8*, i8** @SaveTokenString.TOKEN
%11 = tail call i32 @strcpy(i8* %9, i8* %10)
%12 = load i8*, i8** getelementptr inbounds ([500 x i8*], [500 x i8*]* @SaveTokenString.token, i64 0, i64 0)
%13 = icmp eq i8* %12, null
br i1 %13, label %31, label %14
14: ; preds = %5, %21
%15 = phi i64 [ %16, %21 ], [ 0, %5 ]
%16 = add nuw i64 %15, 1
%17 = tail call i8* @strtok(i8* null, i8* %1)
store i8* %17, i8** @SaveTokenString.TOKEN
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = getelementptr inbounds [500 x i8*], [500 x i8*]* @SaveTokenString.token, i64 0, i64 %16
store i8* null, i8** %20
br label %31
21: ; preds = %14
%22 = tail call i32 @strlen(i8* %17)
%23 = add nsw i32 %22, 1
%24 = tail call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to i8*
%26 = getelementptr inbounds [500 x i8*], [500 x i8*]* @SaveTokenString.token, i64 0, i64 %16
store i8* %25, i8** %26
%27 = load i8*, i8** @SaveTokenString.TOKEN
%28 = tail call i32 @strcpy(i8* %25, i8* %27)
%29 = load i8*, i8** %26
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %14
31: ; preds = %21, %19, %5, %2
%32 = phi i8** [ null, %2 ], [ getelementptr inbounds ([500 x i8*], [500 x i8*]* @SaveTokenString.token, i64 0, i64 0), %5 ], [ getelementptr inbounds ([500 x i8*], [500 x i8*]* @SaveTokenString.token, i64 0, i64 0), %19 ], [ getelementptr inbounds ([500 x i8*], [500 x i8*]* @SaveTokenString.token, i64 0, i64 0), %21 ]
ret i8** %32
}