#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);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int M = 0, N = 0, a = 0, sum = 0;
  scanf("%d", &M);
  while (M != 0) {
    scanf("%d", &N);
    while (N > 0) {
      scanf("%d", &a);
      sum += a;
      N--;
    }
    printf("%d\n\n", sum);
    N = 0, a = 0, sum = 0;
    M--;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeae(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
je     11d8 <main+0xb8>
lea    0xe94(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jle    11a6 <main+0x86>
lea    0xe7a(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1175 <main+0x55>
mov    -0x14(%rbp),%esi
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    115b <main+0x3b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x4(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xeb5(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
je     11e1 <main+0xc1>
lea    0xe99(%rip),%rbx
lea    0x4(%rsp),%r14
lea    0x8(%rsp),%r15
lea    0xe8b(%rip),%r12
jmp    11a3 <main+0x83>
nopw   0x0(%rax,%rax,1)
xor    %ebp,%ebp
mov    %r12,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
movl   $0x0,0x4(%rsp)
movl   $0x0,0x8(%rsp)
addl   $0xffffffff,0xc(%rsp)
je     11e1 <main+0xc1>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1180 <main+0x60>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
add    0x8(%rsp),%ebp
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x4(%rsp)
cmp    $0x1,%eax
jg     11c0 <main+0xa0>
jmp    1182 <main+0x62>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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