#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__ EOF;
scalar_t__ getButtonIndex(char);
int getCharIndex(char);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, char *);
int strlen(char *);
int main() {
  int len, i, j, tap;
  char line[120];
  while (scanf("%s", line) != EOF) {
    len = strlen(line);
    tap = getCharIndex(line[0]);
    for (i = 1; i < len; i++) {
      if (getButtonIndex(line[i]) == getButtonIndex(line[i - 1]))
        tap = tap + getCharIndex(line[i]) + 2;
      else
        tap += getCharIndex(line[i]);
    }
    printf("%d\n", tap);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rsi
lea    0xe90(%rip),%rdi
call   1070 <scanf@plt>
mov    0x2e6c(%rip),%rcx
cmp    (%rcx),%rax
je     1263 <main+0x113>
lea    -0x90(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x8(%rbp)
movsbl -0x90(%rbp),%edi
call   1060 <getCharIndex@plt>
mov    %eax,-0x14(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    124f <main+0xff>
movslq -0xc(%rbp),%rax
movsbl -0x90(%rbp,%rax,1),%edi
ff
call   1030 <getButtonIndex@plt>
mov    %rax,-0x98(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x90(%rbp,%rax,1),%edi
ff
call   1030 <getButtonIndex@plt>
mov    %rax,%rcx
mov    -0x98(%rbp),%rax
cmp    %rcx,%rax
jne    1225 <main+0xd5>
mov    -0x14(%rbp),%eax
mov    %eax,-0x9c(%rbp)
movslq -0xc(%rbp),%rax
movsbl -0x90(%rbp,%rax,1),%edi
ff
call   1060 <getCharIndex@plt>
mov    %eax,%ecx
mov    -0x9c(%rbp),%eax
add    %ecx,%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    123c <main+0xec>
movslq -0xc(%rbp),%rax
movsbl -0x90(%rbp,%rax,1),%edi
ff
call   1060 <getCharIndex@plt>
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1241 <main+0xf1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11aa <main+0x5a>
mov    -0x14(%rbp),%esi
lea    0xdaa(%rip),%rdi
call   1050 <printf@plt>
jmp    1162 <main+0x12>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xe9b(%rip),%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
mov    0x2e74(%rip),%rcx
cmp    (%rcx),%rax
jne    118a <main+0x3a>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%r12
jmp    11b9 <main+0x69>
nop
mov    %ebx,%esi
lea    0xe6a(%rip),%rdi
call   1050 <printf@plt>
lea    0xe5b(%rip),%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    0x2e34(%rip),%rcx
cmp    (%rcx),%rax
je     1179 <main+0x29>
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
movsbl (%rsp),%edi
call   1060 <getCharIndex@plt>
mov    %eax,%ebx
cmp    $0x2,%ebp
jl     1190 <main+0x40>
mov    %ebp,%r15d
mov    $0x1,%r14d
nopl   0x0(%rax)
movsbl (%rsp,%r14,1),%edi
call   1030 <getButtonIndex@plt>
mov    %rax,%r13
movsbl -0x1(%rsp,%r14,1),%edi
call   1030 <getButtonIndex@plt>
mov    %rax,%rbp
movsbl (%rsp,%r14,1),%edi
call   1060 <getCharIndex@plt>
lea    0x2(%rbx),%esi
cmp    %rbp,%r13
cmovne %ebx,%esi
add    %eax,%esi
add    $0x1,%r14
mov    %esi,%ebx
cmp    %r14,%r15
jne    11e0 <main+0x90>
jmp    1192 <main+0x42>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@EOF = global i64 0
@.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 i32
%6 = alloca [120 x i8]
store i32 0, i32* %1
br label %7
7: ; preds = %56, %0
%8 = getelementptr inbounds [120 x i8], [120 x i8]* %6, i64 0, i64 0
%9 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i64, i64* @EOF
%11 = icmp ne i64 %9, %10
br i1 %11, label %12, label %59
12: ; preds = %7
%13 = getelementptr inbounds [120 x i8], [120 x i8]* %6, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %2
%15 = getelementptr inbounds [120 x i8], [120 x i8]* %6, i64 0, i64 0
%16 = load i8, i8* %15
%17 = call i32 @getCharIndex(i8 signext %16)
store i32 %17, i32* %5
store i32 1, i32* %3
br label %18
18: ; preds = %53, %12
%19 = load i32, i32* %3
%20 = load i32, i32* %2
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %56
22: ; preds = %18
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [120 x i8], [120 x i8]* %6, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = call i64 @getButtonIndex(i8 signext %26)
%28 = load i32, i32* %3
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [120 x i8], [120 x i8]* %6, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = call i64 @getButtonIndex(i8 signext %32)
%34 = icmp eq i64 %27, %33
br i1 %34, label %35, label %44
35: ; preds = %22
%36 = load i32, i32* %5
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [120 x i8], [120 x i8]* %6, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = call i32 @getCharIndex(i8 signext %40)
%42 = add nsw i32 %36, %41
%43 = add nsw i32 %42, 2
store i32 %43, i32* %5
br label %52
44: ; preds = %22
%45 = load i32, i32* %3
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [120 x i8], [120 x i8]* %6, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = call i32 @getCharIndex(i8 signext %48)
%50 = load i32, i32* %5
%51 = add nsw i32 %50, %49
store i32 %51, i32* %5
br label %52
52: ; preds = %44, %35
br label %53
53: ; preds = %52
%54 = load i32, i32* %3
%55 = add nsw i32 %54, 1
store i32 %55, i32* %3
br label %18
56: ; preds = %18
%57 = load i32, i32* %5
%58 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %57)
br label %7
59: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [120 x i8]
%2 = getelementptr inbounds [120 x i8], [120 x i8]* %1, i64 0, i64 0
%3 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = load i64, i64* @EOF
%5 = icmp eq i64 %3, %4
br i1 %5, label %37, label %6
6: ; preds = %0, %31
%7 = call i32 @strlen(i8* %2)
%8 = load i8, i8* %2
%9 = call i32 @getCharIndex(i8 signext %8)
%10 = icmp sgt i32 %7, 1
br i1 %10, label %11, label %31
11: ; preds = %6
%12 = zext i32 %7 to i64
br label %13
13: ; preds = %11, %13
%14 = phi i64 [ 1, %11 ], [ %29, %13 ]
%15 = phi i32 [ %9, %11 ], [ %28, %13 ]
%16 = getelementptr inbounds [120 x i8], [120 x i8]* %1, i64 0, i64 %14
%17 = load i8, i8* %16
%18 = call i64 @getButtonIndex(i8 signext %17)
%19 = add nsw i64 %14, -1
%20 = getelementptr inbounds [120 x i8], [120 x i8]* %1, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = call i64 @getButtonIndex(i8 signext %21)
%23 = icmp eq i64 %18, %22
%24 = load i8, i8* %16
%25 = call i32 @getCharIndex(i8 signext %24)
%26 = add i32 %15, 2
%27 = select i1 %23, i32 %26, i32 %15
%28 = add i32 %25, %27
%29 = add nuw nsw i64 %14, 1
%30 = icmp eq i64 %29, %12
br i1 %30, label %31, label %13
31: ; preds = %13, %6
%32 = phi i32 [ %9, %6 ], [ %28, %13 ]
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%35 = load i64, i64* @EOF
%36 = icmp eq i64 %34, %35
br i1 %36, label %37, label %6
37: ; preds = %31, %0
ret i32 0
}