#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*/ printf(char *, ...);
int toupper(char);
void frequency_calculator(char *src) {
  int alphabet[26];
  int ascii[256];
  int i;
  for (i = 0; i < 26; i++) {
    alphabet[i] = 0;
  }
  for (i = 0; i < 256; i++) {
    ascii[i] = 0;
  }
  char c;
  int j;
  i = 0;
  while (src[i] != '\0') {
    c = src[i];
    ascii[c]++;
    if (isalpha(c)) {
      j = toupper(c) - 65;
      alphabet[j]++;
    }
    i++;
  }
  printf("ASCII Analysis:\n");
  for (i = 0; i < 255; i++) {
    if (ascii[i] != 0) {
      printf("'%c' = %d\n", (char)i, ascii[i]);
    }
  }
  printf("Alphabet Analysis:\n");
  for (i = 0; i < 26; i++) {
    if (alphabet[i] != 0) {
      printf("'%c' = %d\n", (char)i + 97, alphabet[i]);
    }
  }
}


x86 assembly (clang, -O0):
<frequency_calculator>:
push   %rbp
mov    %rsp,%rbp
sub    $0x480,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x474(%rbp)
cmpl   $0x1a,-0x474(%rbp)
jge    1179 <frequency_calculator+0x49>
movslq -0x474(%rbp),%rax
movl   $0x0,-0x70(%rbp,%rax,4)
mov    -0x474(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x474(%rbp)
jmp    1149 <frequency_calculator+0x19>
movl   $0x0,-0x474(%rbp)
cmpl   $0x100,-0x474(%rbp)
jge    11b9 <frequency_calculator+0x89>
movslq -0x474(%rbp),%rax
movl   $0x0,-0x470(%rbp,%rax,4)
mov    -0x474(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x474(%rbp)
jmp    1183 <frequency_calculator+0x53>
movl   $0x0,-0x474(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x474(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1259 <frequency_calculator+0x129>
mov    -0x8(%rbp),%rax
movslq -0x474(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x475(%rbp)
movsbq -0x475(%rbp),%rax
ff
mov    -0x470(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x470(%rbp,%rax,4)
movsbl -0x475(%rbp),%edi
call   1050 <isalpha@plt>
cmp    $0x0,%rax
je     1245 <frequency_calculator+0x115>
movsbl -0x475(%rbp),%edi
call   1030 <toupper@plt>
sub    $0x41,%eax
mov    %eax,-0x47c(%rbp)
movslq -0x47c(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x70(%rbp,%rax,4)
mov    -0x474(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x474(%rbp)
jmp    11c3 <frequency_calculator+0x93>
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x474(%rbp)
cmpl   $0xff,-0x474(%rbp)
jge    12d4 <frequency_calculator+0x1a4>
movslq -0x474(%rbp),%rax
cmpl   $0x0,-0x470(%rbp,%rax,4)
je     12bb <frequency_calculator+0x18b>
mov    -0x474(%rbp),%eax
movsbl %al,%esi
movslq -0x474(%rbp),%rax
mov    -0x470(%rbp,%rax,4),%edx
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12c0 <frequency_calculator+0x190>
mov    -0x474(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x474(%rbp)
jmp    1271 <frequency_calculator+0x141>
lea    0xd41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x474(%rbp)
cmpl   $0x1a,-0x474(%rbp)
jge    1349 <frequency_calculator+0x219>
movslq -0x474(%rbp),%rax
cmpl   $0x0,-0x70(%rbp,%rax,4)
je     1330 <frequency_calculator+0x200>
mov    -0x474(%rbp),%eax
movsbl %al,%esi
add    $0x61,%esi
movslq -0x474(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%edx
lea    0xce8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1335 <frequency_calculator+0x205>
mov    -0x474(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x474(%rbp)
jmp    12ec <frequency_calculator+0x1bc>
add    $0x480,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<frequency_calculator>:
push   %rbp
push   %r14
push   %rbx
sub    $0x470,%rsp
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movq   $0x0,0x60(%rsp)
lea    0x70(%rsp),%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    (%rbx),%al
test   %al,%al
je     11e6 <frequency_calculator+0x96>
add    $0x1,%rbx
jmp    11bb <frequency_calculator+0x6b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11e6 <frequency_calculator+0x96>
movsbq %al,%rax
addl   $0x1,0x70(%rsp,%rax,4)
movsbl %al,%ebp
mov    %ebp,%edi
call   1070 <isalpha@plt>
test   %rax,%rax
je     11b0 <frequency_calculator+0x60>
mov    %ebp,%edi
call   1030 <toupper@plt>
cltq
addl   $0x1,-0x104(%rsp,%rax,4)
01
jmp    11b0 <frequency_calculator+0x60>
lea    0xe1e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe07(%rip),%r14
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    1213 <frequency_calculator+0xc3>
nop
add    $0x1,%rbx
add    $0x1000000,%ebp
cmp    $0xff,%rbx
je     122c <frequency_calculator+0xdc>
mov    0x70(%rsp,%rbx,4),%edx
test   %edx,%edx
je     1200 <frequency_calculator+0xb0>
mov    %ebp,%esi
sar    $0x18,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1200 <frequency_calculator+0xb0>
lea    0xde8(%rip),%rdi
call   1040 <puts@plt>
lea    0xdc1(%rip),%rbx
xor    %ebp,%ebp
jmp    125a <frequency_calculator+0x10a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbp
cmp    $0x1a,%rbp
je     1270 <frequency_calculator+0x120>
mov    (%rsp,%rbp,4),%edx
test   %edx,%edx
je     1250 <frequency_calculator+0x100>
lea    0x61(%rbp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1250 <frequency_calculator+0x100>
add    $0x470,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"ASCII Analysis:\0A\00"
@.str.1 = [11 x i8] c"'%c' = %d\0A\00"
@.str.2 = [20 x i8] c"Alphabet Analysis:\0A\00"
define void @frequency_calculator(i8* %0) {
%2 = alloca i8*
%3 = alloca [26 x i32]
%4 = alloca [256 x i32]
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %5
br label %8
8: ; preds = %15, %1
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 26
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [26 x i32], [26 x i32]* %3, i64 0, i64 %13
store i32 0, i32* %14
br label %15
15: ; preds = %11
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
store i32 %17, i32* %5
br label %8
18: ; preds = %8
store i32 0, i32* %5
br label %19
19: ; preds = %26, %18
%20 = load i32, i32* %5
%21 = icmp slt i32 %20, 256
br i1 %21, label %22, label %29
22: ; preds = %19
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %24
store i32 0, i32* %25
br label %26
26: ; preds = %22
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %19
29: ; preds = %19
store i32 0, i32* %5
br label %30
30: ; preds = %61, %29
%31 = load i8*, i8** %2
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %64
38: ; preds = %30
%39 = load i8*, i8** %2
%40 = load i32, i32* %5
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
store i8 %43, i8* %6
%44 = load i8, i8* %6
%45 = sext i8 %44 to i64
%46 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %45
%47 = load i32, i32* %46
%48 = add nsw i32 %47, 1
store i32 %48, i32* %46
%49 = load i8, i8* %6
%50 = call i64 @isalpha(i8 signext %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %61
52: ; preds = %38
%53 = load i8, i8* %6
%54 = call i32 @toupper(i8 signext %53)
%55 = sub nsw i32 %54, 65
store i32 %55, i32* %7
%56 = load i32, i32* %7
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [26 x i32], [26 x i32]* %3, i64 0, i64 %57
%59 = load i32, i32* %58
%60 = add nsw i32 %59, 1
store i32 %60, i32* %58
br label %61
61: ; preds = %52, %38
%62 = load i32, i32* %5
%63 = add nsw i32 %62, 1
store i32 %63, i32* %5
br label %30
64: ; preds = %30
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %66
66: ; preds = %85, %64
%67 = load i32, i32* %5
%68 = icmp slt i32 %67, 255
br i1 %68, label %69, label %88
69: ; preds = %66
%70 = load i32, i32* %5
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %71
%73 = load i32, i32* %72
%74 = icmp ne i32 %73, 0
br i1 %74, label %75, label %84
75: ; preds = %69
%76 = load i32, i32* %5
%77 = trunc i32 %76 to i8
%78 = sext i8 %77 to i32
%79 = load i32, i32* %5
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %80
%82 = load i32, i32* %81
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %78, i32 %82)
br label %84
84: ; preds = %75, %69
br label %85
85: ; preds = %84
%86 = load i32, i32* %5
%87 = add nsw i32 %86, 1
store i32 %87, i32* %5
br label %66
88: ; preds = %66
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %5
br label %90
90: ; preds = %110, %88
%91 = load i32, i32* %5
%92 = icmp slt i32 %91, 26
br i1 %92, label %93, label %113
93: ; preds = %90
%94 = load i32, i32* %5
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [26 x i32], [26 x i32]* %3, i64 0, i64 %95
%97 = load i32, i32* %96
%98 = icmp ne i32 %97, 0
br i1 %98, label %99, label %109
99: ; preds = %93
%100 = load i32, i32* %5
%101 = trunc i32 %100 to i8
%102 = sext i8 %101 to i32
%103 = add nsw i32 %102, 97
%104 = load i32, i32* %5
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds [26 x i32], [26 x i32]* %3, i64 0, i64 %105
%107 = load i32, i32* %106
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %103, i32 %107)
br label %109
109: ; preds = %99, %93
br label %110
110: ; preds = %109
%111 = load i32, i32* %5
%112 = add nsw i32 %111, 1
store i32 %112, i32* %5
br label %90
113: ; preds = %90
ret void
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"'%c' = %d\0A\00"
@str = [16 x i8] c"ASCII Analysis:\00"
@str.3 = [19 x i8] c"Alphabet Analysis:\00"
define void @frequency_calculator(i8* nocapture %0) {
%2 = alloca [26 x i32]
%3 = bitcast [26 x i32]* %2 to i8*
%4 = alloca [256 x i32]
%5 = bitcast [256 x i32]* %4 to i8*
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 0
br i1 %7, label %29, label %8
8: ; preds = %1, %24
%9 = phi i64 [ %25, %24 ], [ 0, %1 ]
%10 = phi i8 [ %27, %24 ], [ %6, %1 ]
%11 = sext i8 %10 to i64
%12 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = add nsw i32 %13, 1
store i32 %14, i32* %12
%15 = tail call i64 @isalpha(i8 signext %10)
%16 = icmp eq i64 %15, 0
br i1 %16, label %24, label %17
17: ; preds = %8
%18 = tail call i32 @toupper(i8 signext %10)
%19 = add nsw i32 %18, -65
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [26 x i32], [26 x i32]* %2, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 1
store i32 %23, i32* %21
br label %24
24: ; preds = %17, %8
%25 = add nuw i64 %9, 1
%26 = getelementptr inbounds i8, i8* %0, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 0
br i1 %28, label %29, label %8
29: ; preds = %24, %1
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %31
31: ; preds = %29, %41
%32 = phi i64 [ 0, %29 ], [ %42, %41 ]
%33 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = icmp eq i32 %34, 0
br i1 %35, label %41, label %36
36: ; preds = %31
%37 = trunc i64 %32 to i32
%38 = shl i32 %37, 24
%39 = ashr exact i32 %38, 24
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %39, i32 %34)
br label %41
41: ; preds = %31, %36
%42 = add nuw nsw i64 %32, 1
%43 = icmp eq i64 %42, 255
br i1 %43, label %44, label %31
44: ; preds = %41
%45 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.3, i64 0, i64 0))
br label %46
46: ; preds = %44, %55
%47 = phi i64 [ 0, %44 ], [ %56, %55 ]
%48 = getelementptr inbounds [26 x i32], [26 x i32]* %2, i64 0, i64 %47
%49 = load i32, i32* %48
%50 = icmp eq i32 %49, 0
br i1 %50, label %55, label %51
51: ; preds = %46
%52 = trunc i64 %47 to i32
%53 = add i32 %52, 97
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %53, i32 %49)
br label %55
55: ; preds = %46, %51
%56 = add nuw nsw i64 %47, 1
%57 = icmp eq i64 %56, 26
br i1 %57, label %58, label %46
58: ; preds = %55
ret void
}