#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 */
scalar_t__ equal(int *, int *, int);
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n;
  scanf("%d", &n);
  int *x;
  int *y;
  while (n != 0) {
    x = (int *)malloc(sizeof(int) * n);
    y = (int *)malloc(sizeof(int) * n);
    int i;
    for (i = 0; i < n; i++) {
      scanf("%d", &x[i]);
      y[x[i] - 1] = i + 1;
    }
    if (equal(x, y, n)) {
      printf("ambiguous\n");
    } else {
      printf("not ambiguous\n");
    }
    free(x);
    free(y);
    scanf("%d", &n);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
je     1257 <main+0x107>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f9 <main+0xa9>
mov    -0x10(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe38(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x1c(%rbp),%rsi
mov    (%rcx,%rsi,4),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a6 <main+0x56>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1070 <equal@plt>
cmp    $0x0,%rax
je     1224 <main+0xd4>
lea    0xded(%rip),%rdi
call   1040 <printf@plt>
jmp    1230 <main+0xe0>
lea    0xdd8(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
lea    0xdb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
jmp    116f <main+0x1f>
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    0xe9e(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
test   %edi,%edi
je     122a <main+0xda>
lea    0xe81(%rip),%r12
lea    0x4(%rsp),%r14
jmp    11d8 <main+0x88>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r13,%rsi
call   1070 <equal@plt>
test   %rax,%rax
lea    0xe62(%rip),%rdi
lea    0xe57(%rip),%rax
cmove  %rax,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
test   %edi,%edi
je     122a <main+0xda>
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%r13
mov    0x4(%rsp),%edx
test   %edx,%edx
jle    1190 <main+0x40>
mov    %r15,%rbx
xor    %ebp,%ebp
nop
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
add    $0x1,%rbp
movslq (%rbx),%rax
mov    %ebp,-0x4(%r13,%rax,4)
movslq 0x4(%rsp),%rdx
add    $0x4,%rbx
cmp    %rdx,%rbp
jl     1200 <main+0xb0>
jmp    1190 <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 = [11 x i8] c"ambiguous\0A\00"
@.str.2 = [15 x i8] c"not ambiguous\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
%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 = %57, %0
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %63
10: ; preds = %7
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = mul i64 4, %12
%14 = trunc i64 %13 to i32
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i32*
store i32* %16, i32** %3
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = mul i64 4, %18
%20 = trunc i64 %19 to i32
%21 = call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to i32*
store i32* %22, i32** %4
store i32 0, i32* %5
br label %23
23: ; preds = %44, %10
%24 = load i32, i32* %5
%25 = load i32, i32* %2
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %47
27: ; preds = %23
%28 = load i32*, i32** %3
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %31)
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
%35 = load i32*, i32** %4
%36 = load i32*, i32** %3
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = load i32, i32* %39
%41 = sub nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %35, i64 %42
store i32 %34, i32* %43
br label %44
44: ; preds = %27
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %23
47: ; preds = %23
%48 = load i32*, i32** %3
%49 = load i32*, i32** %4
%50 = load i32, i32* %2
%51 = call i64 @equal(i32* %48, i32* %49, i32 %50)
%52 = icmp ne i64 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %47
%54 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %57
55: ; preds = %47
%56 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %57
57: ; preds = %55, %53
%58 = load i32*, i32** %3
%59 = call i32 @free(i32* %58)
%60 = load i32*, i32** %4
%61 = call i32 @free(i32* %60)
%62 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %7
63: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@str = [14 x i8] c"not ambiguous\00"
@str.3 = [10 x i8] c"ambiguous\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp eq i32 %4, 0
br i1 %5, label %41, label %6
6: ; preds = %0, %30
%7 = phi i32 [ %39, %30 ], [ %4, %0 ]
%8 = shl i32 %7, 2
%9 = call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i32*
%11 = load i32, i32* %1
%12 = shl i32 %11, 2
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i32*
%15 = load i32, i32* %1
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %30
17: ; preds = %6, %17
%18 = phi i64 [ %21, %17 ], [ 0, %6 ]
%19 = getelementptr inbounds i32, i32* %10, 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* %19
%23 = add nsw i32 %22, -1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %14, i64 %24
%26 = trunc i64 %21 to i32
store i32 %26, i32* %25
%27 = load i32, i32* %1
%28 = sext i32 %27 to i64
%29 = icmp slt i64 %21, %28
br i1 %29, label %17, label %30
30: ; preds = %17, %6
%31 = phi i32 [ %15, %6 ], [ %27, %17 ]
%32 = call i64 @equal(i32* %10, i32* %14, i32 %31)
%33 = icmp eq i64 %32, 0
%34 = select i1 %33, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @str.3, i64 0, i64 0)
%35 = call i32 @puts(i8* dereferenceable(1) %34)
%36 = call i32 @free(i32* %10)
%37 = call i32 @free(i32* %14)
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%39 = load i32, i32* %1
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %6
41: ; preds = %30, %0
ret i32 0
}