#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 i;
  int counter, number;
  int largest = 0, secondLargest = 0;
  for (i = 0; i < 10; i++) {
    printf("Input number: ");
    scanf("%d", &number);
    if (number > largest) {
      secondLargest = largest;
      largest = number;
    } else if (number > secondLargest)
      secondLargest = number;
  }
  printf("The two largest numbers entered were %d and %d\n", secondLargest,
         largest);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11b3 <main+0x93>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeac(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    1189 <main+0x69>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11a0 <main+0x80>
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    119b <main+0x7b>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11a0 <main+0x80>
jmp    11a5 <main+0x85>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1144 <main+0x24>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe52(%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
push   %rax
lea    0xece(%rip),%r14
xor    %ebp,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeca(%rip),%r12
lea    0x4(%rsp),%r15
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%r13d
test   %r13d,%r13d
cmovs  %ebp,%r13d
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%ebx
test   %ebx,%ebx
mov    $0x0,%ebp
cmovns %ebx,%ebp
cmp    %r13d,%ebx
cmovle %r13d,%ebx
cmovg  %r13d,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%r13d
cmp    %ebp,%r13d
cmovg  %r13d,%ebp
cmp    %ebx,%r13d
cmovle %ebx,%r13d
cmovg  %ebx,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%ebx
cmp    %ebp,%ebx
cmovg  %ebx,%ebp
cmp    %r13d,%ebx
cmovle %r13d,%ebx
cmovg  %r13d,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%r13d
cmp    %ebp,%r13d
cmovg  %r13d,%ebp
cmp    %ebx,%r13d
cmovle %ebx,%r13d
cmovg  %ebx,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%ebx
cmp    %ebp,%ebx
cmovg  %ebx,%ebp
cmp    %r13d,%ebx
cmovle %r13d,%ebx
cmovg  %r13d,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%r13d
cmp    %ebp,%r13d
cmovg  %r13d,%ebp
cmp    %ebx,%r13d
cmovle %ebx,%r13d
cmovg  %ebx,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%ebx
cmp    %ebp,%ebx
cmovg  %ebx,%ebp
cmp    %r13d,%ebx
cmovle %r13d,%ebx
cmovg  %r13d,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%r13d
cmp    %ebp,%r13d
cmovg  %r13d,%ebp
cmp    %ebx,%r13d
cmovle %ebx,%r13d
cmovg  %ebx,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%edx
cmp    %ebp,%edx
cmovg  %edx,%ebp
cmp    %r13d,%edx
cmovle %r13d,%edx
cmovg  %r13d,%ebp
lea    0xd2c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Input number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [48 x i8] c"The two largest numbers entered were %d and %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %2
br label %7
7: ; preds = %27, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %30
10: ; preds = %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = icmp sgt i32 %13, %14
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = load i32, i32* %5
store i32 %17, i32* %6
%18 = load i32, i32* %4
store i32 %18, i32* %5
br label %26
19: ; preds = %10
%20 = load i32, i32* %4
%21 = load i32, i32* %6
%22 = icmp sgt i32 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = load i32, i32* %4
store i32 %24, i32* %6
br label %25
25: ; preds = %23, %19
br label %26
26: ; preds = %25, %16
br label %27
27: ; preds = %26
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
br label %7
30: ; preds = %7
%31 = load i32, i32* %6
%32 = load i32, i32* %5
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %31, i32 %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"Input number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [48 x i8] c"The two largest numbers entered were %d and %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
%7 = select i1 %6, i32 %5, i32 0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, %7
%12 = icmp sgt i32 %10, 0
%13 = select i1 %12, i32 %10, i32 0
%14 = select i1 %11, i32 %10, i32 %7
%15 = select i1 %11, i32 %7, i32 %13
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%18 = load i32, i32* %1
%19 = icmp sgt i32 %18, %14
%20 = icmp sgt i32 %18, %15
%21 = select i1 %20, i32 %18, i32 %15
%22 = select i1 %19, i32 %18, i32 %14
%23 = select i1 %19, i32 %14, i32 %21
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%26 = load i32, i32* %1
%27 = icmp sgt i32 %26, %22
%28 = icmp sgt i32 %26, %23
%29 = select i1 %28, i32 %26, i32 %23
%30 = select i1 %27, i32 %26, i32 %22
%31 = select i1 %27, i32 %22, i32 %29
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%34 = load i32, i32* %1
%35 = icmp sgt i32 %34, %30
%36 = icmp sgt i32 %34, %31
%37 = select i1 %36, i32 %34, i32 %31
%38 = select i1 %35, i32 %34, i32 %30
%39 = select i1 %35, i32 %30, i32 %37
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%41 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%42 = load i32, i32* %1
%43 = icmp sgt i32 %42, %38
%44 = icmp sgt i32 %42, %39
%45 = select i1 %44, i32 %42, i32 %39
%46 = select i1 %43, i32 %42, i32 %38
%47 = select i1 %43, i32 %38, i32 %45
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%49 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%50 = load i32, i32* %1
%51 = icmp sgt i32 %50, %46
%52 = icmp sgt i32 %50, %47
%53 = select i1 %52, i32 %50, i32 %47
%54 = select i1 %51, i32 %50, i32 %46
%55 = select i1 %51, i32 %46, i32 %53
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%57 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%58 = load i32, i32* %1
%59 = icmp sgt i32 %58, %54
%60 = icmp sgt i32 %58, %55
%61 = select i1 %60, i32 %58, i32 %55
%62 = select i1 %59, i32 %58, i32 %54
%63 = select i1 %59, i32 %54, i32 %61
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%65 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%66 = load i32, i32* %1
%67 = icmp sgt i32 %66, %62
%68 = icmp sgt i32 %66, %63
%69 = select i1 %68, i32 %66, i32 %63
%70 = select i1 %67, i32 %66, i32 %62
%71 = select i1 %67, i32 %62, i32 %69
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%73 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%74 = load i32, i32* %1
%75 = icmp sgt i32 %74, %70
%76 = icmp sgt i32 %74, %71
%77 = select i1 %76, i32 %74, i32 %71
%78 = select i1 %75, i32 %74, i32 %70
%79 = select i1 %75, i32 %70, i32 %77
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %79, i32 %78)
ret i32 0
}