#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 *, long);
scalar_t__ scanf(char *, char *);
int main(int argc, char const *argv[]) {
  long sum = 0;
  int index = 0;
  char num;
  while (scanf("%c", &num) != 0) {
    if (num == ' ')
      continue;
    else if (num == '0')
      break;
    sum += num - '0';
    index++;
  }
  long totalSum = ((index + 1) * (index + 2)) / 2;
  printf("%li\n", (totalSum - sum));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xeb4(%rip),%rdi
lea    -0x1d(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x0,%rax
je     11a7 <main+0x87>
movsbl -0x1d(%rbp),%eax
cmp    $0x20,%eax
jne    1171 <main+0x51>
jmp    1145 <main+0x25>
movsbl -0x1d(%rbp),%eax
cmp    $0x30,%eax
jne    1183 <main+0x63>
jmp    11a7 <main+0x87>
jmp    1188 <main+0x68>
movsbl -0x1d(%rbp),%eax
sub    $0x30,%eax
cltq
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1145 <main+0x25>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    -0x1c(%rbp),%ecx
add    $0x2,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
sub    -0x18(%rbp),%rsi
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %r12d,%r12d
lea    0xece(%rip),%r14
lea    0x7(%rsp),%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
test   %rax,%rax
je     116c <main+0x4c>
movsbq 0x7(%rsp),%rax
cmp    $0x20,%rax
je     1140 <main+0x20>
cmp    $0x30,%al
je     116c <main+0x4c>
add    %rax,%r12
add    $0xffffffffffffffd0,%r12
add    $0x1,%ebx
jmp    1140 <main+0x20>
lea    0x1(%rbx),%eax
add    $0x2,%ebx
imul   %eax,%ebx
shr    %ebx
sub    %r12,%rbx
lea    0xe82(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@.str.1 = [5 x i8] c"%li\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8
br label %4
4: ; preds = %12, %2
%5 = phi i64 [ %15, %12 ], [ 0, %2 ]
%6 = phi i32 [ %16, %12 ], [ 0, %2 ]
br label %7
7: ; preds = %4, %10
%8 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%9 = icmp eq i64 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %7
%11 = load i8, i8* %3
switch i8 %11, label %12 [
i8 32, label %7
i8 48, label %17
]
12: ; preds = %10
%13 = sext i8 %11 to i64
%14 = add i64 %5, -48
%15 = add i64 %14, %13
%16 = add nuw nsw i32 %6, 1
br label %4
17: ; preds = %10, %7
%18 = add nuw nsw i32 %6, 1
%19 = add nuw nsw i32 %6, 2
%20 = mul nsw i32 %18, %19
%21 = lshr i32 %20, 1
%22 = zext i32 %21 to i64
%23 = sub nsw i64 %22, %5
%24 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %23)
ret i32 0
}