#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 */
scalar_t__ isalpha(char);
int /*<<< orphan*/ make1DArrayFrom2D(char *, char **, int);
int /*<<< orphan*/ printf(char *, char const, int);
int /*<<< orphan*/ puts(char *);
char *strchr(char *, char const);
char tolower(char);
void letterAnalysis(char **bufferPtr, int numOfLines) {
  puts("");
  const char *alphabet = "abcdefghijklmnopqrstuvwxyz";
  char copy[10 * 80];
  make1DArrayFrom2D(copy, bufferPtr, numOfLines);
  for (unsigned int j = 0; (copy[j]) != '\0'; j++) {
    if (isalpha((copy[j]))) {
      (copy[j]) = tolower((copy[j]));
    }
  }
  for (unsigned int j = 0; alphabet[j] != '\0'; j++) {
    int count = 0;
    char *str = strchr(copy, alphabet[j]);
    ;
    while (str != NULL) {
      count++;
      str = strchr(str + 1, alphabet[j]);
    }
    if (j % 5 == 0)
      puts("");
    printf("%c : %3d   ", alphabet[j], count);
  }
  puts("");
}


x86 assembly (clang, -O0):
<letterAnalysis>:
push   %rbp
mov    %rsp,%rbp
sub    $0x360,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7b(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x340(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1060 <make1DArrayFrom2D@plt>
movl   $0x0,-0x344(%rbp)
mov    -0x344(%rbp),%eax
movsbl -0x340(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1215 <letterAnalysis+0xb5>
mov    -0x344(%rbp),%eax
movsbl -0x340(%rbp,%rax,1),%edi
ff
call   1080 <isalpha@plt>
cmp    $0x0,%rax
je     11fc <letterAnalysis+0x9c>
mov    -0x344(%rbp),%eax
movsbl -0x340(%rbp,%rax,1),%edi
ff
call   1070 <tolower@plt>
mov    %al,%cl
mov    -0x344(%rbp),%eax
mov    %cl,-0x340(%rbp,%rax,1)
jmp    1201 <letterAnalysis+0xa1>
mov    -0x344(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x344(%rbp)
jmp    11a6 <letterAnalysis+0x46>
movl   $0x0,-0x348(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x348(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1302 <letterAnalysis+0x1a2>
movl   $0x0,-0x34c(%rbp)
lea    -0x340(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x348(%rbp),%ecx
movsbl (%rax,%rcx,1),%esi
call   1040 <strchr@plt>
mov    %rax,-0x358(%rbp)
cmpq   $0x0,-0x358(%rbp)
je     12a8 <letterAnalysis+0x148>
mov    -0x34c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34c(%rbp)
mov    -0x358(%rbp),%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rax
mov    -0x348(%rbp),%ecx
movsbl (%rax,%rcx,1),%esi
call   1040 <strchr@plt>
mov    %rax,-0x358(%rbp)
jmp    1261 <letterAnalysis+0x101>
mov    -0x348(%rbp),%eax
mov    $0x5,%ecx
xor    %edx,%edx
div    %ecx
cmp    $0x0,%edx
jne    12cc <letterAnalysis+0x16c>
lea    0xd5f(%rip),%rdi
call   1030 <puts@plt>
mov    -0x18(%rbp),%rax
mov    -0x348(%rbp),%ecx
mov    (%rax,%rcx,1),%al
mov    -0x34c(%rbp),%edx
lea    0xd35(%rip),%rdi
movsbl %al,%esi
call   1050 <printf@plt>
mov    -0x348(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x348(%rbp)
jmp    121f <letterAnalysis+0xbf>
lea    0xd1d(%rip),%rdi
call   1030 <puts@plt>
add    $0x360,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<letterAnalysis>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x328,%rsp
mov    %esi,%r14d
mov    %rdi,%rbp
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1060 <make1DArrayFrom2D@plt>
mov    (%rsp),%al
test   %al,%al
je     11ca <letterAnalysis+0x6a>
mov    $0x1,%ebp
jmp    11b1 <letterAnalysis+0x51>
mov    %ebp,%eax
lea    (%rsp,%rax,1),%rbx
movzbl (%rsp,%rax,1),%eax
add    $0x1,%ebp
test   %al,%al
je     11ca <letterAnalysis+0x6a>
movsbl %al,%edi
call   1080 <isalpha@plt>
test   %rax,%rax
je     11a0 <letterAnalysis+0x40>
movsbl (%rbx),%edi
call   1070 <tolower@plt>
mov    %al,(%rbx)
jmp    11a0 <letterAnalysis+0x40>
xor    %r12d,%r12d
lea    0xe2c(%rip),%r13
mov    %rsp,%r14
lea    0xe3d(%rip),%r15
jmp    11f6 <letterAnalysis+0x96>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1050 <printf@plt>
add    $0x1,%r12
cmp    $0x1a,%r12
je     1250 <letterAnalysis+0xf0>
movsbl (%r12,%r13,1),%ebp
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <strchr@plt>
mov    $0x0,%ebx
test   %rax,%rax
je     1236 <letterAnalysis+0xd6>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
add    $0x1,%rax
mov    %rax,%rdi
mov    %ebp,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    1220 <letterAnalysis+0xc0>
imul   $0xcccccccd,%r12d,%eax
cmp    $0x33333333,%eax
ja     11e0 <letterAnalysis+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11e0 <letterAnalysis+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x328,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
@.str.2 = [12 x i8] c"%c : %3d \00"
define void @letterAnalysis(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [800 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i8** %0, i8*** %3
store i32 %1, i32* %4
%11 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8** %5
%12 = getelementptr inbounds [800 x i8], [800 x i8]* %6, i64 0, i64 0
%13 = load i8**, i8*** %3
%14 = load i32, i32* %4
%15 = call i32 @make1DArrayFrom2D(i8* %12, i8** %13, i32 %14)
store i32 0, i32* %7
br label %16
16: ; preds = %40, %2
%17 = load i32, i32* %7
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds [800 x i8], [800 x i8]* %6, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %43
23: ; preds = %16
%24 = load i32, i32* %7
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds [800 x i8], [800 x i8]* %6, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = call i64 @isalpha(i8 signext %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %39
30: ; preds = %23
%31 = load i32, i32* %7
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds [800 x i8], [800 x i8]* %6, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = call signext i8 @tolower(i8 signext %34)
%36 = load i32, i32* %7
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds [800 x i8], [800 x i8]* %6, i64 0, i64 %37
store i8 %35, i8* %38
br label %39
39: ; preds = %30, %23
br label %40
40: ; preds = %39
%41 = load i32, i32* %7
%42 = add i32 %41, 1
store i32 %42, i32* %7
br label %16
43: ; preds = %16
store i32 0, i32* %8
br label %44
44: ; preds = %88, %43
%45 = load i8*, i8** %5
%46 = load i32, i32* %8
%47 = zext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %91
52: ; preds = %44
store i32 0, i32* %9
%53 = getelementptr inbounds [800 x i8], [800 x i8]* %6, i64 0, i64 0
%54 = load i8*, i8** %5
%55 = load i32, i32* %8
%56 = zext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
%58 = load i8, i8* %57
%59 = call i8* @strchr(i8* %53, i8 signext %58)
store i8* %59, i8** %10
br label %60
60: ; preds = %63, %52
%61 = load i8*, i8** %10
%62 = icmp ne i8* %61, null
br i1 %62, label %63, label %74
63: ; preds = %60
%64 = load i32, i32* %9
%65 = add nsw i32 %64, 1
store i32 %65, i32* %9
%66 = load i8*, i8** %10
%67 = getelementptr inbounds i8, i8* %66, i64 1
%68 = load i8*, i8** %5
%69 = load i32, i32* %8
%70 = zext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %68, i64 %70
%72 = load i8, i8* %71
%73 = call i8* @strchr(i8* %67, i8 signext %72)
store i8* %73, i8** %10
br label %60
74: ; preds = %60
%75 = load i32, i32* %8
%76 = urem i32 %75, 5
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %74
%79 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %80
80: ; preds = %78, %74
%81 = load i8*, i8** %5
%82 = load i32, i32* %8
%83 = zext i32 %82 to i64
%84 = getelementptr inbounds i8, i8* %81, i64 %83
%85 = load i8, i8* %84
%86 = load i32, i32* %9
%87 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8 signext %85, i32 %86)
br label %88
88: ; preds = %80
%89 = load i32, i32* %8
%90 = add i32 %89, 1
store i32 %90, i32* %8
br label %44
91: ; preds = %44
%92 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
@.str.2 = [12 x i8] c"%c : %3d \00"
define void @letterAnalysis(i8** %0, i32 %1) {
%3 = alloca [800 x i8]
%4 = tail call i32 @putchar(i32 10)
%5 = getelementptr inbounds [800 x i8], [800 x i8]* %3, i64 0, i64 0
%6 = call i32 @make1DArrayFrom2D(i8* %5, i8** %0, i32 %1)
%7 = load i8, i8* %5
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %19, %2
br label %27
10: ; preds = %2, %19
%11 = phi i8 [ %23, %19 ], [ %7, %2 ]
%12 = phi i8* [ %22, %19 ], [ %5, %2 ]
%13 = phi i32 [ %20, %19 ], [ 0, %2 ]
%14 = call i64 @isalpha(i8 signext %11)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %10
%17 = load i8, i8* %12
%18 = call signext i8 @tolower(i8 signext %17)
store i8 %18, i8* %12
br label %19
19: ; preds = %10, %16
%20 = add i32 %13, 1
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds [800 x i8], [800 x i8]* %3, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %9, label %10
25: ; preds = %47
%26 = call i32 @putchar(i32 10)
ret void
27: ; preds = %9, %47
%28 = phi i64 [ %49, %47 ], [ 0, %9 ]
%29 = getelementptr inbounds [27 x i8], [27 x i8]* @.str.1, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = call i8* @strchr(i8* %5, i8 signext %30)
%32 = icmp eq i8* %31, null
br i1 %32, label %40, label %33
33: ; preds = %27, %33
%34 = phi i8* [ %38, %33 ], [ %31, %27 ]
%35 = phi i32 [ %36, %33 ], [ 0, %27 ]
%36 = add nuw nsw i32 %35, 1
%37 = getelementptr inbounds i8, i8* %34, i64 1
%38 = call i8* @strchr(i8* %37, i8 signext %30)
%39 = icmp eq i8* %38, null
br i1 %39, label %40, label %33
40: ; preds = %33, %27
%41 = phi i32 [ 0, %27 ], [ %36, %33 ]
%42 = trunc i64 %28 to i32
%43 = urem i32 %42, 5
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %40
%46 = call i32 @putchar(i32 10)
br label %47
47: ; preds = %45, %40
%48 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8 signext %30, i32 %41)
%49 = add nuw nsw i64 %28, 1
%50 = icmp eq i64 %49, 26
br i1 %50, label %25, label %27
}