#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 scanf(char *, int *);
main() {
  int n, x, acc, i, teste = 1;
  while (scanf("%d", &n) == 1 && n > 0) {
    acc = 0;
    for (i = 0; i < n; i++) {
      scanf("%d", &x);
      acc += x;
    }
    printf("Teste %d\n%d\n\n", teste++, acc);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x18(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
mov    %al,-0x19(%rbp)
jne    1160 <main+0x40>
cmpl   $0x0,-0x8(%rbp)
setg   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1170 <main+0x50>
jmp    11d0 <main+0xb0>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b1 <main+0x91>
lea    0xe6f(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117e <main+0x5e>
mov    -0x18(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%edx
lea    0xe3d(%rip),%rdi
call   1030 <printf@plt>
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xece(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    11b4 <main+0x94>
cmpl   $0x0,(%rsp)
jle    11b4 <main+0x94>
mov    $0x1,%r14d
lea    0xeae(%rip),%rbx
lea    0x4(%rsp),%r13
mov    %rsp,%r12
nopw   0x0(%rax,%rax,1)
xor    %r15d,%r15d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <scanf@plt>
add    0x4(%rsp),%ebp
add    $0x1,%r15d
cmp    (%rsp),%r15d
jl     1170 <main+0x50>
lea    0xe73(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    11b4 <main+0x94>
add    $0x1,%r14d
cmpl   $0x0,(%rsp)
jg     1160 <main+0x40>
xor    %eax,%eax
add    $0x8,%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 = [14 x i8] c"Teste %d\0A%d\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %6
br label %7
7: ; preds = %28, %0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 0
br label %13
13: ; preds = %10, %7
%14 = phi i1 [ false, %7 ], [ %12, %10 ]
br i1 %14, label %15, label %33
15: ; preds = %13
store i32 0, i32* %4
store i32 0, i32* %5
br label %16
16: ; preds = %25, %15
%17 = load i32, i32* %5
%18 = load i32, i32* %2
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %28
20: ; preds = %16
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = add nsw i32 %23, %22
store i32 %24, i32* %4
br label %25
25: ; preds = %20
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %16
28: ; preds = %16
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
%31 = load i32, i32* %4
%32 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %29, i32 %31)
br label %7
33: ; preds = %13
ret i32 0
}

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