#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 */
scalar_t__ getScore(int);
int getchar();
int /*<<< orphan*/ printf(char *, ...);
void scrabbleScore(void) {
  int c, score;
  char str[100];
  printf("This program tests the ScrabbleScore function.\n");
  printf("Enter words, ending with a blank line.\n");
  while (1) {
    int i = 0;
    score = 0;
    printf("Word: ");
    while ((c = getchar()) != '\n') {
      score += getScore(c);
      str[i] = c;
      i++;
    }
    str[i] = '\0';
    if (str[0] == '\0')
      break;
    printf("The basic score for '%s' is %d.\n", str, score);
  }
}


x86 assembly (clang, -O0):
<scrabbleScore>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xeec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x4(%rbp)
cmp    $0xa,%eax
je     11b6 <scrabbleScore+0x86>
mov    -0x4(%rbp),%edi
call   1050 <getScore@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %al,%cl
movslq -0x74(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1173 <scrabbleScore+0x43>
movslq -0x74(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
movsbl -0x70(%rbp),%eax
cmp    $0x0,%eax
jne    11d1 <scrabbleScore+0xa1>
jmp    11eb <scrabbleScore+0xbb>
lea    -0x70(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1157 <scrabbleScore+0x27>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scrabbleScore>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xed3(%rip),%rdi
call   1030 <puts@plt>
lea    0xef6(%rip),%rdi
call   1030 <puts@plt>
lea    0xe93(%rip),%r12
lea    0xe93(%rip),%r14
mov    %rsp,%r15
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%eax
jne    11a0 <scrabbleScore+0x60>
xor    %r13d,%r13d
xor    %ebp,%ebp
jmp    11cf <scrabbleScore+0x8f>
nopl   (%rax)
mov    %eax,%ebx
xor    %ebp,%ebp
xor    %r13d,%r13d
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1060 <getScore@plt>
add    %eax,%r13d
mov    %bl,(%rsp,%rbp,1)
add    $0x1,%rbp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
cmp    $0xa,%eax
jne    11b0 <scrabbleScore+0x70>
mov    %ebp,%eax
movb   $0x0,(%rsp,%rax,1)
cmpb   $0x0,(%rsp)
je     11ed <scrabbleScore+0xad>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1180 <scrabbleScore+0x40>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"This program tests the ScrabbleScore function.\0A\00"
@.str.1 = [40 x i8] c"Enter words, ending with a blank line.\0A\00"
@.str.2 = [7 x i8] c"Word: \00"
@.str.3 = [33 x i8] c"The basic score for '%s' is %d.\0A\00"
define void @scrabbleScore() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %0, %35
store i32 0, i32* %4
store i32 0, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %12, %7
%10 = call i32 (...) @getchar()
store i32 %10, i32* %1
%11 = icmp ne i32 %10, 10
br i1 %11, label %12, label %26
12: ; preds = %9
%13 = load i32, i32* %1
%14 = call i64 @getScore(i32 %13)
%15 = load i32, i32* %2
%16 = sext i32 %15 to i64
%17 = add nsw i64 %16, %14
%18 = trunc i64 %17 to i32
store i32 %18, i32* %2
%19 = load i32, i32* %1
%20 = trunc i32 %19 to i8
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %22
store i8 %20, i8* %23
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %9
26: ; preds = %9
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %28
store i8 0, i8* %29
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %26
br label %39
35: ; preds = %26
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%37 = load i32, i32* %2
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %36, i32 %37)
br label %7
39: ; preds = %34
ret void
}

LLVM IR (-O2):
@.str.2 = [7 x i8] c"Word: \00"
@.str.3 = [33 x i8] c"The basic score for '%s' is %d.\0A\00"
@str = [47 x i8] c"This program tests the ScrabbleScore function.\00"
@str.4 = [39 x i8] c"Enter words, ending with a blank line.\00"
define void @scrabbleScore() {
%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 ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.4, i64 0, i64 0))
br label %5
5: ; preds = %28, %0
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 (...) @getchar()
%8 = icmp eq i32 %7, 10
br i1 %8, label %21, label %9
9: ; preds = %5, %9
%10 = phi i64 [ %18, %9 ], [ 0, %5 ]
%11 = phi i32 [ %19, %9 ], [ %7, %5 ]
%12 = phi i32 [ %15, %9 ], [ 0, %5 ]
%13 = call i64 @getScore(i32 %11)
%14 = trunc i64 %13 to i32
%15 = add i32 %12, %14
%16 = trunc i32 %11 to i8
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %10
store i8 %16, i8* %17
%18 = add nuw i64 %10, 1
%19 = call i32 (...) @getchar()
%20 = icmp eq i32 %19, 10
br i1 %20, label %21, label %9
21: ; preds = %9, %5
%22 = phi i32 [ 0, %5 ], [ %15, %9 ]
%23 = phi i64 [ 0, %5 ], [ %18, %9 ]
%24 = and i64 %23, 4294967295
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %24
store i8 0, i8* %25
%26 = load i8, i8* %2
%27 = icmp eq i8 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %21
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %2, i32 %22)
br label %5
30: ; preds = %21
ret void
}