#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(void) {
  int number = 0;
  int counter = 1;
  printf("Enter the number:");
  scanf("%d", &number);
  int largest = number;
  int second_largest = number;
  while (counter != 3) {
    counter++;
    printf("Enter the number:");
    scanf("%d", &number);
    if (number > largest) {
      second_largest = largest;
      largest = number;
    } else if (number < largest) {
      if ((counter == 2)) {
        second_largest = number;
      } else if (number > second_largest) {
        second_largest = number;
      } else if (largest == second_largest) {
        second_largest = number;
      }
    }
  }
  printf("counter is %d\n", counter);
  printf("largest Number is: %d\n", largest);
  printf("second largest Number is: %d\n", second_largest);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x3,-0xc(%rbp)
je     1218 <main+0xf8>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe83(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11b5 <main+0x95>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1213 <main+0xf3>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    120e <main+0xee>
cmpl   $0x2,-0xc(%rbp)
jne    11d6 <main+0xb6>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1209 <main+0xe9>
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    11ed <main+0xcd>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1204 <main+0xe4>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    11ff <main+0xdf>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1204 <main+0xe4>
jmp    1209 <main+0xe9>
jmp    120e <main+0xee>
jmp    1213 <main+0xf3>
jmp    1167 <main+0x47>
mov    -0xc(%rbp),%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xde0(%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
movl   $0x0,0x4(%rsp)
lea    0xec6(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec7(%rip),%r15
lea    0x4(%rsp),%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%ebx
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%r13d
cmp    %ebx,%r13d
mov    %ebx,%ebp
cmovl  %r13d,%ebp
cmovle %ebx,%r13d
cmovg  %ebx,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    %r13d,%eax
jle    11ac <main+0x8c>
mov    %eax,%r14d
jmp    11c6 <main+0xa6>
jge    11c0 <main+0xa0>
cmp    %ebp,%eax
jg     11b8 <main+0x98>
cmp    %ebp,%r13d
cmovne %ebp,%eax
mov    %r13d,%r14d
mov    %eax,%r13d
jmp    11c6 <main+0xa6>
mov    %r13d,%r14d
mov    %ebp,%r13d
lea    0xe48(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe4b(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe33(%rip),%rdi
mov    %r13d,%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 = [18 x i8] c"Enter the number:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c"counter is %d\0A\00"
@.str.3 = [23 x i8] c"largest Number is: %d\0A\00"
@.str.4 = [30 x i8] c"second largest Number is: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 1, i32* %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
store i32 %8, i32* %4
%9 = load i32, i32* %2
store i32 %9, i32* %5
br label %10
10: ; preds = %49, %0
%11 = load i32, i32* %3
%12 = icmp ne i32 %11, 3
br i1 %12, label %13, label %50
13: ; preds = %10
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 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* %2)
%18 = load i32, i32* %2
%19 = load i32, i32* %4
%20 = icmp sgt i32 %18, %19
br i1 %20, label %21, label %24
21: ; preds = %13
%22 = load i32, i32* %4
store i32 %22, i32* %5
%23 = load i32, i32* %2
store i32 %23, i32* %4
br label %49
24: ; preds = %13
%25 = load i32, i32* %2
%26 = load i32, i32* %4
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %48
28: ; preds = %24
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, 2
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = load i32, i32* %2
store i32 %32, i32* %5
br label %47
33: ; preds = %28
%34 = load i32, i32* %2
%35 = load i32, i32* %5
%36 = icmp sgt i32 %34, %35
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = load i32, i32* %2
store i32 %38, i32* %5
br label %46
39: ; preds = %33
%40 = load i32, i32* %4
%41 = load i32, i32* %5
%42 = icmp eq i32 %40, %41
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = load i32, i32* %2
store i32 %44, i32* %5
br label %45
45: ; preds = %43, %39
br label %46
46: ; preds = %45, %37
br label %47
47: ; preds = %46, %31
br label %48
48: ; preds = %47, %24
br label %49
49: ; preds = %48, %21
br label %10
50: ; preds = %10
%51 = load i32, i32* %3
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %51)
%53 = load i32, i32* %4
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %53)
%55 = load i32, i32* %5
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %55)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Enter the number:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c"counter is %d\0A\00"
@.str.3 = [23 x i8] c"largest Number is: %d\0A\00"
@.str.4 = [30 x i8] c"second largest Number is: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 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 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, %5
%10 = icmp slt i32 %8, %5
%11 = select i1 %10, i32 %8, i32 %5
%12 = select i1 %9, i32 %8, i32 %5
%13 = select i1 %9, i32 %5, i32 %11
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%16 = load i32, i32* %1
%17 = icmp sgt i32 %16, %12
br i1 %17, label %25, label %18
18: ; preds = %0
%19 = icmp slt i32 %16, %12
br i1 %19, label %20, label %25
20: ; preds = %18
%21 = icmp sgt i32 %16, %13
br i1 %21, label %25, label %22
22: ; preds = %20
%23 = icmp eq i32 %12, %13
%24 = select i1 %23, i32 %16, i32 %13
br label %25
25: ; preds = %22, %20, %18, %0
%26 = phi i32 [ %12, %18 ], [ %16, %0 ], [ %12, %20 ], [ %12, %22 ]
%27 = phi i32 [ %13, %18 ], [ %12, %0 ], [ %16, %20 ], [ %24, %22 ]
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 3)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %27)
ret i32 0
}