#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 *);
void priklad_dva() {
  printf("========== PRIKLAD 2 ==========\n");
  int pole[5 - 1];
  for (int i = 0; i < 5; i++) {
    printf("pole[%d] = ", i);
    scanf("%d", &pole[i]);
  }
  int *max, *min;
  max = &pole[0];
  min = &pole[0];
  for (int i = 0; i < 5; i++) {
    printf("pole[%d] = %d     ", i, pole[i]);
    if (*max < pole[i]) {
      max = &pole[i];
    }
    if (*min > pole[i]) {
      min = &pole[i];
    }
  }
  printf("\n\nMIN = %d   je na pole[%d]\n", *min, (min - &pole[0]));
  printf("MAX = %d   je na pole[%d]\n", *max, (max - &pole[0]));
  printf("========== KONEC PRIKLADU 2 ==========\n");
}


x86 assembly (clang, -O0):
<priklad_dva>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    1181 <priklad_dva+0x61>
mov    -0x14(%rbp),%esi
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x14(%rbp),%rax
lea    -0x10(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xebf(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <priklad_dva+0x1d>
lea    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x5,-0x2c(%rbp)
jge    121c <priklad_dva+0xfc>
mov    -0x2c(%rbp),%esi
movslq -0x2c(%rbp),%rax
mov    -0x10(%rbp,%rax,4),%edx
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
movslq -0x2c(%rbp),%rcx
cmp    -0x10(%rbp,%rcx,4),%eax
jge    11e2 <priklad_dva+0xc2>
movslq -0x2c(%rbp),%rcx
lea    -0x10(%rbp),%rax
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
movslq -0x2c(%rbp),%rcx
cmp    -0x10(%rbp,%rcx,4),%eax
jle    1209 <priklad_dva+0xe9>
movslq -0x2c(%rbp),%rcx
lea    -0x10(%rbp),%rax
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
jmp    120e <priklad_dva+0xee>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1198 <priklad_dva+0x78>
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%rdx
lea    -0x10(%rbp),%rax
sub    %rax,%rdx
sar    $0x2,%rdx
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rdx
lea    -0x10(%rbp),%rax
sub    %rax,%rdx
sar    $0x2,%rdx
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<priklad_dva>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xf15(%rip),%rdi
call   1030 <puts@plt>
lea    0xeaf(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea8(%rip),%rbp
mov    %rsp,%r12
mov    %rbp,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%r13
mov    %rbp,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbp,%rdi
call   1050 <scanf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbp,%rdi
call   1050 <scanf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbp,%rdi
call   1050 <scanf@plt>
mov    (%rsp),%edx
lea    0xe20(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%eax
mov    0x8(%rsp),%edx
xor    %r14d,%r14d
xor    %r15d,%r15d
cmp    0x4(%rsp),%eax
setl   %r14b
mov    %r12,%rbx
cmovl  %r13,%rbx
setg   %r15b
cmovle %r12,%r13
lea    0x0(,%r14,4),%rbp
lea    0x0(,%r15,4),%r12
lea    0xdc6(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%eax
cmp    %eax,(%rsp,%r14,4)
mov    0xc(%rsp),%edx
mov    $0x8,%ecx
cmovl  %rcx,%rbp
lea    0x8(%rsp),%rsi
cmovl  %rsi,%rbx
cmp    %eax,(%rsp,%r15,4)
cmovg  %rcx,%r12
cmovg  %rsi,%r13
lea    0xd89(%rip),%r14
mov    %r14,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
cmp    %eax,(%rsp,%rbp,1)
mov    0x10(%rsp),%edx
mov    $0xc,%ecx
cmovl  %rcx,%rbp
lea    0xc(%rsp),%rsi
cmovl  %rsi,%rbx
cmp    %eax,(%rsp,%r12,1)
cmovg  %rcx,%r12
cmovg  %rsi,%r13
mov    %r14,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%eax
cmp    %eax,(%rsp,%rbp,1)
mov    $0x10,%ecx
cmovl  %rcx,%rbp
lea    0x10(%rsp),%rdx
cmovl  %rdx,%rbx
cmp    %eax,(%rsp,%r12,1)
cmovg  %rcx,%r12
cmovg  %rdx,%r13
mov    (%rsp,%r12,1),%esi
mov    %rsp,%r14
sub    %r14,%r13
sar    $0x2,%r13
lea    0xd1b(%rip),%rdi
mov    %r13,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp,%rbp,1),%esi
sub    %r14,%rbx
sar    $0x2,%rbx
lea    0xd1d(%rip),%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd47(%rip),%rdi
call   1030 <puts@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"========== PRIKLAD 2 ==========\0A\00"
@.str.1 = [12 x i8] c"pole[%d] = \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [19 x i8] c"pole[%d] = %d \00"
@.str.4 = [29 x i8] c"\0A\0AMIN = %d je na pole[%d]\0A\00"
@.str.5 = [27 x i8] c"MAX = %d je na pole[%d]\0A\00"
@.str.6 = [40 x i8] c"========== KONEC PRIKLADU 2 ==========\0A\00"
define void @priklad_dva() {
%1 = alloca [4 x i32]
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %7
7: ; preds = %17, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 5
br i1 %9, label %10, label %20
10: ; preds = %7
%11 = load i32, i32* %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 %14
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %15)
br label %17
17: ; preds = %10
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
br label %7
20: ; preds = %7
%21 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
store i32* %21, i32** %3
%22 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
store i32* %22, i32** %4
store i32 0, i32* %5
br label %23
23: ; preds = %57, %20
%24 = load i32, i32* %5
%25 = icmp slt i32 %24, 5
br i1 %25, label %26, label %60
26: ; preds = %23
%27 = load i32, i32* %5
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %27, i32 %31)
%33 = load i32*, i32** %3
%34 = load i32, i32* %33
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = icmp slt i32 %34, %38
br i1 %39, label %40, label %44
40: ; preds = %26
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 %42
store i32* %43, i32** %3
br label %44
44: ; preds = %40, %26
%45 = load i32*, i32** %4
%46 = load i32, i32* %45
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 %48
%50 = load i32, i32* %49
%51 = icmp sgt i32 %46, %50
br i1 %51, label %52, label %56
52: ; preds = %44
%53 = load i32, i32* %5
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 %54
store i32* %55, i32** %4
br label %56
56: ; preds = %52, %44
br label %57
57: ; preds = %56
%58 = load i32, i32* %5
%59 = add nsw i32 %58, 1
store i32 %59, i32* %5
br label %23
60: ; preds = %23
%61 = load i32*, i32** %4
%62 = load i32, i32* %61
%63 = load i32*, i32** %4
%64 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%65 = ptrtoint i32* %63 to i64
%66 = ptrtoint i32* %64 to i64
%67 = sub i64 %65, %66
%68 = sdiv exact i64 %67, 4
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %62, i64 %68)
%70 = load i32*, i32** %3
%71 = load i32, i32* %70
%72 = load i32*, i32** %3
%73 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%74 = ptrtoint i32* %72 to i64
%75 = ptrtoint i32* %73 to i64
%76 = sub i64 %74, %75
%77 = sdiv exact i64 %76, 4
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %71, i64 %77)
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [12 x i8] c"pole[%d] = \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [19 x i8] c"pole[%d] = %d \00"
@.str.4 = [29 x i8] c"\0A\0AMIN = %d je na pole[%d]\0A\00"
@.str.5 = [27 x i8] c"MAX = %d je na pole[%d]\0A\00"
@str = [32 x i8] c"========== PRIKLAD 2 ==========\00"
@str.7 = [39 x i8] c"========== KONEC PRIKLADU 2 ==========\00"
define void @priklad_dva() {
%1 = alloca [4 x i32]
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%3 = bitcast [4 x i32]* %1 to i8*
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 0)
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 1)
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 2)
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %11)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 3)
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %14)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 4)
%17 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 4
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %17)
%19 = load i32, i32* %5
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 %19)
%21 = load i32, i32* %8
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 %21)
%23 = load i32, i32* %5
%24 = load i32, i32* %8
%25 = icmp slt i32 %23, %24
%26 = select i1 %25, i32* %8, i32* %5
%27 = icmp sgt i32 %23, %24
%28 = select i1 %27, i32* %8, i32* %5
%29 = load i32, i32* %11
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 2, i32 %29)
%31 = load i32, i32* %26
%32 = load i32, i32* %11
%33 = icmp slt i32 %31, %32
%34 = select i1 %33, i32* %11, i32* %26
%35 = load i32, i32* %28
%36 = icmp sgt i32 %35, %32
%37 = select i1 %36, i32* %11, i32* %28
%38 = load i32, i32* %14
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 %38)
%40 = load i32, i32* %34
%41 = load i32, i32* %14
%42 = icmp slt i32 %40, %41
%43 = select i1 %42, i32* %14, i32* %34
%44 = load i32, i32* %37
%45 = icmp sgt i32 %44, %41
%46 = select i1 %45, i32* %14, i32* %37
%47 = load i32, i32* %17
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 4, i32 %47)
%49 = load i32, i32* %43
%50 = load i32, i32* %17
%51 = icmp slt i32 %49, %50
%52 = select i1 %51, i32* %17, i32* %43
%53 = load i32, i32* %46
%54 = icmp sgt i32 %53, %50
%55 = select i1 %54, i32* %17, i32* %46
%56 = load i32, i32* %55
%57 = ptrtoint i32* %55 to i64
%58 = ptrtoint [4 x i32]* %1 to i64
%59 = sub i64 %57, %58
%60 = ashr exact i64 %59, 2
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %56, i64 %60)
%62 = load i32, i32* %52
%63 = ptrtoint i32* %52 to i64
%64 = sub i64 %63, %58
%65 = ashr exact i64 %64, 2
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %62, i64 %65)
%67 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.7, i64 0, i64 0))
ret void
}