#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__ isupper(char const);
double *xcalloc(int, int);
double *letterfreq(const char *m) {
  int i;
  int msgsize = 0;
  double *freqcount = xcalloc(26, sizeof(*freqcount));
  for (; *m != '\0' && *m != '\n'; m++) {
    i = isupper(*m) ? *m - 'A' : *m - 'a';
    freqcount[i]++;
    msgsize++;
  }
  for (i = 0; i < 26; i++)
    freqcount[i] /= msgsize;
  return freqcount;
}


x86 assembly (clang, -O0):
<letterfreq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x1a,%edi
mov    $0x8,%esi
call   1040 <xcalloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     116b <letterfreq+0x4b>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    117b <letterfreq+0x5b>
jmp    11ea <letterfreq+0xca>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isupper@plt>
cmp    $0x0,%rax
je     11a3 <letterfreq+0x83>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
sub    $0x41,%eax
mov    %eax,-0x20(%rbp)
jmp    11b0 <letterfreq+0x90>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
sub    $0x61,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  0xe3a(%rip),%xmm0
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1146 <letterfreq+0x26>
movl   $0x0,-0xc(%rbp)
cmpl   $0x1a,-0xc(%rbp)
jge    1224 <letterfreq+0x104>
cvtsi2sdl -0x10(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11f1 <letterfreq+0xd1>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<letterfreq>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x1a,%edi
mov    $0x8,%esi
call   1040 <xcalloc@plt>
mov    %rax,%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
movzbl (%r14,%rbx,1),%eax
test   %al,%al
je     118b <letterfreq+0x6b>
cmp    $0xa,%al
je     118b <letterfreq+0x6b>
movsbl %al,%edi
call   1030 <isupper@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
movsbq (%r14,%rbx,1),%rax
shl    $0x5,%rcx
add    %rax,%rcx
movsd  -0x308(%r15,%rcx,8),%xmm0
fc ff ff
addsd  0xe85(%rip),%xmm0
movsd  %xmm0,-0x308(%r15,%rcx,8)
fc ff ff
add    $0x1,%rbx
jmp    1140 <letterfreq+0x20>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
unpcklpd %xmm0,%xmm0
movupd (%r15),%xmm1
movupd 0x10(%r15),%xmm2
movupd 0x20(%r15),%xmm3
movupd 0x30(%r15),%xmm4
divpd  %xmm0,%xmm1
movupd %xmm1,(%r15)
divpd  %xmm0,%xmm2
movupd %xmm2,0x10(%r15)
divpd  %xmm0,%xmm3
movupd %xmm3,0x20(%r15)
divpd  %xmm0,%xmm4
movupd %xmm4,0x30(%r15)
movupd 0x40(%r15),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0x40(%r15)
movupd 0x50(%r15),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0x50(%r15)
movupd 0x60(%r15),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0x60(%r15)
movupd 0x70(%r15),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0x70(%r15)
movupd 0x80(%r15),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0x80(%r15)
movupd 0x90(%r15),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0x90(%r15)
movupd 0xa0(%r15),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0xa0(%r15)
movupd 0xb0(%r15),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0xb0(%r15)
movupd 0xc0(%r15),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0xc0(%r15)
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double* @letterfreq(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca double*
store i8* %0, i8** %2
store i32 0, i32* %4
%6 = call double* @xcalloc(i32 26, i32 8)
store double* %6, double** %5
br label %7
7: ; preds = %44, %1
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %7
%13 = load i8*, i8** %2
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 10
br label %17
17: ; preds = %12, %7
%18 = phi i1 [ false, %7 ], [ %16, %12 ]
br i1 %18, label %19, label %47
19: ; preds = %17
%20 = load i8*, i8** %2
%21 = load i8, i8* %20
%22 = call i64 @isupper(i8 signext %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = load i8*, i8** %2
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = sub nsw i32 %27, 65
br label %34
29: ; preds = %19
%30 = load i8*, i8** %2
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = sub nsw i32 %32, 97
br label %34
34: ; preds = %29, %24
%35 = phi i32 [ %28, %24 ], [ %33, %29 ]
store i32 %35, i32* %3
%36 = load double*, double** %5
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
%40 = load double, double* %39
%41 = fadd double %40, 1.000000e+00
store double %41, double* %39
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
store i32 %43, i32* %4
br label %44
44: ; preds = %34
%45 = load i8*, i8** %2
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %2
br label %7
47: ; preds = %17
store i32 0, i32* %3
br label %48
48: ; preds = %60, %47
%49 = load i32, i32* %3
%50 = icmp slt i32 %49, 26
br i1 %50, label %51, label %63
51: ; preds = %48
%52 = load i32, i32* %4
%53 = sitofp i32 %52 to double
%54 = load double*, double** %5
%55 = load i32, i32* %3
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double, double* %54, i64 %56
%58 = load double, double* %57
%59 = fdiv double %58, %53
store double %59, double* %57
br label %60
60: ; preds = %51
%61 = load i32, i32* %3
%62 = add nsw i32 %61, 1
store i32 %62, i32* %3
br label %48
63: ; preds = %48
%64 = load double*, double** %5
ret double* %64
}

LLVM IR (-O2):
define double* @letterfreq(i8* nocapture %0) {
%2 = tail call double* @xcalloc(i32 26, i32 8)
br label %3
3: ; preds = %7, %1
%4 = phi i32 [ 0, %1 ], [ %17, %7 ]
%5 = phi i8* [ %0, %1 ], [ %18, %7 ]
%6 = load i8, i8* %5
switch i8 %6, label %7 [
i8 0, label %19
i8 10, label %19
]
7: ; preds = %3
%8 = tail call i64 @isupper(i8 signext %6)
%9 = icmp eq i64 %8, 0
%10 = load i8, i8* %5
%11 = sext i8 %10 to i64
%12 = select i1 %9, i64 -97, i64 -65
%13 = add nsw i64 %12, %11
%14 = getelementptr inbounds double, double* %2, i64 %13
%15 = load double, double* %14
%16 = fadd double %15, 1.000000e+00
store double %16, double* %14
%17 = add nuw nsw i32 %4, 1
%18 = getelementptr inbounds i8, i8* %5, i64 1
br label %3
19: ; preds = %3, %3
%20 = sitofp i32 %4 to double
%21 = insertelement <2 x double> poison, double %20, i64 0
%22 = shufflevector <2 x double> %21, <2 x double> poison, <2 x i32> zeroinitializer
%23 = bitcast double* %2 to <2 x double>*
%24 = load <2 x double>, <2 x double>* %23
%25 = fdiv <2 x double> %24, %22
%26 = bitcast double* %2 to <2 x double>*
store <2 x double> %25, <2 x double>* %26
%27 = getelementptr inbounds double, double* %2, i64 2
%28 = bitcast double* %27 to <2 x double>*
%29 = load <2 x double>, <2 x double>* %28
%30 = fdiv <2 x double> %29, %22
%31 = bitcast double* %27 to <2 x double>*
store <2 x double> %30, <2 x double>* %31
%32 = getelementptr inbounds double, double* %2, i64 4
%33 = bitcast double* %32 to <2 x double>*
%34 = load <2 x double>, <2 x double>* %33
%35 = fdiv <2 x double> %34, %22
%36 = bitcast double* %32 to <2 x double>*
store <2 x double> %35, <2 x double>* %36
%37 = getelementptr inbounds double, double* %2, i64 6
%38 = bitcast double* %37 to <2 x double>*
%39 = load <2 x double>, <2 x double>* %38
%40 = fdiv <2 x double> %39, %22
%41 = bitcast double* %37 to <2 x double>*
store <2 x double> %40, <2 x double>* %41
%42 = getelementptr inbounds double, double* %2, i64 8
%43 = bitcast double* %42 to <2 x double>*
%44 = load <2 x double>, <2 x double>* %43
%45 = fdiv <2 x double> %44, %22
%46 = bitcast double* %42 to <2 x double>*
store <2 x double> %45, <2 x double>* %46
%47 = getelementptr inbounds double, double* %2, i64 10
%48 = bitcast double* %47 to <2 x double>*
%49 = load <2 x double>, <2 x double>* %48
%50 = fdiv <2 x double> %49, %22
%51 = bitcast double* %47 to <2 x double>*
store <2 x double> %50, <2 x double>* %51
%52 = getelementptr inbounds double, double* %2, i64 12
%53 = bitcast double* %52 to <2 x double>*
%54 = load <2 x double>, <2 x double>* %53
%55 = fdiv <2 x double> %54, %22
%56 = bitcast double* %52 to <2 x double>*
store <2 x double> %55, <2 x double>* %56
%57 = getelementptr inbounds double, double* %2, i64 14
%58 = bitcast double* %57 to <2 x double>*
%59 = load <2 x double>, <2 x double>* %58
%60 = fdiv <2 x double> %59, %22
%61 = bitcast double* %57 to <2 x double>*
store <2 x double> %60, <2 x double>* %61
%62 = getelementptr inbounds double, double* %2, i64 16
%63 = bitcast double* %62 to <2 x double>*
%64 = load <2 x double>, <2 x double>* %63
%65 = fdiv <2 x double> %64, %22
%66 = bitcast double* %62 to <2 x double>*
store <2 x double> %65, <2 x double>* %66
%67 = getelementptr inbounds double, double* %2, i64 18
%68 = bitcast double* %67 to <2 x double>*
%69 = load <2 x double>, <2 x double>* %68
%70 = fdiv <2 x double> %69, %22
%71 = bitcast double* %67 to <2 x double>*
store <2 x double> %70, <2 x double>* %71
%72 = getelementptr inbounds double, double* %2, i64 20
%73 = bitcast double* %72 to <2 x double>*
%74 = load <2 x double>, <2 x double>* %73
%75 = fdiv <2 x double> %74, %22
%76 = bitcast double* %72 to <2 x double>*
store <2 x double> %75, <2 x double>* %76
%77 = getelementptr inbounds double, double* %2, i64 22
%78 = bitcast double* %77 to <2 x double>*
%79 = load <2 x double>, <2 x double>* %78
%80 = fdiv <2 x double> %79, %22
%81 = bitcast double* %77 to <2 x double>*
store <2 x double> %80, <2 x double>* %81
%82 = getelementptr inbounds double, double* %2, i64 24
%83 = bitcast double* %82 to <2 x double>*
%84 = load <2 x double>, <2 x double>* %83
%85 = fdiv <2 x double> %84, %22
%86 = bitcast double* %82 to <2 x double>*
store <2 x double> %85, <2 x double>* %86
ret double* %2
}