#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 scanf(char *, int *);
int main() {
  int n, a, ak, instancia = 1, count, soma;
  while (scanf("%d", &n) == 1) {
    soma = 0;
    ak = -9999;
    for (count = 0; count < n; count++) {
      scanf("%d", &a);
      if (ak == -9999 && soma == a) {
        ak = a;
      } else {
        soma += a;
      }
    }
    printf("Instancia %d\n", instancia++);
    if (ak == -9999) {
      printf("nao achei\n\n");
    } else {
      printf("%d\n\n", ak);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x14(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    120f <main+0xef>
movl   $0x0,-0x1c(%rbp)
movl   $0xffffd8f1,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c0 <main+0xa0>
lea    0xe89(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0xffffd8f1,-0x10(%rbp)
jne    11a4 <main+0x84>
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11a4 <main+0x84>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11ad <main+0x8d>
mov    -0xc(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11b2 <main+0x92>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1164 <main+0x44>
mov    -0x14(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0xffffd8f1,-0x10(%rbp)
jne    11f9 <main+0xd9>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120a <main+0xea>
mov    -0x10(%rbp),%esi
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
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    0xebe(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1239 <main+0x109>
mov    $0x1,%r12d
lea    0xea0(%rip),%r15
lea    0x4(%rsp),%r14
jmp    11a9 <main+0x79>
nopw   0x0(%rax,%rax,1)
lea    0x1(%r12),%ebx
lea    0xe87(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe89(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
mov    %ebx,%r12d
cmp    $0x1,%eax
jne    1239 <main+0x109>
cmpl   $0x0,(%rsp)
jle    1170 <main+0x40>
mov    $0xffffd8f1,%r13d
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    11ca <main+0x9a>
nopl   0x0(%rax,%rax,1)
add    %eax,%ebp
add    $0x1,%ebx
cmp    (%rsp),%ebx
jge    1200 <main+0xd0>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <scanf@plt>
mov    %r13d,%ecx
xor    $0xffffd8f1,%ecx
mov    0x4(%rsp),%eax
mov    %ebp,%edx
xor    %eax,%edx
or     %ecx,%edx
jne    11c0 <main+0x90>
mov    %eax,%r13d
xor    %eax,%eax
jmp    11c0 <main+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x1(%r12),%ebx
lea    0xdf7(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xffffd8f1,%r13d
je     1186 <main+0x56>
lea    0xde7(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1192 <main+0x62>
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"Instancia %d\0A\00"
@.str.2 = [12 x i8] c"nao achei\0A\0A\00"
@.str.3 = [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
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %5
br label %8
8: ; preds = %45, %0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %46
11: ; preds = %8
store i32 0, i32* %7
store i32 -9999, i32* %4
store i32 0, i32* %6
br label %12
12: ; preds = %31, %11
%13 = load i32, i32* %6
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %34
16: ; preds = %12
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, -9999
br i1 %19, label %20, label %26
20: ; preds = %16
%21 = load i32, i32* %7
%22 = load i32, i32* %3
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = load i32, i32* %3
store i32 %25, i32* %4
br label %30
26: ; preds = %20, %16
%27 = load i32, i32* %3
%28 = load i32, i32* %7
%29 = add nsw i32 %28, %27
store i32 %29, i32* %7
br label %30
30: ; preds = %26, %24
br label %31
31: ; preds = %30
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %12
34: ; preds = %12
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%38 = load i32, i32* %4
%39 = icmp eq i32 %38, -9999
br i1 %39, label %40, label %42
40: ; preds = %34
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %45
42: ; preds = %34
%43 = load i32, i32* %4
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %42, %40
br label %8
46: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [14 x i8] c"Instancia %d\0A\00"
@.str.3 = [5 x i8] c"%d\0A\0A\00"
@str = [11 x i8] c"nao achei\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
br i1 %6, label %7, label %42
7: ; preds = %0, %38
%8 = phi i32 [ %39, %38 ], [ 1, %0 ]
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = add nuw nsw i32 %8, 1
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %33
14: ; preds = %7, %14
%15 = phi i32 [ %25, %14 ], [ 0, %7 ]
%16 = phi i32 [ %26, %14 ], [ 0, %7 ]
%17 = phi i32 [ %23, %14 ], [ -9999, %7 ]
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%19 = icmp eq i32 %17, -9999
%20 = load i32, i32* %2
%21 = icmp eq i32 %15, %20
%22 = select i1 %19, i1 %21, i1 false
%23 = select i1 %22, i32 %20, i32 %17
%24 = select i1 %22, i32 0, i32 %20
%25 = add nsw i32 %24, %15
%26 = add nuw nsw i32 %16, 1
%27 = load i32, i32* %1
%28 = icmp slt i32 %26, %27
br i1 %28, label %14, label %29
29: ; preds = %14
%30 = add nuw nsw i32 %8, 1
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%32 = icmp eq i32 %23, -9999
br i1 %32, label %33, label %36
33: ; preds = %11, %29
%34 = phi i32 [ %12, %11 ], [ %30, %29 ]
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %38
36: ; preds = %29
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %23)
br label %38
38: ; preds = %36, %33
%39 = phi i32 [ %30, %36 ], [ %34, %33 ]
%40 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%41 = icmp eq i32 %40, 1
br i1 %41, label %7, label %42
42: ; preds = %38, %0
ret i32 0
}