#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 scanf(char *, int *);
int main(int argc, const char *argv[]) {
  int temp;
  int max = 0;
  int min = 0;
  printf("Enter array of numbers (press enter after each number | 0 Exists): \n"
         "-----------------------------------------------------------------\n");
  while (scanf("%d", &temp), temp != 0) {
    if (temp > max) {
      max = temp;
    } else if (temp < min || min == 0) {
      min = temp;
    }
  }
  printf("MAX: %d\nMIN: %d\n", max, min);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf2e(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x14(%rbp)
je     11a9 <main+0x89>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    1183 <main+0x63>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11a4 <main+0x84>
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     1199 <main+0x79>
cmpl   $0x0,-0x1c(%rbp)
jne    119f <main+0x7f>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11a4 <main+0x84>
jmp    1152 <main+0x32>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xed4(%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   %rbx
push   %rax
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     1199 <main+0x69>
xor    %ebx,%ebx
lea    0xe9b(%rip),%r14
lea    0x4(%rsp),%r15
xor    %ebp,%ebp
nopl   0x0(%rax)
cmp    %ebx,%eax
mov    %ebx,%ecx
cmovl  %eax,%ecx
test   %ebx,%ebx
cmove  %eax,%ecx
cmp    %ebp,%eax
cmovg  %eax,%ebp
cmovle %ecx,%ebx
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jne    1170 <main+0x40>
jmp    119d <main+0x6d>
xor    %ebp,%ebp
xor    %ebx,%ebx
lea    0xe5f(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [135 x i8] c"Enter array of numbers (press enter after each number | 0 Exists): \0A-----------------------------------------------------------------\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"MAX: %d\0AMIN: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %30, %2
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%12 = load i32, i32* %6
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %31
14: ; preds = %10
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = icmp sgt i32 %15, %16
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = load i32, i32* %6
store i32 %19, i32* %7
br label %30
20: ; preds = %14
%21 = load i32, i32* %6
%22 = load i32, i32* %8
%23 = icmp slt i32 %21, %22
br i1 %23, label %27, label %24
24: ; preds = %20
%25 = load i32, i32* %8
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24, %20
%28 = load i32, i32* %6
store i32 %28, i32* %8
br label %29
29: ; preds = %27, %24
br label %30
30: ; preds = %29, %18
br label %10
31: ; preds = %10
%32 = load i32, i32* %7
%33 = load i32, i32* %8
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %32, i32 %33)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"MAX: %d\0AMIN: %d\0A\00"
@str = [134 x i8] c"Enter array of numbers (press enter after each number | 0 Exists): \0A-----------------------------------------------------------------\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([134 x i8], [134 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* %3)
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 0
br i1 %8, label %23, label %9
9: ; preds = %2, %9
%10 = phi i32 [ %21, %9 ], [ %7, %2 ]
%11 = phi i32 [ %19, %9 ], [ 0, %2 ]
%12 = phi i32 [ %18, %9 ], [ 0, %2 ]
%13 = icmp sgt i32 %10, %12
%14 = icmp slt i32 %10, %11
%15 = icmp eq i32 %11, 0
%16 = or i1 %15, %14
%17 = select i1 %16, i32 %10, i32 %11
%18 = select i1 %13, i32 %10, i32 %12
%19 = select i1 %13, i32 %11, i32 %17
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %9
23: ; preds = %9, %2
%24 = phi i32 [ 0, %2 ], [ %18, %9 ]
%25 = phi i32 [ 0, %2 ], [ %19, %9 ]
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %24, i32 %25)
ret i32 0
}