#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 lett_to_num(char);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  int n = 0, temp = 0;
  int num = 0;
  char c;
  char mess[160];
  while (c != '\n') {
    scanf("%c", &c);
    mess[n] = c;
    n++;
  }
  n = strlen(mess);
  for (n = n - 1; n >= 0; n--) {
    temp = lett_to_num(mess[n]);
    num += temp;
  }
  printf("%d\n", num);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
je     11a0 <main+0x60>
lea    0xe85(%rip),%rdi
lea    -0x11(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x11(%rbp),%cl
movslq -0x8(%rbp),%rax
mov    %cl,-0xc0(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1167 <main+0x27>
lea    -0xc0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     11ed <main+0xad>
movslq -0x8(%rbp),%rax
movsbl -0xc0(%rbp,%rax,1),%edi
ff
call   1060 <lett_to_num@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    11b8 <main+0x78>
mov    -0x10(%rbp),%esi
lea    0xe0c(%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    $0xb0,%rsp
lea    0x10(%rsp),%rbp
lea    0xea9(%rip),%r14
lea    0xf(%rsp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movzbl 0xf(%rsp),%eax
mov    %al,0x0(%rbp)
add    $0x1,%rbp
cmp    $0xa,%al
jne    1160 <main+0x20>
lea    0x10(%rsp),%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11bb <main+0x7b>
mov    %eax,%ebx
add    $0x1,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    -0x2(%rbx),%eax
movsbl 0x10(%rsp,%rax,1),%edi
call   1060 <lett_to_num@plt>
add    %eax,%ebp
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     11a0 <main+0x60>
jmp    11bd <main+0x7d>
xor    %ebp,%ebp
lea    0xe3f(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca [160 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %7
7: ; preds = %11, %0
%8 = load i8, i8* %5
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 10
br i1 %10, label %11, label %19
11: ; preds = %7
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%13 = load i8, i8* %5
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [160 x i8], [160 x i8]* %6, i64 0, i64 %15
store i8 %13, i8* %16
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %7
19: ; preds = %7
%20 = getelementptr inbounds [160 x i8], [160 x i8]* %6, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
store i32 %21, i32* %2
%22 = load i32, i32* %2
%23 = sub nsw i32 %22, 1
store i32 %23, i32* %2
br label %24
24: ; preds = %36, %19
%25 = load i32, i32* %2
%26 = icmp sge i32 %25, 0
br i1 %26, label %27, label %39
27: ; preds = %24
%28 = load i32, i32* %2
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [160 x i8], [160 x i8]* %6, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = call i32 @lett_to_num(i8 signext %31)
store i32 %32, i32* %3
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = add nsw i32 %34, %33
store i32 %35, i32* %4
br label %36
36: ; preds = %27
%37 = load i32, i32* %2
%38 = add nsw i32 %37, -1
store i32 %38, i32* %2
br label %24
39: ; preds = %24
%40 = load i32, i32* %4
%41 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %40)
ret i32 0
}

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