#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int toupper(char);
int main(void) {
  int sum = 0;
  char input;
  printf("Enter a word: ");
  while ((input = getchar()) != '\n') {
    switch (toupper(input)) {
    case 'D':
    case 'G':
      sum += 2;
      break;
    case 'B':
    case 'C':
    case 'M':
    case 'P':
      sum += 3;
      break;
    case 'F':
    case 'H':
    case 'V':
    case 'W':
    case 'Y':
      sum += 4;
      break;
    case 'K':
      sum += 5;
      break;
    case 'J':
    case 'X':
      sum += 8;
      break;
    case 'Q':
    case 'Z':
      sum += 10;
      break;
    default:
      sum++;
      break;
    }
  }
  printf("Scrabble value: %d\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xf17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x9(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     11fb <main+0xcb>
movsbl -0x9(%rbp),%edi
call   1030 <toupper@plt>
add    $0xffffffbe,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x18,%eax
ja     11ed <main+0xbd>
mov    -0x18(%rbp),%rax
lea    0xe70(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
jmp    11f6 <main+0xc6>
mov    -0x8(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x8(%rbp)
jmp    11f6 <main+0xc6>
mov    -0x8(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x8(%rbp)
jmp    11f6 <main+0xc6>
mov    -0x8(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x8(%rbp)
jmp    11f6 <main+0xc6>
mov    -0x8(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x8(%rbp)
jmp    11f6 <main+0xc6>
mov    -0x8(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x8(%rbp)
jmp    11f6 <main+0xc6>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1154 <main+0x24>
mov    -0x8(%rbp),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    1169 <main+0x39>
lea    0xeb9(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xeb4(%rip),%r14
xor    %ebx,%ebx
jmp    118d <main+0x5d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    %ecx,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     114f <main+0x1f>
movsbl %al,%edi
call   1030 <toupper@plt>
add    $0xffffffbe,%eax
mov    $0x1,%ecx
cmp    $0x18,%eax
ja     1180 <main+0x50>
cltq
mov    (%r14,%rax,4),%ecx
jmp    1180 <main+0x50>

LLVM IR (-O0):
@.str = [15 x i8] c"Enter a word: \00"
@.str.1 = [20 x i8] c"Scrabble value: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %33, %0
%6 = call signext i8 (...) @getchar()
store i8 %6, i8* %3
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 10
br i1 %8, label %9, label %34
9: ; preds = %5
%10 = load i8, i8* %3
%11 = call i32 @toupper(i8 signext %10)
switch i32 %11, label %30 [
i32 68, label %12
i32 71, label %12
i32 66, label %15
i32 67, label %15
i32 77, label %15
i32 80, label %15
i32 70, label %18
i32 72, label %18
i32 86, label %18
i32 87, label %18
i32 89, label %18
i32 75, label %21
i32 74, label %24
i32 88, label %24
i32 81, label %27
i32 90, label %27
]
12: ; preds = %9, %9
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 2
store i32 %14, i32* %2
br label %33
15: ; preds = %9, %9, %9, %9
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 3
store i32 %17, i32* %2
br label %33
18: ; preds = %9, %9, %9, %9, %9
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 4
store i32 %20, i32* %2
br label %33
21: ; preds = %9
%22 = load i32, i32* %2
%23 = add nsw i32 %22, 5
store i32 %23, i32* %2
br label %33
24: ; preds = %9, %9
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 8
store i32 %26, i32* %2
br label %33
27: ; preds = %9, %9
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 10
store i32 %29, i32* %2
br label %33
30: ; preds = %9
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %33
33: ; preds = %30, %27, %24, %21, %18, %15, %12
br label %5
34: ; preds = %5
%35 = load i32, i32* %2
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %35)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"Enter a word: \00"
@.str.1 = [20 x i8] c"Scrabble value: %d\0A\00"
@switch.table.main = [25 x i32] [i32 3, i32 3, i32 2, i32 1, i32 4, i32 2, i32 4, i32 1, i32 8, i32 5, i32 1, i32 3, i32 1, i32 1, i32 3, i32 10, i32 1, i32 1, i32 1, i32 1, i32 4, i32 4, i32 8, i32 4, i32 10]
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%2 = tail call signext i8 (...) @getchar()
%3 = icmp eq i8 %2, 10
br i1 %3, label %19, label %4
4: ; preds = %0, %14
%5 = phi i8 [ %17, %14 ], [ %2, %0 ]
%6 = phi i32 [ %16, %14 ], [ 0, %0 ]
%7 = tail call i32 @toupper(i8 signext %5)
%8 = add i32 %7, -66
%9 = icmp ult i32 %8, 25
br i1 %9, label %10, label %14
10: ; preds = %4
%11 = sext i32 %8 to i64
%12 = getelementptr inbounds [25 x i32], [25 x i32]* @switch.table.main, i64 0, i64 %11
%13 = load i32, i32* %12
br label %14
14: ; preds = %4, %10
%15 = phi i32 [ %13, %10 ], [ 1, %4 ]
%16 = add nuw nsw i32 %6, %15
%17 = tail call signext i8 (...) @getchar()
%18 = icmp eq i8 %17, 10
br i1 %18, label %19, label %4
19: ; preds = %14, %0
%20 = phi i32 [ 0, %0 ], [ %16, %14 ]
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %20)
ret i32 0
}