#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 i = 0, teste = 0, p = 0, n = 0;
  while (1) {
    teste++;
    n = 0;
    i = 1;
    scanf("%d", &n);
    if (n == 0)
      break;
    printf("Teste %d\n", teste);
    for (i; i < n + 1; i++) {
      scanf("%d", &p);
      if (p == i) {
        printf("%d\n\n", i);
      }
    }
  }
  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)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xe97(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x14(%rbp)
jne    1181 <main+0x61>
jmp    11e4 <main+0xc4>
mov    -0xc(%rbp),%esi
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11df <main+0xbf>
lea    0xe58(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11cc <main+0xac>
mov    -0x8(%rbp),%esi
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
jmp    11d1 <main+0xb1>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1190 <main+0x70>
jmp    114b <main+0x2b>
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
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
lea    0xebf(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
cmpl   $0x0,(%rsp)
je     11e9 <main+0xc9>
mov    $0x1,%r12d
lea    0xea0(%rip),%rbx
mov    %rsp,%r15
lea    0x4(%rsp),%rbp
lea    0xe9e(%rip),%r13
jmp    119c <main+0x7c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12d
movl   $0x0,(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
cmpl   $0x0,(%rsp)
je     11e9 <main+0xc9>
lea    0xe60(%rip),%rdi
mov    %r12d,%esi
call   1030 <printf@plt>
cmpl   $0x0,(%rsp)
jle    1180 <main+0x60>
xor    %r14d,%r14d
jmp    11c6 <main+0xa6>
cs nopw 0x0(%rax,%rax,1)
cmp    (%rsp),%r14d
jge    1180 <main+0x60>
add    $0x1,%r14d
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <scanf@plt>
cmp    0x4(%rsp),%r14d
jne    11c0 <main+0xa0>
mov    %r13,%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
jmp    11c0 <main+0xa0>
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 = [10 x i8] c"Teste %d\0A\00"
@.str.2 = [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
br label %6
6: ; preds = %0, %34
%7 = load i32, i32* %3
%8 = add nsw i32 %7, 1
store i32 %8, i32* %3
store i32 0, i32* %5
store i32 1, i32* %2
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%10 = load i32, i32* %5
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %6
br label %35
13: ; preds = %6
%14 = load i32, i32* %3
%15 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %2
br label %17
17: ; preds = %31, %13
%18 = load i32, i32* %2
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
%21 = icmp slt i32 %18, %20
br i1 %21, label %22, label %34
22: ; preds = %17
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%24 = load i32, i32* %4
%25 = load i32, i32* %2
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = load i32, i32* %2
%29 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %27, %22
br label %31
31: ; preds = %30
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %17
34: ; preds = %17
br label %6
35: ; preds = %12
ret i32 0
}

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