#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 calculator(char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main() {
  int helper, total = 0;
  char sentence[30];
  fgets(sentence, 30, stdin);
  for (helper = 0; helper <= strlen(sentence); helper++) {
    total = total + calculator(&sentence[helper]);
  }
  printf("%d \n", total);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x30(%rbp),%rdi
mov    0x2e87(%rip),%rax
mov    (%rax),%edx
mov    $0x1e,%esi
call   1050 <fgets@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jg     11be <main+0x7e>
mov    -0xc(%rbp),%eax
mov    %eax,-0x38(%rbp)
movslq -0x8(%rbp),%rax
lea    -0x30(%rbp),%rdi
add    %rax,%rdi
call   1060 <calculator@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1174 <main+0x34>
mov    -0xc(%rbp),%esi
lea    0xe38(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1e,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
xor    %ebp,%ebp
test   %eax,%eax
js     11a2 <main+0x62>
mov    $0xffffffffffffffff,%rbx
mov    %rsp,%r14
nopl   0x0(%rax)
lea    (%rsp,%rbx,1),%rdi
add    $0x1,%rdi
call   1060 <calculator@plt>
add    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
add    $0x1,%rbx
cmp    %rax,%rbx
jl     1180 <main+0x40>
lea    0xe57(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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