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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
void findSecond() {
  int array[] = {1, 23, 45, 2, 5, 6, 8, 9, 12, 4, 3, 5, 123, 234};
  int max = array[0];
  int s_max = array[1];
  int lenght = sizeof(array) / 4;
  int *p = array;
  for (int i = 0; i < lenght; i++) {
    if (*(p + i) > max) {
      s_max = max;
      max = *(p + i);
    } else if (*(p + i) > s_max) {
      s_max = *(p + i);
    }
  }
  printf("Max  = %d   SMax = %d\n", max, s_max);
}


x86 assembly (clang, -O0):
<findSecond>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    -0x40(%rbp),%rdi
lea    0xecd(%rip),%rsi
mov    $0x38,%edx
call   1040 <memcpy@plt>
mov    -0x40(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x48(%rbp)
movl   $0xe,-0x4c(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    11d2 <findSecond+0xb2>
mov    -0x58(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x44(%rbp),%eax
jle    1198 <findSecond+0x78>
mov    -0x44(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x58(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x44(%rbp)
jmp    11bf <findSecond+0x9f>
mov    -0x58(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x48(%rbp),%eax
jle    11ba <findSecond+0x9a>
mov    -0x58(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x48(%rbp)
jmp    11bf <findSecond+0x9f>
jmp    11c4 <findSecond+0xa4>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    115f <findSecond+0x3f>
mov    -0x44(%rbp),%esi
mov    -0x48(%rbp),%edx
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findSecond>:
lea    0xee9(%rip),%rdi
mov    $0xea,%esi
mov    $0x7b,%edx
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [23 x i8] c"Max = %d SMax = %d\0A\00"
define void @findSecond() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 234, i32 123)
ret void
}