#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__ Numbervalue(char);
char getchar();
int /*<<< orphan*/ printf(char *, int);
int strlen(char *);
int main() {
  char sentence[160], ch;
  int i = 0, s = 0;
  while ((ch = getchar()) != '\n') {
    sentence[i] = ch;
    i++;
  }
  for (i = 0; i < strlen(sentence); i++) {
    s += Numbervalue(sentence[i]);
  }
  printf("\n%d", s);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xb8(%rbp)
movl   $0x0,-0xbc(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0xb1(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     11a7 <main+0x67>
mov    -0xb1(%rbp),%cl
movslq -0xb8(%rbp),%rax
mov    %cl,-0xb0(%rbp,%rax,1)
mov    -0xb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb8(%rbp)
jmp    1166 <main+0x26>
movl   $0x0,-0xb8(%rbp)
mov    -0xb8(%rbp),%eax
mov    %eax,-0xc0(%rbp)
lea    -0xb0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xc0(%rbp),%eax
cmp    %ecx,%eax
jge    1214 <main+0xd4>
movslq -0xb8(%rbp),%rax
movsbl -0xb0(%rbp,%rax,1),%edi
ff
call   1040 <Numbervalue@plt>
mov    %rax,%rcx
movslq -0xbc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xbc(%rbp)
mov    -0xb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb8(%rbp)
jmp    11b1 <main+0x71>
mov    -0xbc(%rbp),%esi
lea    0xddf(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0xa0,%rsp
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%al
je     1171 <main+0x31>
mov    %rsp,%rbx
nopl   0x0(%rax,%rax,1)
mov    %al,(%rbx)
xor    %eax,%eax
call   1060 <getchar@plt>
add    $0x1,%rbx
cmp    $0xa,%al
jne    1160 <main+0x20>
mov    %rsp,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11ae <main+0x6e>
xor    %ebx,%ebx
mov    %rsp,%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%rsp,%rbx,1),%edi
call   1040 <Numbervalue@plt>
add    %eax,%ebp
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1190 <main+0x50>
lea    0xe4b(%rip),%rdi
mov    %ebp,%esi
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0xa0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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