#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*/ scanf(char *, int *);
int main() {
  int a = 0, b = 0, c = 0, i, d = 5, e = 1, f;
  scanf("%d", &a);
  scanf("%d", &b);
  for (i = 1; i < a; i++) {
    scanf("%d", &c);
    if (b > c && e == 1) {
      d = 0;
      e = 0;
      f = i;
    }
    b = c;
  }
  if (d == 0) {
    printf("%d\n", f + 1);
  } else {
    printf("0\n");
  }
  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   $0x5,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
lea    0xea7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe97(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d3 <main+0xb3>
lea    0xe74(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11bf <main+0x9f>
cmpl   $0x1,-0x1c(%rbp)
jne    11bf <main+0x9f>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1179 <main+0x59>
cmpl   $0x0,-0x18(%rbp)
jne    11f6 <main+0xd6>
mov    -0x20(%rbp),%esi
add    $0x1,%esi
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1204 <main+0xe4>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
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
sub    $0x18,%rsp
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x14(%rsp)
lea    0xea3(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
cmpl   $0x2,0x10(%rsp)
jl     11ee <main+0xbe>
mov    $0x5,%r13d
mov    $0x1,%ebx
lea    0xe70(%rip),%r14
lea    0x14(%rsp),%r15
mov    $0x1,%ebp
jmp    11b5 <main+0x85>
nopl   0x0(%rax)
mov    %ecx,0xc(%rsp)
add    $0x1,%ebp
mov    %esi,%r12d
mov    %edx,%ebx
mov    %edi,%r13d
cmp    0x10(%rsp),%ebp
jge    11ea <main+0xba>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    0x14(%rsp),%ecx
cmp    %ecx,0xc(%rsp)
setg   %r8b
cmp    $0x1,%ebx
sete   %al
xor    %edi,%edi
mov    $0x0,%edx
mov    %ebp,%esi
test   %al,%r8b
jne    11a0 <main+0x70>
mov    %r13d,%edi
mov    %ebx,%edx
mov    %r12d,%esi
jmp    11a0 <main+0x70>
test   %edi,%edi
je     11fc <main+0xcc>
lea    0xe12(%rip),%rdi
call   1030 <puts@plt>
jmp    120d <main+0xdd>
add    $0x1,%esi
lea    0xdfd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%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 = [4 x i8] c"%d\0A\00"
@.str.2 = [3 x i8] c"0\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
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 5, i32* %6
store i32 1, i32* %7
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
store i32 1, i32* %5
br label %11
11: ; preds = %27, %0
%12 = load i32, i32* %5
%13 = load i32, i32* %2
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %30
15: ; preds = %11
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = icmp sgt i32 %17, %18
br i1 %19, label %20, label %25
20: ; preds = %15
%21 = load i32, i32* %7
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %25
23: ; preds = %20
store i32 0, i32* %6
store i32 0, i32* %7
%24 = load i32, i32* %5
store i32 %24, i32* %8
br label %25
25: ; preds = %23, %20, %15
%26 = load i32, i32* %4
store i32 %26, i32* %3
br label %27
27: ; preds = %25
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %11
30: ; preds = %11
%31 = load i32, i32* %6
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %35)
br label %39
37: ; preds = %30
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %39
39: ; preds = %37, %33
ret i32 0
}

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