#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 getchar();
scalar_t__ isalpha(int);
int /*<<< orphan*/ printf(char *);
int toupper(int);
void read_word(int word[]) {
  int letter;
  printf("Enter a word: ");
  while ((letter = getchar()) != '\n') {
    if (isalpha(letter)) {
      letter = toupper(letter);
      word[letter - 65] += 1;
    } else {
      continue;
    }
  }
}


x86 assembly (clang, -O0):
<read_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xead(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xa,%eax
je     11ad <read_word+0x6d>
mov    -0xc(%rbp),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%rax
je     11a3 <read_word+0x63>
mov    -0xc(%rbp),%edi
call   1030 <toupper@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x41,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
jmp    11a8 <read_word+0x68>
jmp    1158 <read_word+0x18>
jmp    1158 <read_word+0x18>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_word>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xeb3(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%eax
jne    1165 <read_word+0x25>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %eax,%ebp
jmp    117e <read_word+0x3e>
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
cmp    $0xa,%eax
je     115e <read_word+0x1e>
mov    %ebp,%edi
call   1060 <isalpha@plt>
test   %rax,%rax
je     1170 <read_word+0x30>
mov    %ebp,%edi
call   1030 <toupper@plt>
cltq
addl   $0x1,-0x104(%rbx,%rax,4)
01
jmp    1170 <read_word+0x30>

LLVM IR (-O0):
@.str = [15 x i8] c"Enter a word: \00"
define void @read_word(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %23, %22, %1
%6 = call i32 (...) @getchar()
store i32 %6, i32* %3
%7 = icmp ne i32 %6, 10
br i1 %7, label %8, label %24
8: ; preds = %5
%9 = load i32, i32* %3
%10 = call i64 @isalpha(i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %8
%13 = load i32, i32* %3
%14 = call i32 @toupper(i32 %13)
store i32 %14, i32* %3
%15 = load i32*, i32** %2
%16 = load i32, i32* %3
%17 = sub nsw i32 %16, 65
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %15, i64 %18
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1
store i32 %21, i32* %19
br label %23
22: ; preds = %8
br label %5
23: ; preds = %12
br label %5
24: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"Enter a word: \00"
define void @read_word(i32* nocapture %0) {
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 (...) @getchar()
%4 = icmp eq i32 %3, 10
br i1 %4, label %19, label %5
5: ; preds = %1, %16
%6 = phi i32 [ %17, %16 ], [ %3, %1 ]
%7 = tail call i64 @isalpha(i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %5
%10 = tail call i32 @toupper(i32 %6)
%11 = add nsw i32 %10, -65
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %0, i64 %12
%14 = load i32, i32* %13
%15 = add nsw i32 %14, 1
store i32 %15, i32* %13
br label %16
16: ; preds = %9, %5
%17 = tail call i32 (...) @getchar()
%18 = icmp eq i32 %17, 10
br i1 %18, label %19, label %5
19: ; preds = %16, %1
ret void
}