#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 EOF;
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, int *);
int main() {
  int c;
  int count = 1;
  int largest = 0;
  int smallest = 0;
  int res;
  while ((res = scanf("%d", &c)) != EOF) {
    if (res != 1) {
      printf("corrupt input\n");
      break;
    } else if (count == 1) {
      smallest = c;
      largest = c;
      count++;
    } else if (largest < c) {
      largest = c;
      count++;
    } else if (smallest > c) {
      smallest = c;
      count++;
    }
  }
  printf("%d %d are smallest and largest \n", smallest, largest);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeb5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%eax
je     11f6 <main+0xd6>
cmpl   $0x1,-0x18(%rbp)
je     1183 <main+0x63>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f6 <main+0xd6>
cmpl   $0x1,-0xc(%rbp)
jne    11a7 <main+0x87>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ec <main+0xcc>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c7 <main+0xa7>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11e7 <main+0xc7>
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    11e2 <main+0xc2>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11e7 <main+0xc7>
jmp    11ec <main+0xcc>
jmp    11f1 <main+0xd1>
jmp    1144 <main+0x24>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe0f(%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    0xebe(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2e95(%rip),%r12
xor    %ebx,%ebx
mov    $0x0,%r13d
cmp    (%r12),%eax
je     11e3 <main+0xb3>
xor    %r13d,%r13d
mov    $0x1,%ecx
lea    0x4(%rsp),%r15
xor    %ebp,%ebp
jmp    119d <main+0x6d>
cs nopw 0x0(%rax,%rax,1)
mov    %ebx,%r13d
lea    0xe76(%rip),%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    %r14d,%ecx
mov    %ebx,%ebp
cmp    (%r12),%eax
je     11e3 <main+0xb3>
cmp    $0x1,%eax
jne    11d5 <main+0xa5>
mov    $0x2,%r14d
mov    0x4(%rsp),%ebx
cmp    $0x1,%ecx
je     1180 <main+0x50>
cmp    %ebx,%ebp
jge    11c0 <main+0x90>
add    $0x1,%ecx
jmp    11d0 <main+0xa0>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
cmp    %ebx,%r13d
setg   %al
cmovg  %ebx,%r13d
add    %eax,%ecx
mov    %ebp,%ebx
mov    %ecx,%r14d
jmp    1183 <main+0x53>
lea    0xe48(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%ebx
lea    0xe19(%rip),%rdi
mov    %r13d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <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 = [3 x i8] c"%d\00"
@EOF = global i32 0
@.str.1 = [15 x i8] c"corrupt input\0A\00"
@.str.2 = [33 x i8] c"%d %d are smallest and largest \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 1, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %43, %0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 %8, i32* %6
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %8, %9
br i1 %10, label %11, label %44
11: ; preds = %7
%12 = load i32, i32* %6
%13 = icmp ne i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %44
16: ; preds = %11
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = load i32, i32* %2
store i32 %20, i32* %5
%21 = load i32, i32* %2
store i32 %21, i32* %4
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %42
24: ; preds = %16
%25 = load i32, i32* %4
%26 = load i32, i32* %2
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i32, i32* %2
store i32 %29, i32* %4
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %41
32: ; preds = %24
%33 = load i32, i32* %5
%34 = load i32, i32* %2
%35 = icmp sgt i32 %33, %34
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = load i32, i32* %2
store i32 %37, i32* %5
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %40
40: ; preds = %36, %32
br label %41
41: ; preds = %40, %28
br label %42
42: ; preds = %41, %19
br label %43
43: ; preds = %42
br label %7
44: ; preds = %14, %7
%45 = load i32, i32* %5
%46 = load i32, i32* %4
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %45, i32 %46)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EOF = global i32 0
@.str.2 = [33 x i8] c"%d %d are smallest and largest \0A\00"
@str = [14 x i8] c"corrupt input\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %33, label %6
6: ; preds = %0, %26
%7 = phi i32 [ %30, %26 ], [ %3, %0 ]
%8 = phi i32 [ %29, %26 ], [ 1, %0 ]
%9 = phi i32 [ %28, %26 ], [ 0, %0 ]
%10 = phi i32 [ %27, %26 ], [ 0, %0 ]
%11 = icmp eq i32 %7, 1
br i1 %11, label %14, label %12
12: ; preds = %6
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %33
14: ; preds = %6
%15 = icmp eq i32 %8, 1
%16 = load i32, i32* %1
br i1 %15, label %26, label %17
17: ; preds = %14
%18 = icmp slt i32 %10, %16
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = add nsw i32 %8, 1
br label %26
21: ; preds = %17
%22 = icmp sgt i32 %9, %16
%23 = select i1 %22, i32 %16, i32 %9
%24 = zext i1 %22 to i32
%25 = add nsw i32 %8, %24
br label %26
26: ; preds = %14, %21, %19
%27 = phi i32 [ %16, %19 ], [ %10, %21 ], [ %16, %14 ]
%28 = phi i32 [ %9, %19 ], [ %23, %21 ], [ %16, %14 ]
%29 = phi i32 [ %20, %19 ], [ %25, %21 ], [ 2, %14 ]
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%31 = load i32, i32* @EOF
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %6
33: ; preds = %26, %0, %12
%34 = phi i32 [ %10, %12 ], [ 0, %0 ], [ %27, %26 ]
%35 = phi i32 [ %9, %12 ], [ 0, %0 ], [ %28, %26 ]
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %35, i32 %34)
ret i32 0
}