#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*/ strcpy(char *, char *);
char *strtok(char *, char *);
int BreakApartInput(char *input, char cmd[256][64]) {
  int i, j;
  char *dl = " ", *token = strtok(input, dl);
  for (i = 0; i < 20; i++) {
    for (j = 0; j < 64; j++)
      cmd[i][j] = 0;
  }
  i = 0;
  while (token) {
    strcpy(cmd[i], token);
    i++;
    token = strtok(0, dl);
  }
  cmd[i][0] = 0;
  return i;
}


x86 assembly (clang, -O0):
<BreakApartInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec9(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x14,-0x14(%rbp)
jge    11a6 <BreakApartInput+0x86>
movl   $0x0,-0x18(%rbp)
cmpl   $0x40,-0x18(%rbp)
jge    1193 <BreakApartInput+0x73>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x6,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1164 <BreakApartInput+0x44>
jmp    1198 <BreakApartInput+0x78>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1153 <BreakApartInput+0x33>
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11ef <BreakApartInput+0xcf>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x6,%rax
add    %rax,%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1040 <strtok@plt>
mov    %rax,-0x28(%rbp)
jmp    11ad <BreakApartInput+0x8d>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x6,%rcx
add    %rcx,%rax
movb   $0x0,(%rax)
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BreakApartInput>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
lea    0xebd(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,%r15
xor    %r13d,%r13d
mov    $0x500,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
test   %r15,%r15
je     1195 <BreakApartInput+0x65>
xor    %r13d,%r13d
lea    0xe94(%rip),%r12
mov    %r14,%rbx
nop
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   1050 <strtok@plt>
mov    %rax,%r15
add    $0x40,%rbx
add    $0x1,%r13d
test   %rax,%rax
jne    1170 <BreakApartInput+0x40>
mov    %r13d,%eax
shl    $0x6,%rax
movb   $0x0,(%r14,%rax,1)
mov    %r13d,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define i32 @BreakApartInput(i8* %0, [64 x i8]* %1) {
%3 = alloca i8*
%4 = alloca [64 x i8]*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %3
store [64 x i8]* %1, [64 x i8]** %4
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %7
%9 = load i8*, i8** %3
%10 = load i8*, i8** %7
%11 = call i8* @strtok(i8* %9, i8* %10)
store i8* %11, i8** %8
store i32 0, i32* %5
br label %12
12: ; preds = %31, %2
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 20
br i1 %14, label %15, label %34
15: ; preds = %12
store i32 0, i32* %6
br label %16
16: ; preds = %27, %15
%17 = load i32, i32* %6
%18 = icmp slt i32 %17, 64
br i1 %18, label %19, label %30
19: ; preds = %16
%20 = load [64 x i8]*, [64 x i8]** %4
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [64 x i8], [64 x i8]* %20, i64 %22
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [64 x i8], [64 x i8]* %23, i64 0, i64 %25
store i8 0, i8* %26
br label %27
27: ; preds = %19
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %16
30: ; preds = %16
br label %31
31: ; preds = %30
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %12
34: ; preds = %12
store i32 0, i32* %5
br label %35
35: ; preds = %38, %34
%36 = load i8*, i8** %8
%37 = icmp ne i8* %36, null
br i1 %37, label %38, label %50
38: ; preds = %35
%39 = load [64 x i8]*, [64 x i8]** %4
%40 = load i32, i32* %5
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [64 x i8], [64 x i8]* %39, i64 %41
%43 = getelementptr inbounds [64 x i8], [64 x i8]* %42, i64 0, i64 0
%44 = load i8*, i8** %8
%45 = call i32 @strcpy(i8* %43, i8* %44)
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
%48 = load i8*, i8** %7
%49 = call i8* @strtok(i8* null, i8* %48)
store i8* %49, i8** %8
br label %35
50: ; preds = %35
%51 = load [64 x i8]*, [64 x i8]** %4
%52 = load i32, i32* %5
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [64 x i8], [64 x i8]* %51, i64 %53
%55 = getelementptr inbounds [64 x i8], [64 x i8]* %54, i64 0, i64 0
store i8 0, i8* %55
%56 = load i32, i32* %5
ret i32 %56
}

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