#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 */
char **calloc(int, int);
int /*<<< orphan*/ free(char **);
int parse_token_input(char **);
char *strtok(char *, char *);
int parse_raw_input(char *input) {
  char **token_input = calloc(100, sizeof(char *));
  char *tok = strtok(input, " ");
  int j = 0;
  while (tok) {
    token_input[j++] = tok;
    tok = strtok(0, " ");
  }
  int return_val = parse_token_input(token_input);
  free(token_input);
  return return_val;
}


x86 assembly (clang, -O0):
<parse_raw_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x64,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11b8 <parse_raw_input+0x78>
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x1c(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe56(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x18(%rbp)
jmp    117a <parse_raw_input+0x3a>
mov    -0x10(%rbp),%rdi
call   1040 <parse_token_input@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_raw_input>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    $0x64,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%r14
lea    0xe9f(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strtok@plt>
test   %rax,%rax
je     1196 <parse_raw_input+0x56>
lea    0xe8b(%rip),%r15
mov    %r14,%rbx
nopl   0x0(%rax,%rax,1)
mov    %rax,(%rbx)
xor    %edi,%edi
mov    %r15,%rsi
call   1060 <strtok@plt>
add    $0x8,%rbx
test   %rax,%rax
jne    1180 <parse_raw_input+0x40>
mov    %r14,%rdi
call   1040 <parse_token_input@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define i32 @parse_raw_input(i8* %0) {
%2 = alloca i8*
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = call i8** @calloc(i32 100, i32 8)
store i8** %7, i8*** %3
%8 = load i8*, i8** %2
%9 = call i8* @strtok(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %4
store i32 0, i32* %5
br label %10
10: ; preds = %13, %1
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %21
13: ; preds = %10
%14 = load i8*, i8** %4
%15 = load i8**, i8*** %3
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
store i32 %17, i32* %5
%18 = sext i32 %16 to i64
%19 = getelementptr inbounds i8*, i8** %15, i64 %18
store i8* %14, i8** %19
%20 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %20, i8** %4
br label %10
21: ; preds = %10
%22 = load i8**, i8*** %3
%23 = call i32 @parse_token_input(i8** %22)
store i32 %23, i32* %6
%24 = load i8**, i8*** %3
%25 = call i32 @free(i8** %24)
%26 = load i32, i32* %6
ret i32 %26
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define i32 @parse_raw_input(i8* %0) {
%2 = tail call i8** @calloc(i32 100, i32 8)
%3 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %12, label %5
5: ; preds = %1, %5
%6 = phi i64 [ %8, %5 ], [ 0, %1 ]
%7 = phi i8* [ %10, %5 ], [ %3, %1 ]
%8 = add nuw i64 %6, 1
%9 = getelementptr inbounds i8*, i8** %2, i64 %6
store i8* %7, i8** %9
%10 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %5
12: ; preds = %5, %1
%13 = tail call i32 @parse_token_input(i8** %2)
%14 = tail call i32 @free(i8** %2)
ret i32 %13
}