#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 size, count = -1, term;
  scanf("%d %d", &size, &term);
  int arr[size];
  for (int a = 0; a < size; a++)
    scanf("%d", &arr[a]);
  for (int a = size - 1; a > 0; a--) {
    if (arr[a] == term) {
      printf("%i", a + 1);
      count = 0;
    }
  }
  if (count == -1)
    printf("%i", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0xc(%rbp)
lea    0xec3(%rip),%rdi
xor    %eax,%eax
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b1 <main+0x91>
mov    -0x30(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117a <main+0x5a>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jle    1204 <main+0xe4>
mov    -0x30(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x10(%rbp),%eax
jne    11f1 <main+0xd1>
mov    -0x28(%rbp),%esi
add    $0x1,%esi
lea    0xe21(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
jmp    11f6 <main+0xd6>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    11ba <main+0x9a>
cmpl   $0xffffffff,-0xc(%rbp)
jne    121d <main+0xfd>
mov    -0xc(%rbp),%esi
lea    0xdee(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xecb(%rip),%rdi
lea    -0x2c(%rbp),%rsi
lea    -0x30(%rbp),%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rsp,%r15
mov    -0x2c(%rbp),%eax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
cmpl   $0x0,-0x2c(%rbp)
jle    11ed <main+0xcd>
lea    0xe93(%rip),%r14
mov    %r12,%r13
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
add    $0x4,%r13
cmp    %rax,%rbx
jl     1180 <main+0x60>
mov    %eax,%esi
cmp    $0x2,%esi
jl     11ed <main+0xcd>
mov    $0xffffffff,%eax
lea    0xe55(%rip),%r14
jmp    11cd <main+0xad>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x1(%rbx),%rcx
mov    %rbx,%rsi
cmp    $0x2,%rcx
jbe    11e8 <main+0xc8>
lea    -0x1(%rsi),%rbx
mov    %ebx,%ecx
mov    (%r12,%rcx,4),%ecx
cmp    -0x30(%rbp),%ecx
jne    11c0 <main+0xa0>
mov    %r14,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
jmp    11c0 <main+0xa0>
cmp    $0xffffffff,%eax
jne    11fe <main+0xde>
lea    0xe12(%rip),%rdi
mov    $0xffffffff,%esi
call   1030 <printf@plt>
mov    %r15,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%i\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %3
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %4)
%10 = load i32, i32* %2
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %5
%13 = alloca i32, i64 %11
store i64 %11, i64* %6
store i32 0, i32* %7
br label %14
14: ; preds = %23, %0
%15 = load i32, i32* %7
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %13, i64 %20
%22 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %21)
br label %23
23: ; preds = %18
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %14
26: ; preds = %14
%27 = load i32, i32* %2
%28 = sub nsw i32 %27, 1
store i32 %28, i32* %8
br label %29
29: ; preds = %44, %26
%30 = load i32, i32* %8
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %47
32: ; preds = %29
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %13, i64 %34
%36 = load i32, i32* %35
%37 = load i32, i32* %4
%38 = icmp eq i32 %36, %37
br i1 %38, label %39, label %43
39: ; preds = %32
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
%42 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %41)
store i32 0, i32* %3
br label %43
43: ; preds = %39, %32
br label %44
44: ; preds = %43
%45 = load i32, i32* %8
%46 = add nsw i32 %45, -1
store i32 %46, i32* %8
br label %29
47: ; preds = %29
%48 = load i32, i32* %3
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %53
50: ; preds = %47
%51 = load i32, i32* %3
%52 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %50, %47
store i32 0, i32* %1
%54 = load i8*, i8** %5
%55 = load i32, i32* %1
ret i32 %55
}

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