#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__ malloc(int);
int max(int, int);
int min(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, numbers_len;
  printf("How many numbers? ");
  scanf("%d", &numbers_len);
  int *numbers = (int *)malloc(numbers_len * sizeof(int));
  for (i = 0; i < numbers_len; i++) {
    printf("N[%d] = ", i);
    scanf("%d", numbers + i);
  }
  int big = *numbers;
  int small = numbers[0];
  for (i = 1; i < numbers_len; i++) {
    big = max(big, *(numbers + i));
    small = min(small, numbers[i]);
  }
  printf("The small number is %d\n", small);
  printf("The big number is %d\n", big);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9f(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11dd <main+0x8d>
mov    -0x8(%rbp),%esi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe49(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1197 <main+0x47>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    123c <main+0xec>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1050 <max@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1040 <min@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11f6 <main+0xa6>
mov    -0x20(%rbp),%esi
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xde0(%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   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
cmpl   $0x0,0xc(%rsp)
jle    121c <main+0xcc>
lea    0xe7a(%rip),%r15
lea    0xe70(%rip),%r12
mov    %r14,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
add    $0x1,%rbp
movslq 0xc(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     11b0 <main+0x60>
mov    (%r14),%ebp
cmp    $0x2,%eax
jl     1224 <main+0xd4>
mov    $0x1,%ebx
mov    %ebp,%r15d
nopl   0x0(%rax)
mov    (%r14,%rbx,4),%esi
mov    %r15d,%edi
call   1050 <max@plt>
mov    %eax,%r15d
mov    (%r14,%rbx,4),%esi
mov    %ebp,%edi
call   1040 <min@plt>
mov    %eax,%ebp
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11f0 <main+0xa0>
jmp    1227 <main+0xd7>
mov    (%r14),%r15d
mov    %r15d,%ebp
jmp    1227 <main+0xd7>
mov    %ebp,%r15d
lea    0xdf1(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xdf9(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"How many numbers? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"N[%d] = \00"
@.str.3 = [24 x i8] c"The small number is %d\0A\00"
@.str.4 = [22 x i8] c"The big number is %d\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 ([19 x i8], [19 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)
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = mul i64 %10, 4
%12 = trunc i64 %11 to i32
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i32*
store i32* %14, i32** %4
store i32 0, i32* %2
br label %15
15: ; preds = %27, %0
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %30
19: ; preds = %15
%20 = load i32, i32* %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = load i32*, i32** %4
%23 = load i32, i32* %2
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %25)
br label %27
27: ; preds = %19
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
br label %15
30: ; preds = %15
%31 = load i32*, i32** %4
%32 = load i32, i32* %31
store i32 %32, i32* %5
%33 = load i32*, i32** %4
%34 = getelementptr inbounds i32, i32* %33, i64 0
%35 = load i32, i32* %34
store i32 %35, i32* %6
store i32 1, i32* %2
br label %36
36: ; preds = %55, %30
%37 = load i32, i32* %2
%38 = load i32, i32* %3
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %58
40: ; preds = %36
%41 = load i32, i32* %5
%42 = load i32*, i32** %4
%43 = load i32, i32* %2
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
%46 = load i32, i32* %45
%47 = call i32 @max(i32 %41, i32 %46)
store i32 %47, i32* %5
%48 = load i32, i32* %6
%49 = load i32*, i32** %4
%50 = load i32, i32* %2
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %49, i64 %51
%53 = load i32, i32* %52
%54 = call i32 @min(i32 %48, i32 %53)
store i32 %54, i32* %6
br label %55
55: ; preds = %40
%56 = load i32, i32* %2
%57 = add nsw i32 %56, 1
store i32 %57, i32* %2
br label %36
58: ; preds = %36
%59 = load i32, i32* %6
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %59)
%61 = load i32, i32* %5
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %1
ret i32 %63
}

LLVM IR (-O2):
@.str = [19 x i8] c"How many numbers? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"N[%d] = \00"
@.str.3 = [24 x i8] c"The small number is %d\0A\00"
@.str.4 = [22 x i8] c"The big number is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 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 = shl i32 %5, 2
%7 = call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i32*
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %0
%12 = load i32, i32* %8
br label %39
13: ; preds = %0, %13
%14 = phi i64 [ %19, %13 ], [ 0, %0 ]
%15 = trunc i64 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds i32, i32* %8, i64 %14
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %17)
%19 = add nuw nsw i64 %14, 1
%20 = load i32, i32* %1
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %13, label %23
23: ; preds = %13
%24 = load i32, i32* %8
%25 = icmp sgt i32 %20, 1
br i1 %25, label %26, label %39
26: ; preds = %23, %26
%27 = phi i64 [ %35, %26 ], [ 1, %23 ]
%28 = phi i32 [ %34, %26 ], [ %24, %23 ]
%29 = phi i32 [ %32, %26 ], [ %24, %23 ]
%30 = getelementptr inbounds i32, i32* %8, i64 %27
%31 = load i32, i32* %30
%32 = call i32 @max(i32 %29, i32 %31)
%33 = load i32, i32* %30
%34 = call i32 @min(i32 %28, i32 %33)
%35 = add nuw nsw i64 %27, 1
%36 = load i32, i32* %1
%37 = sext i32 %36 to i64
%38 = icmp slt i64 %35, %37
br i1 %38, label %26, label %39
39: ; preds = %26, %11, %23
%40 = phi i32 [ %24, %23 ], [ %12, %11 ], [ %32, %26 ]
%41 = phi i32 [ %24, %23 ], [ %12, %11 ], [ %34, %26 ]
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %40)
ret i32 0
}