#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 x, y, small, big, n;
  printf("How many numbers do you want: ");
  scanf("%d", &y);
  for (x = 1; x <= y; x++) {
    printf("Enter a number: ");
    scanf("%d", &n);
    if (x == 1) {
      big = n;
      small = n;
    } else {
      if (n > big) {
        big = n;
      }
      if (n < small) {
        small = n;
      }
    }
  }
  printf("%d is the largest \n", big);
  printf("%d is the smallest\n", small);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11d5 <main+0xb5>
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaa(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    1199 <main+0x79>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11c2 <main+0xa2>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    11ab <main+0x8b>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11bd <main+0x9d>
mov    -0x18(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11c2 <main+0xa2>
jmp    11c7 <main+0xa7>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1154 <main+0x34>
mov    -0x14(%rbp),%esi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%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),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedf(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xece(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    (%rsp),%r13d
cmpl   $0x2,0x4(%rsp)
jl     11bf <main+0x9f>
mov    $0x1,%ebx
lea    0xea5(%rip),%r14
lea    0xe9b(%rip),%r15
mov    %rsp,%r12
mov    %r13d,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%eax
cmp    %r13d,%eax
cmovg  %eax,%r13d
cmp    %ebp,%eax
cmovl  %eax,%ebp
add    $0x1,%ebx
cmp    0x4(%rsp),%ebx
jl     1190 <main+0x70>
jmp    11c2 <main+0xa2>
mov    %r13d,%ebp
lea    0xe6a(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe6d(%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 = [31 x i8] c"How many numbers do you want: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"Enter a number: \00"
@.str.3 = [20 x i8] c"%d is the largest \0A\00"
@.str.4 = [20 x i8] c"%d is the smallest\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
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 1, i32* %2
br label %9
9: ; preds = %35, %0
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %38
13: ; preds = %9
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i32, i32* %6
store i32 %19, i32* %5
%20 = load i32, i32* %6
store i32 %20, i32* %4
br label %34
21: ; preds = %13
%22 = load i32, i32* %6
%23 = load i32, i32* %5
%24 = icmp sgt i32 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = load i32, i32* %6
store i32 %26, i32* %5
br label %27
27: ; preds = %25, %21
%28 = load i32, i32* %6
%29 = load i32, i32* %4
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = load i32, i32* %6
store i32 %32, i32* %4
br label %33
33: ; preds = %31, %27
br label %34
34: ; preds = %33, %18
br label %35
35: ; preds = %34
%36 = load i32, i32* %2
%37 = add nsw i32 %36, 1
store i32 %37, i32* %2
br label %9
38: ; preds = %9
%39 = load i32, i32* %5
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %4
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@.str = [31 x i8] c"How many numbers do you want: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"Enter a number: \00"
@.str.3 = [20 x i8] c"%d is the largest \0A\00"
@.str.4 = [20 x i8] c"%d is the smallest\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 0
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
%12 = load i32, i32* %1
%13 = icmp sgt i32 %12, 1
br i1 %13, label %14, label %28
14: ; preds = %0, %14
%15 = phi i32 [ %22, %14 ], [ %11, %0 ]
%16 = phi i32 [ %24, %14 ], [ %11, %0 ]
%17 = phi i32 [ %25, %14 ], [ 2, %0 ]
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%20 = load i32, i32* %2
%21 = icmp sgt i32 %20, %15
%22 = select i1 %21, i32 %20, i32 %15
%23 = icmp slt i32 %20, %16
%24 = select i1 %23, i32 %20, i32 %16
%25 = add nuw nsw i32 %17, 1
%26 = load i32, i32* %1
%27 = icmp slt i32 %17, %26
br i1 %27, label %14, label %28
28: ; preds = %14, %0
%29 = phi i32 [ %11, %0 ], [ %24, %14 ]
%30 = phi i32 [ %11, %0 ], [ %22, %14 ]
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %29)
ret i32 0
}