#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() {
  int n, i, min, max;
  int t[n];
  printf("Podaj ilość elementów w tablicy: ");
  scanf("%d", &n);
  printf("Podaj %d liczb całkowitych:\n", n);
  for (i = 0; i <= n; i++) {
    scanf("%d", &t[i]);
    if (i == 0) {
      max = t[i];
      min = t[i];
    } else {
      if (t[i] > max) {
        max = t[i];
      } else if (t[i] < min) {
        min = t[i];
      }
    }
  }
  printf("max=%d", max);
  printf("min=%d", min);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1240 <main+0x120>
mov    -0x30(%rbp),%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xea0(%rip),%rdi
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11da <main+0xba>
mov    -0x30(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
mov    %ecx,-0x14(%rbp)
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x10(%rbp)
jmp    122d <main+0x10d>
mov    -0x30(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x14(%rbp),%eax
jle    1201 <main+0xe1>
mov    -0x30(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
jmp    1228 <main+0x108>
mov    -0x30(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x10(%rbp),%eax
jge    1223 <main+0x103>
mov    -0x30(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x10(%rbp)
jmp    1228 <main+0x108>
jmp    122d <main+0x10d>
jmp    1232 <main+0x112>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118c <main+0x6c>
mov    -0x14(%rbp),%esi
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsp,%r12
lea    0xecb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf0b(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
lea    0xeca(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    (%rsp),%r14d
cmpl   $0x0,0x4(%rsp)
jle    11c6 <main+0xa6>
lea    0x4(%rsp),%rbx
xor    %ebp,%ebp
lea    0xec8(%rip),%r15
mov    %r14d,%r13d
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%eax
cmp    %r14d,%eax
mov    %r14d,%ecx
cmovl  %eax,%ecx
cmp    %r13d,%eax
cmovg  %eax,%r13d
cmovle %ecx,%r14d
movslq 0x4(%rsp),%rax
add    $0x4,%rbx
add    $0x1,%rbp
cmp    %rax,%rbp
jl     1190 <main+0x70>
jmp    11c9 <main+0xa9>
mov    %r14d,%r13d
lea    0xe73(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe69(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rsp
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Podaj ilo\C5\9B\C4\87 element\C3\B3w w tablicy: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"Podaj %d liczb ca\C5\82kowitych:\0A\00"
@.str.3 = [7 x i8] c"max=%d\00"
@.str.4 = [7 x i8] c"min=%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
store i32 0, i32* %1
%8 = load i32, i32* %2
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %6
%11 = alloca i32, i64 %9
store i64 %9, i64* %7
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %14)
store i32 0, i32* %3
br label %16
16: ; preds = %63, %0
%17 = load i32, i32* %3
%18 = load i32, i32* %2
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %66
20: ; preds = %16
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %11, i64 %22
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %23)
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %36
27: ; preds = %20
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %11, i64 %29
%31 = load i32, i32* %30
store i32 %31, i32* %5
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %11, i64 %33
%35 = load i32, i32* %34
store i32 %35, i32* %4
br label %62
36: ; preds = %20
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %11, i64 %38
%40 = load i32, i32* %39
%41 = load i32, i32* %5
%42 = icmp sgt i32 %40, %41
br i1 %42, label %43, label %48
43: ; preds = %36
%44 = load i32, i32* %3
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %11, i64 %45
%47 = load i32, i32* %46
store i32 %47, i32* %5
br label %61
48: ; preds = %36
%49 = load i32, i32* %3
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %11, i64 %50
%52 = load i32, i32* %51
%53 = load i32, i32* %4
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %60
55: ; preds = %48
%56 = load i32, i32* %3
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i32, i32* %11, i64 %57
%59 = load i32, i32* %58
store i32 %59, i32* %4
br label %60
60: ; preds = %55, %48
br label %61
61: ; preds = %60, %43
br label %62
62: ; preds = %61, %27
br label %63
63: ; preds = %62
%64 = load i32, i32* %3
%65 = add nsw i32 %64, 1
store i32 %65, i32* %3
br label %16
66: ; preds = %16
%67 = load i32, i32* %5
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %67)
%69 = load i32, i32* %4
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %69)
%71 = load i8*, i8** %6
%72 = load i32, i32* %1
ret i32 %72
}

LLVM IR (-O2):
@.str = [37 x i8] c"Podaj ilo\C5\9B\C4\87 element\C3\B3w w tablicy: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"Podaj %d liczb ca\C5\82kowitych:\0A\00"
@.str.3 = [7 x i8] c"max=%d\00"
@.str.4 = [7 x i8] c"min=%d\00"
define i32 @main() {
%1 = alloca [0 x i32]
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i8* @llvm.stacksave()
%5 = getelementptr inbounds [0 x i32], [0 x i32]* %1, i64 0, i64 0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, -1
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%13 = load i32, i32* %5
%14 = load i32, i32* %2
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %34
16: ; preds = %0
%17 = getelementptr inbounds [0 x i32], [0 x i32]* %1, i64 0, i64 0
br label %18
18: ; preds = %18, %16
%19 = phi i64 [ 1, %16 ], [ %30, %18 ]
%20 = phi i32 [ %13, %16 ], [ %29, %18 ]
%21 = phi i32 [ %13, %16 ], [ %28, %18 ]
%22 = getelementptr inbounds [0 x i32], [0 x i32]* %1, i64 0, i64 %19
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %22)
%24 = load i32, i32* %17
%25 = icmp sgt i32 %24, %21
%26 = icmp slt i32 %24, %20
%27 = select i1 %26, i32 %24, i32 %20
%28 = select i1 %25, i32 %24, i32 %21
%29 = select i1 %25, i32 %20, i32 %27
%30 = add nuw nsw i64 %19, 1
%31 = load i32, i32* %2
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %19, %32
br i1 %33, label %18, label %34
34: ; preds = %18, %0
%35 = phi i32 [ %13, %0 ], [ %28, %18 ]
%36 = phi i32 [ %13, %0 ], [ %29, %18 ]
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %35)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %36)
ret i32 0
}