#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() {
  int n, i, t = 1;
  int ticket, winner;
  scanf("%d", &n);
  while (n > 0) {
    for (i = 1; i <= n; i++) {
      scanf("%d", &ticket);
      if (ticket == i)
        winner = i;
    }
    printf("Teste %d\n%d\n\n", t++, winner);
    scanf("%d", &n);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    11c7 <main+0xa7>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1198 <main+0x78>
lea    0xe96(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1185 <main+0x65>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    118a <main+0x6a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1157 <main+0x37>
mov    -0x10(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%edx
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
lea    0xe47(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1146 <main+0x26>
mov    -0x4(%rbp),%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>
cmpl   $0x0,(%rsp)
jle    11b7 <main+0x97>
mov    $0x1,%r13d
lea    0xeb3(%rip),%rbx
lea    0x4(%rsp),%r14
mov    %rsp,%r12
cs nopw 0x0(%rax,%rax,1)
nop
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r15d
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
cmp    0x4(%rsp),%r15d
cmove  %r15d,%ebp
cmp    (%rsp),%r15d
jl     1170 <main+0x50>
lea    0x1(%r13),%r15d
lea    0xe6a(%rip),%rdi
mov    %r13d,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
cmpl   $0x0,(%rsp)
mov    %r15d,%r13d
jg     1160 <main+0x40>
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* %4
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %8
8: ; preds = %27, %0
%9 = load i32, i32* %2
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %33
11: ; preds = %8
store i32 1, i32* %3
br label %12
12: ; preds = %24, %11
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %27
16: ; preds = %12
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%18 = load i32, i32* %5
%19 = load i32, i32* %3
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = load i32, i32* %3
store i32 %22, i32* %6
br label %23
23: ; preds = %21, %16
br label %24
24: ; preds = %23
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %12
27: ; preds = %12
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
%30 = load i32, i32* %6
%31 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %30)
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %8
33: ; preds = %8
%34 = load i32, i32* %1
ret i32 %34
}

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 sgt i32 %6, 0
br i1 %7, label %8, label %27
8: ; preds = %0, %21
%9 = phi i32 [ %17, %21 ], [ undef, %0 ]
%10 = phi i32 [ %22, %21 ], [ 1, %0 ]
br label %11
11: ; preds = %8, %11
%12 = phi i32 [ %17, %11 ], [ %9, %8 ]
%13 = phi i32 [ %18, %11 ], [ 1, %8 ]
%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 eq i32 %15, %13
%17 = select i1 %16, i32 %13, i32 %12
%18 = add nuw nsw i32 %13, 1
%19 = load i32, i32* %1
%20 = icmp slt i32 %13, %19
br i1 %20, label %11, label %21
21: ; preds = %11
%22 = add nuw nsw i32 %10, 1
%23 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %17)
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%25 = load i32, i32* %1
%26 = icmp sgt i32 %25, 0
br i1 %26, label %8, label %27
27: ; preds = %21, %0
ret i32 0
}