#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*/ row;

/* Variables and functions */
int INT_MIN;
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  char row[12];
  int i;
  int max_diff = INT_MIN;
  int min;
  int n = atoi(fgets(row, sizeof(row), stdin));
  if (n == 0) {
    printf("err\n");
    exit(1);
  }
  min = atoi(fgets(row, sizeof(row), stdin));
  for (i = 1; i < n; i++) {
    int diff;
    int x = atoi(fgets(row, sizeof(row), stdin));
    diff = x - min;
    if (max_diff < diff) {
      max_diff = diff;
    }
    if (x < min) {
      min = x;
    }
  }
  printf("%d\n", max_diff);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e83(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
lea    -0x1c(%rbp),%rdi
mov    0x2e7b(%rip),%rax
mov    (%rax),%edx
mov    $0xc,%esi
call   1040 <fgets@plt>
mov    %eax,%edi
call   1050 <atoi@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    11a5 <main+0x65>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
lea    -0x1c(%rbp),%rdi
mov    0x2e38(%rip),%rax
mov    (%rax),%edx
mov    $0xc,%esi
call   1040 <fgets@plt>
mov    %eax,%edi
call   1050 <atoi@plt>
mov    %eax,-0x28(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    123a <main+0xfa>
lea    -0x1c(%rbp),%rdi
mov    0x2e04(%rip),%rax
mov    (%rax),%edx
mov    $0xc,%esi
call   1040 <fgets@plt>
mov    %eax,%edi
call   1050 <atoi@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
sub    -0x28(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1215 <main+0xd5>
mov    -0x30(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1227 <main+0xe7>
mov    -0x34(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    122c <main+0xec>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11cd <main+0x8d>
mov    -0x24(%rbp),%esi
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    0x2e7d(%rip),%rax
mov    (%rax),%r14d
mov    0x2e7b(%rip),%r12
mov    (%r12),%edx
lea    0x4(%rsp),%rdi
mov    $0xc,%esi
call   1050 <fgets@plt>
mov    %eax,%edi
call   1060 <atoi@plt>
test   %eax,%eax
je     120b <main+0xbb>
mov    %eax,%ebp
mov    (%r12),%edx
lea    0x4(%rsp),%rdi
mov    $0xc,%esi
call   1050 <fgets@plt>
mov    %eax,%edi
call   1060 <atoi@plt>
cmp    $0x2,%ebp
jl     11eb <main+0x9b>
mov    %eax,%ebx
add    $0xffffffff,%ebp
lea    0x4(%rsp),%r15
nopw   0x0(%rax,%rax,1)
mov    (%r12),%edx
mov    %r15,%rdi
mov    $0xc,%esi
call   1050 <fgets@plt>
mov    %eax,%edi
call   1060 <atoi@plt>
mov    %eax,%ecx
sub    %ebx,%ecx
cmovl  %eax,%ebx
cmp    %ecx,%r14d
cmovl  %ecx,%r14d
add    $0xffffffff,%ebp
jne    11c0 <main+0x70>
lea    0xe0e(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdf2(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

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

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