#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*/ make1DArrayFrom2D(char *, char **, int);
int strlen(char *);
char *strtok(char *, char *);
int wordLengthAnalysis(char **bufferPtr, int numOfLines, int length) {
  char copy[10 * 80];
  make1DArrayFrom2D(copy, bufferPtr, numOfLines);
  char *strTokenPtr;
  int count = 0;
  strTokenPtr = strtok(copy, " \r\n");
  while (strTokenPtr != NULL) {
    if (strlen(strTokenPtr) == length) {
      count++;
    }
    strTokenPtr = strtok(NULL, " \r\n");
  }
  return count;
}


x86 assembly (clang, -O0):
<wordLengthAnalysis>:
push   %rbp
mov    %rsp,%rbp
sub    $0x340,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    -0x330(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1040 <make1DArrayFrom2D@plt>
movl   $0x0,-0x33c(%rbp)
lea    -0x330(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x338(%rbp)
cmpq   $0x0,-0x338(%rbp)
je     11ca <wordLengthAnalysis+0x9a>
mov    -0x338(%rbp),%rdi
call   1030 <strlen@plt>
cmp    -0x10(%rbp),%eax
jne    11ae <wordLengthAnalysis+0x7e>
mov    -0x33c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x33c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe47(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x338(%rbp)
jmp    117c <wordLengthAnalysis+0x4c>
mov    -0x33c(%rbp),%eax
add    $0x340,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wordLengthAnalysis>:
push   %rbp
push   %r14
push   %rbx
sub    $0x320,%rsp
mov    %edx,%ebp
mov    %esi,%edx
mov    %rdi,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <make1DArrayFrom2D@plt>
lea    0xeac(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strtok@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     1190 <wordLengthAnalysis+0x60>
lea    0xe96(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %rax,%rdi
call   1030 <strlen@plt>
xor    %ecx,%ecx
cmp    %ebp,%eax
sete   %cl
add    %ecx,%ebx
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <strtok@plt>
test   %rax,%rax
jne    1170 <wordLengthAnalysis+0x40>
mov    %ebx,%eax
add    $0x320,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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