#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(void) {
  char alphabet[27] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                       'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                       's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '\0'};
  char words[100];
  int i = 0;
  int j = 0;
  int sum;
  printf("\nPlease Enter a sentence:\n");
  fgets(words, 100, stdin);
  printf("\nYour sentence contains: \n");
  for (i = 0; alphabet[i] != '\0'; i++) {
    sum = 0;
    for (j = 0; words[j] != '\0'; j++) {
      if (alphabet[i] == words[j]) {
        sum = sum + 1;
      }
    }
    printf("%c: %d\n", alphabet[i], sum);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xebe(%rip),%ax
mov    %ax,-0x8(%rbp)
mov    0xeb6(%rip),%al
mov    %al,-0x6(%rbp)
movl   $0x0,-0x94(%rbp)
movl   $0x0,-0x98(%rbp)
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    0x2e51(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1040 <fgets@plt>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x94(%rbp)
movslq -0x94(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     127b <main+0x15b>
movl   $0x0,-0x9c(%rbp)
movl   $0x0,-0x98(%rbp)
movslq -0x98(%rbp),%rax
movsbl -0x90(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1247 <main+0x127>
movslq -0x94(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
movslq -0x98(%rbp),%rcx
movsbl -0x90(%rbp,%rcx,1),%ecx
ff
cmp    %ecx,%eax
jne    122e <main+0x10e>
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c(%rbp)
jmp    1233 <main+0x113>
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    11e4 <main+0xc4>
movslq -0x94(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%esi
mov    -0x9c(%rbp),%edx
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    11bb <main+0x9b>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xee1(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e9a(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x64,%esi
call   1050 <fgets@plt>
lea    0xed9(%rip),%rdi
call   1030 <puts@plt>
lea    0x1(%rsp),%r14
lea    0xe8b(%rip),%r15
lea    0xe9f(%rip),%r12
xor    %ebx,%ebx
jmp    1194 <main+0x64>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x1a,%rbx
je     11c8 <main+0x98>
mov    (%rsp),%al
movsbl (%rbx,%r15,1),%esi
mov    $0x0,%edx
test   %al,%al
je     1180 <main+0x50>
xor    %edx,%edx
mov    %r14,%rcx
nopw   0x0(%rax,%rax,1)
xor    %edi,%edi
cmp    %al,%sil
sete   %dil
add    %edi,%edx
movzbl (%rcx),%eax
add    $0x1,%rcx
test   %al,%al
jne    11b0 <main+0x80>
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.alphabet = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
@.str = [27 x i8] c"\0APlease Enter a sentence:\0A\00"
@stdin = global i32 0
@.str.1 = [27 x i8] c"\0AYour sentence contains: \0A\00"
@.str.2 = [8 x i8] c"%c: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [27 x i8]
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [27 x i8]* %2 to i8*
store i32 0, i32* %4
store i32 0, i32* %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %9, i32 100, i32 %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %13
13: ; preds = %55, %0
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [27 x i8], [27 x i8]* %2, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %58
20: ; preds = %13
store i32 0, i32* %6
store i32 0, i32* %5
br label %21
21: ; preds = %44, %20
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %47
28: ; preds = %21
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [27 x i8], [27 x i8]* %2, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %33, %38
br i1 %39, label %40, label %43
40: ; preds = %28
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
br label %43
43: ; preds = %40, %28
br label %44
44: ; preds = %43
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %21
47: ; preds = %21
%48 = load i32, i32* %4
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [27 x i8], [27 x i8]* %2, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = load i32, i32* %6
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %52, i32 %53)
br label %55
55: ; preds = %47
%56 = load i32, i32* %4
%57 = add nsw i32 %56, 1
store i32 %57, i32* %4
br label %13
58: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@__const.main.alphabet = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
@stdin = global i32 0
@.str.2 = [8 x i8] c"%c: %d\0A\00"
@str = [26 x i8] c"\0APlease Enter a sentence:\00"
@str.3 = [26 x i8] c"\0AYour sentence contains: \00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %2, i32 100, i32 %4)
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.3, i64 0, i64 0))
br label %7
7: ; preds = %0, %24
%8 = phi i64 [ 0, %0 ], [ %28, %24 ]
%9 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @__const.main.alphabet, i64 0, i64 0), %0 ], [ %29, %24 ]
%10 = load i8, i8* %2
%11 = icmp eq i8 %10, 0
%12 = load i8, i8* %9
br i1 %11, label %24, label %13
13: ; preds = %7, %13
%14 = phi i64 [ %20, %13 ], [ 0, %7 ]
%15 = phi i8 [ %22, %13 ], [ %10, %7 ]
%16 = phi i32 [ %19, %13 ], [ 0, %7 ]
%17 = icmp eq i8 %12, %15
%18 = zext i1 %17 to i32
%19 = add nuw nsw i32 %16, %18
%20 = add nuw nsw i64 %14, 1
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %13
24: ; preds = %13, %7
%25 = phi i32 [ 0, %7 ], [ %19, %13 ]
%26 = sext i8 %12 to i32
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %26, i32 %25)
%28 = add nuw nsw i64 %8, 1
%29 = getelementptr inbounds [27 x i8], [27 x i8]* @__const.main.alphabet, i64 0, i64 %28
%30 = icmp eq i64 %28, 26
br i1 %30, label %31, label %7
31: ; preds = %24
ret i32 0
}