#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 *calloc(int, int);
scalar_t__ isalpha(char);
int strlen(char *);
char toupper(char);
int *genccountdict(char *input) {
  int *dict = calloc(sizeof(int), 26);
  int i;
  for (i = 0; i < strlen(input); i++)
    if (isalpha(input[i]))
      dict[toupper(input[i]) - 'A']++;
  return dict;
}


x86 assembly (clang, -O0):
<genccountdict>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x4,%edi
mov    $0x1a,%esi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    11e1 <genccountdict+0xa1>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%rax
je     11ce <genccountdict+0x8e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
movsbl %cl,%ecx
sub    $0x41,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
jmp    11d3 <genccountdict+0x93>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1166 <genccountdict+0x26>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genccountdict>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
mov    $0x4,%edi
mov    $0x1a,%esi
call   1050 <calloc@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11ab <genccountdict+0x6b>
xor    %ebx,%ebx
jmp    1183 <genccountdict+0x43>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    11ab <genccountdict+0x6b>
movsbl (%r15,%rbx,1),%edi
call   1060 <isalpha@plt>
test   %rax,%rax
je     1170 <genccountdict+0x30>
movsbl (%r15,%rbx,1),%edi
call   1030 <toupper@plt>
movsbq %al,%rax
addl   $0x1,-0x104(%r14,%rax,4)
ff 01
jmp    1170 <genccountdict+0x30>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32* @genccountdict(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i32* @calloc(i32 4, i32 26)
store i32* %5, i32** %3
store i32 0, i32* %4
br label %6
6: ; preds = %34, %1
%7 = load i32, i32* %4
%8 = load i8*, i8** %2
%9 = call i32 @strlen(i8* %8)
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %37
11: ; preds = %6
%12 = load i8*, i8** %2
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = call i64 @isalpha(i8 signext %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %33
19: ; preds = %11
%20 = load i32*, i32** %3
%21 = load i8*, i8** %2
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = call signext i8 @toupper(i8 signext %25)
%27 = sext i8 %26 to i32
%28 = sub nsw i32 %27, 65
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %20, i64 %29
%31 = load i32, i32* %30
%32 = add nsw i32 %31, 1
store i32 %32, i32* %30
br label %33
33: ; preds = %19, %11
br label %34
34: ; preds = %33
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %6
37: ; preds = %6
%38 = load i32*, i32** %3
ret i32* %38
}

LLVM IR (-O2):
define noalias i32* @genccountdict(i8* %0) {
%2 = tail call i32* @calloc(i32 4, i32 26)
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %24
5: ; preds = %1, %19
%6 = phi i64 [ %20, %19 ], [ 0, %1 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = tail call i64 @isalpha(i8 signext %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %19, label %11
11: ; preds = %5
%12 = load i8, i8* %7
%13 = tail call signext i8 @toupper(i8 signext %12)
%14 = sext i8 %13 to i64
%15 = add nsw i64 %14, -65
%16 = getelementptr inbounds i32, i32* %2, i64 %15
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1
store i32 %18, i32* %16
br label %19
19: ; preds = %5, %11
%20 = add nuw nsw i64 %6, 1
%21 = tail call i32 @strlen(i8* %0)
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %5, label %24
24: ; preds = %19, %1
ret i32* %2
}