#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int stCountTokens(char *, char *);
int /*<<< orphan*/ stFreeTokens(char *, char *, char ***);
int stInvalidString(char *, char *);
int /*<<< orphan*/ stTokenize(char *, char *, char ***);
int main() {
  int i;
  char inputString[256];
  int count;
  char *delimiter = " ";
  char **tokenString = NULL;
  do {
    printf("%% ");
    gets(inputString);
  } while (stInvalidString(inputString, delimiter) == 1);
  count = stCountTokens(inputString, delimiter);
  stTokenize(inputString, delimiter, &tokenString);
  for (i = 0; i < count; i++)
    printf("tokenString[%d]: %s\n", i, tokenString[i]);
  stFreeTokens(inputString, delimiter, &tokenString);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe89(%rip),%rax
mov    %rax,-0x120(%rbp)
movq   $0x0,-0x128(%rbp)
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x110(%rbp),%rdi
call   1080 <gets@plt>
lea    -0x110(%rbp),%rdi
mov    -0x120(%rbp),%rsi
call   1060 <stInvalidString@plt>
cmp    $0x1,%eax
je     118b <main+0x2b>
lea    -0x110(%rbp),%rdi
mov    -0x120(%rbp),%rsi
call   1030 <stCountTokens@plt>
mov    %eax,-0x114(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x120(%rbp),%rsi
lea    -0x128(%rbp),%rdx
call   1070 <stTokenize@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x114(%rbp),%eax
jge    1238 <main+0xd8>
mov    -0x8(%rbp),%esi
mov    -0x128(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11fb <main+0x9b>
lea    -0x110(%rbp),%rdi
mov    -0x120(%rbp),%rsi
lea    -0x128(%rbp),%rdx
call   1050 <stFreeTokens@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x110,%rsp
movq   $0x0,0x8(%rsp)
lea    0xe84(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xe7a(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1080 <gets@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <stInvalidString@plt>
cmp    $0x1,%eax
je     1190 <main+0x30>
lea    0xe49(%rip),%r14
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <stCountTokens@plt>
mov    %eax,%ebx
lea    0x8(%rsp),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <stTokenize@plt>
test   %ebx,%ebx
jle    120e <main+0xae>
mov    %ebx,%r15d
lea    0xe1b(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
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    11f0 <main+0x90>
lea    0xded(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rdx
call   1050 <stFreeTokens@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [4 x i8] c"%% \00"
@.str.2 = [21 x i8] c"tokenString[%d]: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [256 x i8]
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
store i32 0, i32* %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %5
store i8** null, i8*** %6
br label %7
7: ; preds = %11, %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%10 = call i32 @gets(i8* %9)
br label %11
11: ; preds = %7
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%13 = load i8*, i8** %5
%14 = call i32 @stInvalidString(i8* %12, i8* %13)
%15 = icmp eq i32 %14, 1
br i1 %15, label %7, label %16
16: ; preds = %11
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%18 = load i8*, i8** %5
%19 = call i32 @stCountTokens(i8* %17, i8* %18)
store i32 %19, i32* %4
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%21 = load i8*, i8** %5
%22 = call i32 @stTokenize(i8* %20, i8* %21, i8*** %6)
store i32 0, i32* %2
br label %23
23: ; preds = %35, %16
%24 = load i32, i32* %2
%25 = load i32, i32* %4
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %38
27: ; preds = %23
%28 = load i32, i32* %2
%29 = load i8**, i8*** %6
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %28, i8* %33)
br label %35
35: ; preds = %27
%36 = load i32, i32* %2
%37 = add nsw i32 %36, 1
store i32 %37, i32* %2
br label %23
38: ; preds = %23
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%40 = load i8*, i8** %5
%41 = call i32 @stFreeTokens(i8* %39, i8* %40, i8*** %6)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [4 x i8] c"%% \00"
@.str.2 = [21 x i8] c"tokenString[%d]: %s\0A\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = alloca i8**
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%4 = bitcast i8*** %2 to i8*
store i8** null, i8*** %2
br label %5
5: ; preds = %5, %0
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @gets(i8* %3)
%8 = call i32 @stInvalidString(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %8, 1
br i1 %9, label %5, label %10
10: ; preds = %5
%11 = call i32 @stCountTokens(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @stTokenize(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8*** %2)
%13 = icmp sgt i32 %11, 0
br i1 %13, label %14, label %25
14: ; preds = %10
%15 = zext i32 %11 to i64
br label %16
16: ; preds = %14, %16
%17 = phi i64 [ 0, %14 ], [ %23, %16 ]
%18 = load i8**, i8*** %2
%19 = getelementptr inbounds i8*, i8** %18, i64 %17
%20 = load i8*, i8** %19
%21 = trunc i64 %17 to i32
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %21, i8* %20)
%23 = add nuw nsw i64 %17, 1
%24 = icmp eq i64 %23, %15
br i1 %24, label %25, label %16
25: ; preds = %16, %10
%26 = call i32 @stFreeTokens(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8*** %2)
ret i32 0
}