#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char string[100];
  int c = 0, count[26] = {0};
  printf("Enter a string\n");
  gets(string);
  while (string[c] != '\0') {
    if (string[c] >= 'a' && string[c] <= 'z')
      count[string[c] - 'a']++;
    c++;
  }
  for (c = 0; c < 26; c++) {
    if (count[c] != 0)
      printf("%c occurs %d times in the entered string.\n", c + 'a', count[c]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x74(%rbp)
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x68,%edx
call   1040 <memset@plt>
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1050 <gets@plt>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11d6 <main+0xa6>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x61,%eax
jl     11c8 <main+0x98>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x7a,%eax
jg     11c8 <main+0x98>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
sub    $0x61,%eax
cltq
mov    -0xe0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0xe0(%rbp,%rax,4)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1173 <main+0x43>
movl   $0x0,-0x74(%rbp)
cmpl   $0x1a,-0x74(%rbp)
jge    122b <main+0xfb>
movslq -0x74(%rbp),%rax
cmpl   $0x0,-0xe0(%rbp,%rax,4)
je     1218 <main+0xe8>
mov    -0x74(%rbp),%esi
add    $0x61,%esi
movslq -0x74(%rbp),%rax
mov    -0xe0(%rbp,%rax,4),%edx
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121d <main+0xed>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    11dd <main+0xad>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xd8,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0x60(%rsp)
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
lea    0x70(%rsp),%rdi
call   1050 <gets@plt>
mov    0x70(%rsp),%cl
test   %cl,%cl
je     11af <main+0x7f>
lea    0x71(%rsp),%rax
jmp    119b <main+0x6b>
nopl   0x0(%rax,%rax,1)
movzbl (%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
je     11af <main+0x7f>
lea    -0x61(%rcx),%edx
cmp    $0x19,%dl
ja     1190 <main+0x60>
movzbl %cl,%ecx
add    $0xffffff9f,%ecx
addl   $0x1,(%rsp,%rcx,4)
jmp    1190 <main+0x60>
lea    0xe4a(%rip),%r14
xor    %ebx,%ebx
jmp    11ca <main+0x9a>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x1a,%rbx
je     11e0 <main+0xb0>
mov    (%rsp,%rbx,4),%edx
test   %edx,%edx
je     11c0 <main+0x90>
lea    0x61(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11c0 <main+0x90>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Enter a string\0A\00"
@.str.1 = [43 x i8] c"%c occurs %d times in the entered string.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca [26 x i32]
store i32 0, i32* %1
store i32 0, i32* %3
%5 = bitcast [26 x i32]* %4 to i8*
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%8 = call i32 @gets(i8* %7)
br label %9
9: ; preds = %41, %0
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %44
16: ; preds = %9
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp sge i32 %21, 97
br i1 %22, label %23, label %41
23: ; preds = %16
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp sle i32 %28, 122
br i1 %29, label %30, label %41
30: ; preds = %23
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = sub nsw i32 %35, 97
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = add nsw i32 %39, 1
store i32 %40, i32* %38
br label %41
41: ; preds = %30, %23, %16
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 1
store i32 %43, i32* %3
br label %9
44: ; preds = %9
store i32 0, i32* %3
br label %45
45: ; preds = %63, %44
%46 = load i32, i32* %3
%47 = icmp slt i32 %46, 26
br i1 %47, label %48, label %66
48: ; preds = %45
%49 = load i32, i32* %3
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 %50
%52 = load i32, i32* %51
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %62
54: ; preds = %48
%55 = load i32, i32* %3
%56 = add nsw i32 %55, 97
%57 = load i32, i32* %3
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 %58
%60 = load i32, i32* %59
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %56, i32 %60)
br label %62
62: ; preds = %54, %48
br label %63
63: ; preds = %62
%64 = load i32, i32* %3
%65 = add nsw i32 %64, 1
store i32 %65, i32* %3
br label %45
66: ; preds = %45
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [43 x i8] c"%c occurs %d times in the entered string.\0A\00"
@str = [15 x i8] c"Enter a string\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [26 x i32]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = bitcast [26 x i32]* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%6 = call i32 @gets(i8* %3)
%7 = load i8, i8* %3
%8 = icmp eq i8 %7, 0
br i1 %8, label %26, label %9
9: ; preds = %0, %21
%10 = phi i64 [ %22, %21 ], [ 0, %0 ]
%11 = phi i8 [ %24, %21 ], [ %7, %0 ]
%12 = add i8 %11, -97
%13 = icmp ult i8 %12, 26
br i1 %13, label %14, label %21
14: ; preds = %9
%15 = zext i8 %11 to i64
%16 = add nuw nsw i64 %15, 4294967199
%17 = and i64 %16, 4294967295
%18 = getelementptr inbounds [26 x i32], [26 x i32]* %2, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = add nsw i32 %19, 1
store i32 %20, i32* %18
br label %21
21: ; preds = %14, %9
%22 = add nuw i64 %10, 1
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %9
26: ; preds = %21, %0
br label %27
27: ; preds = %26, %36
%28 = phi i64 [ %37, %36 ], [ 0, %26 ]
%29 = getelementptr inbounds [26 x i32], [26 x i32]* %2, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 0
br i1 %31, label %36, label %32
32: ; preds = %27
%33 = trunc i64 %28 to i32
%34 = add i32 %33, 97
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %34, i32 %30)
br label %36
36: ; preds = %27, %32
%37 = add nuw nsw i64 %28, 1
%38 = icmp eq i64 %37, 26
br i1 %38, label %39, label %27
39: ; preds = %36
ret i32 0
}