#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 max_trip(int *, int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int T;
  scanf("%d", &T);
  for (int caseIndex = 1; caseIndex <= T; caseIndex++) {
    int N;
    scanf("%d", &N);
    int W[100] = {};
    for (int i = 0; i < N; i++) {
      scanf("%d", &W[i]);
    }
    printf("Case #%d: %d\n", caseIndex, max_trip(W, N));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1220 <main+0xe0>
lea    0xe84(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1040 <memset@plt>
movl   $0x0,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11e6 <main+0xa6>
movslq -0x1a4(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe33(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    11a2 <main+0x62>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1a8(%rbp)
lea    -0x1a0(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1050 <max_trip@plt>
mov    -0x1a8(%rbp),%esi
mov    %eax,%edx
lea    0xdf6(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1169 <main+0x29>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a8,%rsp
lea    0xea8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11ff <main+0xbf>
mov    $0x1,%r14d
lea    0xe86(%rip),%rbx
lea    0x10(%rsp),%r12
lea    0xe7d(%rip),%r13
jmp    11b3 <main+0x73>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1050 <max_trip@plt>
mov    %r13,%rdi
mov    %r14d,%esi
mov    %eax,%edx
call   1030 <printf@plt>
lea    0x1(%r14),%eax
cmp    0xc(%rsp),%r14d
mov    %eax,%r14d
jge    11ff <main+0xbf>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
mov    $0x190,%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    0x8(%rsp),%esi
test   %esi,%esi
jle    1190 <main+0x50>
mov    %r12,%rbp
xor    %r15d,%r15d
nopl   (%rax)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
add    $0x1,%r15
movslq 0x8(%rsp),%rsi
add    $0x4,%rbp
cmp    %rsi,%r15
jl     11e0 <main+0xa0>
jmp    1190 <main+0x50>
xor    %eax,%eax
add    $0x1a8,%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"Case #%d: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x i32]
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %8
8: ; preds = %33, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %36
12: ; preds = %8
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%14 = bitcast [100 x i32]* %5 to i8*
store i32 0, i32* %6
br label %15
15: ; preds = %24, %12
%16 = load i32, i32* %6
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %21
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %22)
br label %24
24: ; preds = %19
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %15
27: ; preds = %15
%28 = load i32, i32* %3
%29 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 0
%30 = load i32, i32* %4
%31 = call i32 @max_trip(i32* %29, i32 %30)
%32 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %31)
br label %33
33: ; preds = %27
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %8
36: ; preds = %8
ret i32 0
}

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