#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, short);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ is_in_u(long);
int main() {
  FILE *f = fopen("MAXISEQ.INP", "r");
  short n, i, max = 0, start = -1;
  long a, b;
  fscanf(f, "%hd\n", &n);
  for (i = 0; i < n; i++) {
    b = a;
    fscanf(f, "%ld\n", &a);
    if (!is_in_u(a) || start >= 0 && b > a) {
      start = -1;
      continue;
    }
    if (start < 0)
      start = i;
    if (i - start >= max)
      max = i - start + 1;
  }
  fclose(f);
  f = fopen("MAXISEQ.OUT", "w");
  fprintf(f, "%hd\n", max);
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
movw   $0x0,-0x16(%rbp)
movw   $0xffff,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe81(%rip),%rsi
lea    -0x12(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
movw   $0x0,-0x14(%rbp)
movswl -0x14(%rbp),%eax
movswl -0x12(%rbp),%ecx
cmp    %ecx,%eax
jge    1256 <main+0x106>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe52(%rip),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
mov    -0x20(%rbp),%rdi
call   1070 <is_in_u@plt>
cmp    $0x0,%eax
je     11f9 <main+0xa9>
movswl -0x18(%rbp),%eax
cmp    $0x0,%eax
jl     1204 <main+0xb4>
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jle    1204 <main+0xb4>
movw   $0xffff,-0x18(%rbp)
jmp    1245 <main+0xf5>
movswl -0x18(%rbp),%eax
cmp    $0x0,%eax
jge    1219 <main+0xc9>
mov    -0x14(%rbp),%ax
mov    %ax,-0x18(%rbp)
movswl -0x14(%rbp),%eax
movswl -0x18(%rbp),%ecx
sub    %ecx,%eax
movswl -0x16(%rbp),%ecx
cmp    %ecx,%eax
jl     1240 <main+0xf0>
movswl -0x14(%rbp),%eax
movswl -0x18(%rbp),%ecx
sub    %ecx,%eax
add    $0x1,%eax
mov    %ax,-0x16(%rbp)
jmp    1245 <main+0xf5>
mov    -0x14(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x14(%rbp)
jmp    119e <main+0x4e>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xdb2(%rip),%rdi
lea    0xdb7(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xd8d(%rip),%rsi
movswl -0x16(%rbp),%edx
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe9b(%rip),%rdi
lea    0xea0(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r12
lea    0xe93(%rip),%rsi
lea    0xe(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1040 <fscanf@plt>
cmpw   $0x0,0xe(%rsp)
jle    1211 <main+0xc1>
mov    $0xffff,%bx
lea    0x10(%rsp),%r15
xor    %ebp,%ebp
xor    %r13d,%r13d
mov    %r12,%rdi
lea    0xe69(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    0x10(%rsp),%rdi
call   1070 <is_in_u@plt>
test   %eax,%eax
je     11ce <main+0x7e>
test   %bx,%bx
js     11f0 <main+0xa0>
cmp    0x10(%rsp),%r14
jle    11f0 <main+0xa0>
mov    $0xffff,%bx
add    $0x1,%ebp
movswl 0xe(%rsp),%eax
cmp    %eax,%ebp
jge    1214 <main+0xc4>
mov    0x10(%rsp),%r14
jmp    11a0 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
nop
test   %bx,%bx
cmovs  %ebp,%ebx
movswl %bx,%eax
mov    %ebp,%ecx
sub    %eax,%ecx
movswl %r13w,%eax
cmp    %eax,%ecx
jl     11d2 <main+0x82>
mov    %ebp,%r13d
sub    %ebx,%r13d
add    $0x1,%r13d
jmp    11d2 <main+0x82>
xor    %r13d,%r13d
mov    %r12,%rdi
call   1030 <fclose@plt>
lea    0xdf5(%rip),%rdi
lea    0xdfa(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
movswl %r13w,%edx
lea    0xdd1(%rip),%rsi
mov    %rax,%rdi
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"MAXISEQ.INP\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c"%hd\0A\00"
@.str.3 = [5 x i8] c"%ld\0A\00"
@.str.4 = [12 x i8] c"MAXISEQ.OUT\00"
@.str.5 = [2 x i8] c"w\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i16
%4 = alloca i16
%5 = alloca i16
%6 = alloca i16
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %1
%9 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %2
store i16 0, i16* %5
store i16 -1, i16* %6
%10 = load i32*, i32** %2
%11 = call i32 (i32*, i8*, ...) @fscanf(i32* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i16* %3)
store i16 0, i16* %4
br label %12
12: ; preds = %58, %0
%13 = load i16, i16* %4
%14 = sext i16 %13 to i32
%15 = load i16, i16* %3
%16 = sext i16 %15 to i32
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %61
18: ; preds = %12
%19 = load i64, i64* %7
store i64 %19, i64* %8
%20 = load i32*, i32** %2
%21 = call i32 (i32*, i8*, ...) @fscanf(i32* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64* %7)
%22 = load i64, i64* %7
%23 = call i32 @is_in_u(i64 %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %33
25: ; preds = %18
%26 = load i16, i16* %6
%27 = sext i16 %26 to i32
%28 = icmp sge i32 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = load i64, i64* %8
%31 = load i64, i64* %7
%32 = icmp sgt i64 %30, %31
br i1 %32, label %33, label %34
33: ; preds = %29, %18
store i16 -1, i16* %6
br label %58
34: ; preds = %29, %25
%35 = load i16, i16* %6
%36 = sext i16 %35 to i32
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = load i16, i16* %4
store i16 %39, i16* %6
br label %40
40: ; preds = %38, %34
%41 = load i16, i16* %4
%42 = sext i16 %41 to i32
%43 = load i16, i16* %6
%44 = sext i16 %43 to i32
%45 = sub nsw i32 %42, %44
%46 = load i16, i16* %5
%47 = sext i16 %46 to i32
%48 = icmp sge i32 %45, %47
br i1 %48, label %49, label %57
49: ; preds = %40
%50 = load i16, i16* %4
%51 = sext i16 %50 to i32
%52 = load i16, i16* %6
%53 = sext i16 %52 to i32
%54 = sub nsw i32 %51, %53
%55 = add nsw i32 %54, 1
%56 = trunc i32 %55 to i16
store i16 %56, i16* %5
br label %57
57: ; preds = %49, %40
br label %58
58: ; preds = %57, %33
%59 = load i16, i16* %4
%60 = add i16 %59, 1
store i16 %60, i16* %4
br label %12
61: ; preds = %12
%62 = load i32*, i32** %2
%63 = call i32 @fclose(i32* %62)
%64 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %64, i32** %2
%65 = load i32*, i32** %2
%66 = load i16, i16* %5
%67 = call i32 @fprintf(i32* %65, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i16 signext %66)
%68 = load i32*, i32** %2
%69 = call i32 @fclose(i32* %68)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"MAXISEQ.INP\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c"%hd\0A\00"
@.str.3 = [5 x i8] c"%ld\0A\00"
@.str.4 = [12 x i8] c"MAXISEQ.OUT\00"
@.str.5 = [2 x i8] c"w\00"
define i32 @main() {
%1 = alloca i16
%2 = alloca i64
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = bitcast i16* %1 to i8*
%5 = bitcast i64* %2 to i8*
%6 = call i32 (i32*, i8*, ...) @fscanf(i32* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i16* %1)
%7 = load i16, i16* %1
%8 = icmp sgt i16 %7, 0
br i1 %8, label %9, label %43
9: ; preds = %0, %41
%10 = phi i64 [ %42, %41 ], [ undef, %0 ]
%11 = phi i32 [ %37, %41 ], [ 0, %0 ]
%12 = phi i16 [ %36, %41 ], [ -1, %0 ]
%13 = phi i16 [ %35, %41 ], [ 0, %0 ]
%14 = call i32 (i32*, i8*, ...) @fscanf(i32* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64* %2)
%15 = load i64, i64* %2
%16 = call i32 @is_in_u(i64 %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %34, label %18
18: ; preds = %9
%19 = icmp sgt i16 %12, -1
%20 = load i64, i64* %2
%21 = icmp sgt i64 %10, %20
%22 = select i1 %19, i1 %21, i1 false
br i1 %22, label %34, label %23
23: ; preds = %18
%24 = icmp slt i16 %12, 0
%25 = trunc i32 %11 to i16
%26 = select i1 %24, i16 %25, i16 %12
%27 = sext i16 %26 to i32
%28 = sub nsw i32 %11, %27
%29 = sext i16 %13 to i32
%30 = icmp slt i32 %28, %29
br i1 %30, label %34, label %31
31: ; preds = %23
%32 = trunc i32 %28 to i16
%33 = add i16 %32, 1
br label %34
34: ; preds = %9, %18, %23, %31
%35 = phi i16 [ %33, %31 ], [ %13, %23 ], [ %13, %18 ], [ %13, %9 ]
%36 = phi i16 [ %26, %31 ], [ %26, %23 ], [ -1, %18 ], [ -1, %9 ]
%37 = add nuw nsw i32 %11, 1
%38 = load i16, i16* %1
%39 = sext i16 %38 to i32
%40 = icmp slt i32 %37, %39
br i1 %40, label %41, label %43
41: ; preds = %34
%42 = load i64, i64* %2
br label %9
43: ; preds = %34, %0
%44 = phi i16 [ 0, %0 ], [ %35, %34 ]
%45 = call i32 @fclose(i32* %3)
%46 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%47 = call i32 @fprintf(i32* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i16 signext %44)
%48 = call i32 @fclose(i32* %46)
ret i32 0
}