#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 *);
int main(void) {
  int num, x, soma;
  int i;
  int n = 1;
  while (1) {
    scanf("%d", &num);
    if (num == 0)
      break;
    soma = 0;
    for (i = 0; i < num; i++) {
      scanf("%d", &x);
      soma += x;
    }
    printf("Teste %d\n%d\n\n", n++, soma);
  }
  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>
cmpl   $0x0,-0x8(%rbp)
jne    1155 <main+0x35>
jmp    11b5 <main+0x95>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1196 <main+0x76>
lea    0xe8a(%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    1163 <main+0x43>
mov    -0x18(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%edx
lea    0xe58(%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>
mov    (%rsp),%eax
test   %eax,%eax
je     11bb <main+0x9b>
mov    $0x1,%r13d
lea    0xeb2(%rip),%rbx
lea    0x4(%rsp),%r14
mov    %rsp,%r12
jmp    118c <main+0x6c>
nopl   0x0(%rax,%rax,1)
xor    %ebp,%ebp
lea    0x1(%r13),%r15d
lea    0xe96(%rip),%rdi
mov    %r13d,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%eax
mov    %r15d,%r13d
test   %eax,%eax
je     11bb <main+0x9b>
test   %eax,%eax
jle    1160 <main+0x40>
xor    %r15d,%r15d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
add    0x4(%rsp),%ebp
add    $0x1,%r15d
cmp    (%rsp),%r15d
jl     11a0 <main+0x80>
jmp    1162 <main+0x42>
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 = %0, %25
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
br label %30
12: ; preds = %7
store i32 0, i32* %4
store i32 0, i32* %5
br label %13
13: ; preds = %22, %12
%14 = load i32, i32* %5
%15 = load i32, i32* %2
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = add nsw i32 %20, %19
store i32 %21, i32* %4
br label %22
22: ; preds = %17
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %13
25: ; preds = %13
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
%28 = load i32, i32* %4
%29 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %26, i32 %28)
br label %7
30: ; preds = %11
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 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %28, label %8
8: ; preds = %0, %21
%9 = phi i32 [ %26, %21 ], [ %6, %0 ]
%10 = phi i32 [ %23, %21 ], [ 1, %0 ]
%11 = icmp sgt i32 %9, 0
br i1 %11, label %12, label %21
12: ; preds = %8, %12
%13 = phi i32 [ %18, %12 ], [ 0, %8 ]
%14 = phi i32 [ %17, %12 ], [ 0, %8 ]
%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, %8
%22 = phi i32 [ 0, %8 ], [ %17, %12 ]
%23 = add nuw nsw i32 %10, 1
%24 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %22)
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%26 = load i32, i32* %1
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %8
28: ; preds = %21, %0
ret i32 0
}