#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 *);
int strlen(char *);
char *strtok(char *, char *);
int tokenize(char *line, char arr[16][64]) {
  int i, slen;
  char *s;
  i = slen = 0;
  s = strtok(line, " ");
  if (s) {
    slen = strlen(s);
    if (s[slen - 1] == '\n')
      s[slen - 1] = '\0';
  }
  strcpy(arr[0], s);
  while (s != NULL) {
    i++;
    s = strtok(NULL, " ");
    if (s) {
      slen = strlen(s);
      if (s[slen - 1] == '\n') {
        s[slen - 1] = '\0';
      }
      strcpy(arr[i], s);
    }
  }
  return i;
}


x86 assembly (clang, -O0):
<tokenize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11a9 <tokenize+0x79>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    11a4 <tokenize+0x74>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11a9 <tokenize+0x79>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
cmpq   $0x0,-0x20(%rbp)
je     123d <tokenize+0x10d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe2b(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1238 <tokenize+0x108>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1220 <tokenize+0xf0>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x6,%rax
add    %rax,%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11b6 <tokenize+0x86>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tokenize>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
lea    0xebf(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11dc <tokenize+0xac>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    1168 <tokenize+0x38>
movb   $0x0,-0x1(%rbx,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xe86(%rip),%rsi
xor    %edi,%edi
call   1050 <strtok@plt>
test   %rax,%rax
je     11eb <tokenize+0xbb>
mov    %rax,%rbx
add    $0x40,%r15
mov    $0x1,%ebp
lea    0xe67(%rip),%r14
jmp    11c4 <tokenize+0x94>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <strtok@plt>
mov    %rax,%rbx
add    $0x1,%ebp
add    $0x40,%r15
test   %rax,%rax
je     11f0 <tokenize+0xc0>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    11a0 <tokenize+0x70>
movb   $0x0,-0x1(%rbx,%rax,1)
jmp    11a0 <tokenize+0x70>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
xor    %ebp,%ebp
jmp    11f0 <tokenize+0xc0>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define i32 @tokenize(i8* %0, [64 x i8]* %1) {
%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 %13, label %5
5: ; preds = %2
%6 = tail call i32 @strlen(i8* %3)
%7 = add nsw i32 %6, -1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %3, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 10
br i1 %11, label %12, label %16
12: ; preds = %5
store i8 0, i8* %9
br label %16
13: ; preds = %2
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%15 = tail call i32 @strcpy(i8* %14, i8* %3)
br label %39
16: ; preds = %5, %12
%17 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%18 = tail call i32 @strcpy(i8* %17, i8* %3)
%19 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i8* %19, null
br i1 %20, label %39, label %21
21: ; preds = %16, %31
%22 = phi i8* [ %35, %31 ], [ %19, %16 ]
%23 = phi i64 [ %34, %31 ], [ 1, %16 ]
%24 = tail call i32 @strlen(i8* %22)
%25 = add nsw i32 %24, -1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %22, i64 %26
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 10
br i1 %29, label %30, label %31
30: ; preds = %21
store i8 0, i8* %27
br label %31
31: ; preds = %30, %21
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 %23, i64 0
%33 = tail call i32 @strcpy(i8* %32, i8* %22)
%34 = add nuw i64 %23, 1
%35 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %21
37: ; preds = %31
%38 = trunc i64 %34 to i32
br label %39
39: ; preds = %16, %37, %13
%40 = phi i32 [ 0, %13 ], [ %38, %37 ], [ 1, %16 ]
ret i32 %40
}