#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 getMaxSum(int *, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int c, i, num;
  int elems[100000];
  scanf("%d", &c);
  while (c--) {
    scanf("%d", &num);
    for (i = 0; i < num; i++)
      scanf("%d", &elems[i]);
    printf("%d\n", getMaxSum(elems, num));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x61a90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     11d7 <main+0xa7>
lea    0xe93(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11b5 <main+0x85>
movslq -0xc(%rbp),%rax
lea    -0x61a90(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe5e(%rip),%rdi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117d <main+0x4d>
lea    -0x61a90(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1050 <getMaxSum@plt>
mov    %eax,%esi
lea    0xe36(%rip),%rdi
call   1030 <printf@plt>
jmp    1152 <main+0x22>
xor    %eax,%eax
add    $0x61a90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x61a98,%rsp
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    116d <main+0x3d>
xor    %eax,%eax
add    $0x61a98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe8c(%rip),%r13
lea    0x8(%rsp),%r14
lea    0x10(%rsp),%r15
lea    0xe7e(%rip),%r12
jmp    11a9 <main+0x79>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1050 <getMaxSum@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
subl   $0x1,0xc(%rsp)
jb     1159 <main+0x29>
mov    %r13,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%esi
test   %esi,%esi
jle    1190 <main+0x60>
mov    %r15,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
add    $0x1,%rbp
movslq 0x8(%rsp),%rsi
add    $0x4,%rbx
cmp    %rsi,%rbp
jl     11d0 <main+0xa0>
jmp    1190 <main+0x60>

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

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