#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 /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, char **);
int main() {
  char number[5];
  int sum = 0;
  scanf("%s", &number);
  for (int i = 0; i < 5; i++)
    sum += (int)number[i];
  printf("%d", sum - 5 * (int)'0');
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x9(%rbp),%rsi
lea    0xebf(%rip),%rdi
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    1174 <main+0x54>
movslq -0x14(%rbp),%rax
movsbl -0x9(%rbp,%rax,1),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <main+0x2d>
mov    -0x10(%rbp),%esi
sub    $0xf0,%esi
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
lea    0x3(%rsp),%rsi
call   1040 <scanf@plt>
movsbl 0x3(%rsp),%eax
movsbl 0x4(%rsp),%ecx
add    %eax,%ecx
movsbl 0x5(%rsp),%eax
add    %ecx,%eax
movsbl 0x6(%rsp),%ecx
add    %eax,%ecx
movsbl 0x7(%rsp),%eax
lea    (%rax,%rcx,1),%esi
add    $0xffffff10,%esi
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%3 = bitcast [5 x i8]* %1 to i8**
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %3)
%5 = load i8, i8* %2
%6 = sext i8 %5 to i32
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 1
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = add nsw i32 %6, %9
%11 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 2
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = add nsw i32 %10, %13
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 3
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = add nsw i32 %14, %17
%19 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 4
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = add nsw i32 %18, %21
%23 = add nsw i32 %22, -240
%24 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %23)
ret i32 0
}