#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 createTokenArray(char *, char **);
int /*<<< orphan*/ getLine(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char str[100];
  char tokenArray[100 / 2][20];
  printf("Enter the line to tokenise > ");
  getLine(str, 100);
  int tokenArrayLength;
  tokenArrayLength = createTokenArray(str, tokenArray);
  int i;
  for (i = 0; i < tokenArrayLength; i++) {
    printf("%d: %s\n", i, tokenArray[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x470,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    $0x64,%esi
call   1050 <getLine@plt>
lea    -0x70(%rbp),%rdi
lea    -0x460(%rbp),%rsi
call   1040 <createTokenArray@plt>
mov    %eax,-0x464(%rbp)
movl   $0x0,-0x468(%rbp)
mov    -0x468(%rbp),%eax
cmp    -0x464(%rbp),%eax
jge    11cd <main+0x9d>
mov    -0x468(%rbp),%esi
movslq -0x468(%rbp),%rax
lea    -0x460(%rbp),%rdx
imul   $0x14,%rax,%rax
add    %rax,%rdx
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x468(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x468(%rbp)
jmp    117e <main+0x4e>
xor    %eax,%eax
add    $0x470,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x458,%rsp
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1050 <getLine@plt>
lea    0x70(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <createTokenArray@plt>
test   %eax,%eax
jle    119c <main+0x6c>
mov    %eax,%r12d
lea    0xea4(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r15,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
add    $0x14,%r15
cmp    %rbx,%r12
jne    1180 <main+0x50>
xor    %eax,%eax
add    $0x458,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Enter the line to tokenise > \00"
@.str.1 = [8 x i8] c"%d: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [50 x [20 x i8]]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%8 = call i32 @getLine(i8* %7, i32 100)
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%10 = getelementptr inbounds [50 x [20 x i8]], [50 x [20 x i8]]* %3, i64 0, i64 0
%11 = bitcast [20 x i8]* %10 to i8**
%12 = call i32 @createTokenArray(i8* %9, i8** %11)
store i32 %12, i32* %4
store i32 0, i32* %5
br label %13
13: ; preds = %24, %0
%14 = load i32, i32* %5
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %27
17: ; preds = %13
%18 = load i32, i32* %5
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [50 x [20 x i8]], [50 x [20 x i8]]* %3, i64 0, i64 %20
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %21, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %18, i8* %22)
br label %24
24: ; preds = %17
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %13
27: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [30 x i8] c"Enter the line to tokenise > \00"
@.str.1 = [8 x i8] c"%d: %s\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [50 x [20 x i8]]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [50 x [20 x i8]], [50 x [20 x i8]]* %2, i64 0, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @getLine(i8* %3, i32 100)
%7 = bitcast [50 x [20 x i8]]* %2 to i8**
%8 = call i32 @createTokenArray(i8* %3, i8** %7)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %0
%11 = zext i32 %8 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %17, %12 ]
%14 = getelementptr inbounds [50 x [20 x i8]], [50 x [20 x i8]]* %2, i64 0, i64 %13, i64 0
%15 = trunc i64 %13 to i32
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %15, i8* %14)
%17 = add nuw nsw i64 %13, 1
%18 = icmp eq i64 %17, %11
br i1 %18, label %19, label %12
19: ; preds = %12, %0
ret i32 0
}