#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 /*<<< orphan*/, int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int n, i, a, res;
  int t = 1;
  char op;
  scanf("%i", &n);
  while (n > 0) {
    n--;
    scanf("%i", &res);
    for (i = 0; i < n; i++) {
      scanf("%c%i", &op, &a);
      res = (op == '+') ? res + a : res - a;
    }
    printf("Teste %i\n%i\n\n", t++, res);
    scanf("%i", &n);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x18(%rbp)
lea    0xec5(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    11ff <main+0xdf>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
lea    0xea0(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ce <main+0xae>
lea    0xe79(%rip),%rdi
lea    -0x19(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x19(%rbp),%eax
cmp    $0x2b,%eax
jne    11b1 <main+0x91>
mov    -0x14(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    11ba <main+0x9a>
mov    -0x14(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1174 <main+0x54>
mov    -0x18(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edx
lea    0xe22(%rip),%rdi
call   1030 <printf@plt>
lea    0xe13(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    1148 <main+0x28>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xecd(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    11f8 <main+0xd8>
mov    $0x1,%ebp
lea    0xea9(%rip),%r15
lea    0xea0(%rip),%r12
lea    0xb(%rsp),%r13
lea    0x14(%rsp),%rbx
jmp    11a0 <main+0x80>
nopl   0x0(%rax)
mov    0x10(%rsp),%edx
lea    0x1(%rbp),%r14d
lea    0xe86(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %r15,%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
mov    %r14d,%ebp
test   %eax,%eax
jle    11f8 <main+0xd8>
add    $0xffffffff,%eax
mov    %eax,0xc(%rsp)
mov    %r15,%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    1170 <main+0x50>
xor    %r14d,%r14d
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x14(%rsp),%eax
mov    %eax,%edx
neg    %edx
cmpb   $0x2b,0xb(%rsp)
cmove  %eax,%edx
add    0x10(%rsp),%edx
mov    %edx,0x10(%rsp)
add    $0x1,%r14d
cmp    0xc(%rsp),%r14d
jl     11c0 <main+0xa0>
jmp    1174 <main+0x54>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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