#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 long);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int t, i;
  long long sum = 0, k;
  char s[20];
  scanf("%d", &t);
  for (i = 0; i < t; i++) {
    scanf("%s", s);
    if (s[0] == 'd') {
      scanf("%lld", &k);
      sum += k;
    }
    if (s[0] == 'r')
      printf("%lld\n", sum);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xec2(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c9 <main+0xa9>
lea    -0x40(%rbp),%rsi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x40(%rbp),%eax
cmp    $0x64,%eax
jne    1199 <main+0x79>
lea    0xe84(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x20(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
movsbl -0x40(%rbp),%eax
cmp    $0x72,%eax
jne    11b6 <main+0x96>
mov    -0x18(%rbp),%rsi
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
jmp    11bb <main+0x9b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1150 <main+0x30>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xecb(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11bd <main+0x9d>
lea    0xeb4(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%r12
lea    0xeab(%rip),%r13
xor    %ebp,%ebp
xor    %r15d,%r15d
jmp    117b <main+0x5b>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r15d
cmp    0x4(%rsp),%r15d
jge    11bd <main+0x9d>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movzbl 0x10(%rsp),%eax
cmp    $0x64,%al
jne    11ac <main+0x8c>
lea    0xe6e(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
add    0x8(%rsp),%rbp
movzbl 0x10(%rsp),%eax
cmp    $0x72,%al
jne    1170 <main+0x50>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1030 <printf@plt>
jmp    1170 <main+0x50>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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