#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 strlen(char *);
char *strtok(char *, char *);
void parseInput(char *input) {
  extern char *args[];
  char *word;
  int i;
  word = strtok(input, " ");
  while (word != NULL) {
    args[i] = word;
    word = strtok(NULL, " ");
    i++;
  }
  if (args[1] == NULL)
    args[0][strlen(args[0]) - 1] = '\0';
}


x86 assembly (clang, -O0):
<parseInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1180 <parseInput+0x60>
mov    -0x10(%rbp),%rdx
movslq -0x14(%rbp),%rcx
mov    0x2e86(%rip),%rax
mov    %rdx,(%rax,%rcx,8)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe97(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1140 <parseInput+0x20>
mov    0x2e59(%rip),%rax
cmpq   $0x0,0x8(%rax)
jne    11bf <parseInput+0x9f>
mov    0x2e47(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e39(%rip),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseInput>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     1166 <parseInput+0x46>
mov    0x2ea4(%rip),%rbx
lea    0xebd(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rax,(%rbx)
xor    %edi,%edi
mov    %r14,%rsi
call   1040 <strtok@plt>
add    $0x8,%rbx
test   %rax,%rax
jne    1150 <parseInput+0x30>
mov    0x2e73(%rip),%rax
cmpq   $0x0,0x8(%rax)
jne    1186 <parseInput+0x66>
mov    (%rax),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@args = external global [0 x i8*]
define void @parseInput(i8* %0) {
%2 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %11, label %4
4: ; preds = %1, %4
%5 = phi i64 [ %9, %4 ], [ 0, %1 ]
%6 = phi i8* [ %8, %4 ], [ %2, %1 ]
%7 = getelementptr inbounds [0 x i8*], [0 x i8*]* @args, i64 0, i64 %5
store i8* %6, i8** %7
%8 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = add i64 %5, 1
%10 = icmp eq i8* %8, null
br i1 %10, label %11, label %4
11: ; preds = %4, %1
%12 = load i8*, i8** getelementptr inbounds ([0 x i8*], [0 x i8*]* @args, i64 0, i64 1)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = load i8*, i8** getelementptr inbounds ([0 x i8*], [0 x i8*]* @args, i64 0, i64 0)
%16 = tail call i32 @strlen(i8* %15)
%17 = add nsw i32 %16, -1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %15, i64 %18
store i8 0, i8* %19
br label %20
20: ; preds = %14, %11
ret void
}