#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 */
scalar_t__ EOF;
int INT_MIN;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, int *);
int main() {
  int input;
  int largest;
  int amtLargestNumEntered = 0;
  largest = INT_MIN;
  printf("\nPlease enter an integer: ");
  while (scanf("%d", &input) != EOF) {
    if (input >= largest) {
      if (input > largest) {
        amtLargestNumEntered = 1;
        largest = input;
        printf("Largest number entered so far: %d", largest);
      } else {
        amtLargestNumEntered++;
        printf("Number of times Largest Number entered: %d",
               amtLargestNumEntered);
      }
    }
    printf("\nEnter next integer, <EOF> to stop: ");
  }
  printf("\n\nThe largest value entered is %d and it was entered %d times.\n",
         largest, amtLargestNumEntered);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
mov    0x2ea3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2e81(%rip),%rcx
cmp    (%rcx),%rax
je     11dd <main+0xbd>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     11ca <main+0xaa>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11ab <main+0x8b>
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c5 <main+0xa5>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ca <main+0xaa>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1150 <main+0x30>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2eae(%rip),%rax
mov    (%rax),%r13d
lea    0xec4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf19(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x2e8b(%rip),%rbp
cmp    0x0(%rbp),%rax
jne    118a <main+0x6a>
mov    %r13d,%r14d
lea    0xf20(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
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
lea    0xed4(%rip),%r15
lea    0x4(%rsp),%r12
xor    %ebx,%ebx
jmp    11d8 <main+0xb8>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
lea    0xe93(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13d,%r14d
lea    0xeab(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    %r14d,%r13d
cmp    0x0(%rbp),%rax
je     1166 <main+0x46>
mov    0x4(%rsp),%r14d
cmp    %r13d,%r14d
jl     11b3 <main+0x93>
jle    11a0 <main+0x80>
lea    0xe30(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebx
jmp    11b6 <main+0x96>

LLVM IR (-O0):
@INT_MIN = global i32 0
@.str = [27 x i8] c"\0APlease enter an integer: \00"
@.str.1 = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.2 = [34 x i8] c"Largest number entered so far: %d\00"
@.str.3 = [43 x i8] c"Number of times Largest Number entered: %d\00"
@.str.4 = [37 x i8] c"\0AEnter next integer, <EOF> to stop: \00"
@.str.5 = [64 x i8] c"\0A\0AThe largest value entered is %d and it was entered %d times.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%5 = load i32, i32* @INT_MIN
store i32 %5, i32* %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %29, %0
%8 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i64, i64* @EOF
%10 = icmp ne i64 %8, %9
br i1 %10, label %11, label %31
11: ; preds = %7
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = icmp sge i32 %12, %13
br i1 %14, label %15, label %29
15: ; preds = %11
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = icmp sgt i32 %16, %17
br i1 %18, label %19, label %23
19: ; preds = %15
store i32 1, i32* %4
%20 = load i32, i32* %2
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %28
23: ; preds = %15
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
%26 = load i32, i32* %4
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %23, %19
br label %29
29: ; preds = %28, %11
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
br label %7
31: ; preds = %7
%32 = load i32, i32* %3
%33 = load i32, i32* %4
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0), i32 %32, i32 %33)
ret i32 0
}

LLVM IR (-O2):
@INT_MIN = global i32 0
@.str = [27 x i8] c"\0APlease enter an integer: \00"
@.str.1 = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.2 = [34 x i8] c"Largest number entered so far: %d\00"
@.str.3 = [43 x i8] c"Number of times Largest Number entered: %d\00"
@.str.4 = [37 x i8] c"\0AEnter next integer, <EOF> to stop: \00"
@.str.5 = [64 x i8] c"\0A\0AThe largest value entered is %d and it was entered %d times.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = load i32, i32* @INT_MIN
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%5 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i64, i64* @EOF
%7 = icmp eq i64 %5, %6
br i1 %7, label %27, label %8
8: ; preds = %0, %20
%9 = phi i32 [ %22, %20 ], [ 0, %0 ]
%10 = phi i32 [ %21, %20 ], [ %3, %0 ]
%11 = load i32, i32* %1
%12 = icmp slt i32 %11, %10
br i1 %12, label %20, label %13
13: ; preds = %8
%14 = icmp sgt i32 %11, %10
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %11)
br label %20
17: ; preds = %13
%18 = add nsw i32 %9, 1
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %15, %17, %8
%21 = phi i32 [ %11, %15 ], [ %10, %17 ], [ %10, %8 ]
%22 = phi i32 [ 1, %15 ], [ %18, %17 ], [ %9, %8 ]
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%24 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%25 = load i64, i64* @EOF
%26 = icmp eq i64 %24, %25
br i1 %26, label %27, label %8
27: ; preds = %20, %0
%28 = phi i32 [ %3, %0 ], [ %21, %20 ]
%29 = phi i32 [ 0, %0 ], [ %22, %20 ]
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0), i32 %28, i32 %29)
ret i32 0
}