#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 a[10];
  int max = a[0];
  int secondmax = a[1];
  int i = 0;
  for (i = 0; i < 10; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 2; i < 10; i++) {
    if (a[i] > secondmax) {
      if (a[i] > max) {
        secondmax = max;
        max = a[i];
      } else {
        secondmax = a[i];
      }
    }
  }
  printf("%d\n", secondmax);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0xa,-0x3c(%rbp)
jge    117c <main+0x5c>
movslq -0x3c(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe97(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1149 <main+0x29>
movl   $0x2,-0x3c(%rbp)
cmpl   $0xa,-0x3c(%rbp)
jge    11e8 <main+0xc8>
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
cmp    -0x38(%rbp),%eax
jle    11d5 <main+0xb5>
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
cmp    -0x34(%rbp),%eax
jle    11c5 <main+0xa5>
mov    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x34(%rbp)
jmp    11d0 <main+0xb0>
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x38(%rbp)
jmp    11d5 <main+0xb5>
jmp    11da <main+0xba>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1183 <main+0x63>
mov    -0x38(%rbp),%esi
lea    0xe11(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0x4(%rsp),%r14
lea    0xecd(%rip),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x24(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %11)
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %13)
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %15)
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %17)
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %19)
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 undef)
ret i32 0
}