#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*/ assert(int /*<<< orphan*/);
scalar_t__ calloc(int, int);
scalar_t__ isalpha(char);
char toupper(char);
int *count_char(char *string) {
  int *count_array = (int *)calloc(26, sizeof(int)), i;
  assert(count_array != NULL);
  for (i = 0; i < 26; i++) {
    count_array[i] = 0;
  }
  for (i = 0; string[i] != '\0'; i++) {
    if (isalpha(string[i])) {
      count_array[toupper(string[i]) - 'A']++;
    }
  }
  return count_array;
}


x86 assembly (clang, -O0):
<count_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x1a,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x1a,-0x14(%rbp)
jge    119f <count_char+0x5f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1178 <count_char+0x38>
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     121a <count_char+0xda>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%rax
je     1207 <count_char+0xc7>
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    120c <count_char+0xcc>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a6 <count_char+0x66>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_char>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x1a,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,%r14
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
xorps  %xmm0,%xmm0
movups %xmm0,(%r14)
movups %xmm0,0x10(%r14)
movups %xmm0,0x20(%r14)
movups %xmm0,0x30(%r14)
movups %xmm0,0x40(%r14)
movups %xmm0,0x50(%r14)
movq   $0x0,0x60(%r14)
mov    (%rbx),%al
test   %al,%al
je     11d0 <count_char+0x90>
add    $0x1,%rbx
jmp    11ab <count_char+0x6b>
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11d0 <count_char+0x90>
movsbl %al,%edi
call   1060 <isalpha@plt>
test   %rax,%rax
je     11a0 <count_char+0x60>
movsbl -0x1(%rbx),%edi
call   1030 <toupper@plt>
movsbq %al,%rax
addl   $0x1,-0x104(%r14,%rax,4)
ff 01
jmp    11a0 <count_char+0x60>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32* @count_char(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i64 @calloc(i32 26, i32 4)
%6 = inttoptr i64 %5 to i32*
store i32* %6, i32** %3
%7 = load i32*, i32** %3
%8 = icmp ne i32* %7, null
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
store i32 0, i32* %4
br label %11
11: ; preds = %19, %1
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 26
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = load i32*, i32** %3
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
store i32 0, i32* %18
br label %19
19: ; preds = %14
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %11
22: ; preds = %11
store i32 0, i32* %4
br label %23
23: ; preds = %54, %22
%24 = load i8*, i8** %2
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %57
31: ; preds = %23
%32 = load i8*, i8** %2
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = call i64 @isalpha(i8 signext %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %53
39: ; preds = %31
%40 = load i32*, i32** %3
%41 = load i8*, i8** %2
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8, i8* %44
%46 = call signext i8 @toupper(i8 signext %45)
%47 = sext i8 %46 to i32
%48 = sub nsw i32 %47, 65
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i32, i32* %40, i64 %49
%51 = load i32, i32* %50
%52 = add nsw i32 %51, 1
store i32 %52, i32* %50
br label %53
53: ; preds = %39, %31
br label %54
54: ; preds = %53
%55 = load i32, i32* %4
%56 = add nsw i32 %55, 1
store i32 %56, i32* %4
br label %23
57: ; preds = %23
%58 = load i32*, i32** %3
ret i32* %58
}

LLVM IR (-O2):
define i32* @count_char(i8* nocapture %0) {
%2 = tail call i64 @calloc(i32 26, i32 4)
%3 = inttoptr i64 %2 to i32*
%4 = inttoptr i64 %2 to i8*
%5 = icmp ne i64 %2, 0
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 0
br i1 %9, label %29, label %10
10: ; preds = %1, %24
%11 = phi i64 [ %25, %24 ], [ 0, %1 ]
%12 = phi i8 [ %27, %24 ], [ %8, %1 ]
%13 = phi i8* [ %26, %24 ], [ %0, %1 ]
%14 = tail call i64 @isalpha(i8 signext %12)
%15 = icmp eq i64 %14, 0
br i1 %15, label %24, label %16
16: ; preds = %10
%17 = load i8, i8* %13
%18 = tail call signext i8 @toupper(i8 signext %17)
%19 = sext i8 %18 to i64
%20 = add nsw i64 %19, -65
%21 = getelementptr inbounds i32, i32* %3, i64 %20
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 1
store i32 %23, i32* %21
br label %24
24: ; preds = %10, %16
%25 = add nuw i64 %11, 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 %10
29: ; preds = %24, %1
ret i32* %3
}