#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 */
typedef int /*<<< orphan*/ cmdTokens;

/* Variables and functions */
int strlen(char *);
char *strtok(char *, char *);
void readCmdTokens(char *cmd, char **cmdTokens) {
  cmd[strlen(cmd) - 1] = '\0';
  int i = 0;
  cmdTokens[i] = strtok(cmd, " ");
  while (cmdTokens[i++] && i < sizeof(cmdTokens)) {
    cmdTokens[i] = strtok(NULL, " ");
  }
}


x86 assembly (clang, -O0):
<readCmdTokens>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %eax,%rdx
xor    %eax,%eax
cmpq   $0x0,(%rcx,%rdx,8)
mov    %al,-0x21(%rbp)
je     11a7 <readCmdTokens+0x87>
movslq -0x14(%rbp),%rax
cmp    $0x8,%rax
setb   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11b7 <readCmdTokens+0x97>
jmp    11db <readCmdTokens+0xbb>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe3e(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    1177 <readCmdTokens+0x57>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readCmdTokens>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
lea    0xec1(%rip),%rsi
mov    %r14,%rdi
call   1040 <strtok@plt>
mov    %rax,(%r15)
test   %rax,%rax
je     1180 <readCmdTokens+0x60>
mov    $0x1,%ebx
lea    0xea5(%rip),%r14
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %r14,%rsi
call   1040 <strtok@plt>
mov    %rax,(%r15,%rbx,8)
test   %rax,%rax
je     1180 <readCmdTokens+0x60>
lea    0x1(%rbx),%rax
cmp    $0x7,%rbx
mov    %rax,%rbx
jb     1160 <readCmdTokens+0x40>
pop    %rbx
pop    %r14
pop    %r15
ret

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

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