#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 key_sum(char);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  int n, sum = 0;
  char sentence[160];
  scanf("%[^\n]s", sentence);
  for (n = 0; n < strlen(sentence); n++) {
    sum = sum + key_sum(sentence[n]);
  }
  printf("%d \n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0xb0(%rbp),%rsi
lea    0xe99(%rip),%rdi
call   1050 <scanf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xb4(%rbp)
lea    -0xb0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xb4(%rbp),%eax
cmp    %ecx,%eax
jge    11cd <main+0x8d>
mov    -0xc(%rbp),%eax
mov    %eax,-0xb8(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0xb0(%rbp,%rax,1),%edi
ff
call   1060 <key_sum@plt>
mov    %eax,%ecx
mov    -0xb8(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1173 <main+0x33>
mov    -0xc(%rbp),%esi
lea    0xe30(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0xa0,%rsp
lea    0xeae(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1190 <main+0x50>
xor    %ebx,%ebx
mov    %rsp,%r14
xor    %ebp,%ebp
movsbl (%rsp,%rbx,1),%edi
call   1060 <key_sum@plt>
add    %eax,%ebp
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1170 <main+0x30>
jmp    1192 <main+0x52>
xor    %ebp,%ebp
lea    0xe6e(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%[^\0A]s\00"
@.str.1 = [5 x i8] c"%d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [160 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
%5 = getelementptr inbounds [160 x i8], [160 x i8]* %4, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %5)
store i32 0, i32* %2
br label %7
7: ; preds = %20, %0
%8 = load i32, i32* %2
%9 = getelementptr inbounds [160 x i8], [160 x i8]* %4, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %23
12: ; preds = %7
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [160 x i8], [160 x i8]* %4, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = call i32 @key_sum(i8 signext %17)
%19 = add nsw i32 %13, %18
store i32 %19, i32* %3
br label %20
20: ; preds = %12
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %7
23: ; preds = %7
%24 = load i32, i32* %3
%25 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%[^\0A]s\00"
@.str.1 = [5 x i8] c"%d \0A\00"
define i32 @main() {
%1 = alloca [160 x i8]
%2 = getelementptr inbounds [160 x i8], [160 x i8]* %1, i64 0, i64 0
%3 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i32 @strlen(i8* %2)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %0, %6
%7 = phi i64 [ %13, %6 ], [ 0, %0 ]
%8 = phi i32 [ %12, %6 ], [ 0, %0 ]
%9 = getelementptr inbounds [160 x i8], [160 x i8]* %1, i64 0, i64 %7
%10 = load i8, i8* %9
%11 = call i32 @key_sum(i8 signext %10)
%12 = add nsw i32 %11, %8
%13 = add nuw nsw i64 %7, 1
%14 = call i32 @strlen(i8* %2)
%15 = sext i32 %14 to i64
%16 = icmp slt i64 %13, %15
br i1 %16, label %6, label %17
17: ; preds = %6, %0
%18 = phi i32 [ 0, %0 ], [ %12, %6 ]
%19 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %18)
ret i32 0
}