#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 *, short);
int /*<<< orphan*/ scanf(char *, int *);
main() {
  short int i, posi;
  int n, y;
  scanf("%d", &n);
  int x[n];
  for (i = 0; i < n; i++)
    scanf("%d", &x[i]);
  y = x[0];
  for (i = 0; i < n; i++) {
    if (x[i] < y) {
      y = x[i];
      posi = i;
    }
  }
  printf("Menor valor: %d\n", y);
  printf("Posicao: %d\n", posi);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movw   $0x0,-0x6(%rbp)
movswl -0x6(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a6 <main+0x86>
mov    -0x28(%rbp),%rsi
movswq -0x6(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe70(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x6(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x6(%rbp)
jmp    116c <main+0x4c>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
movw   $0x0,-0x6(%rbp)
movswl -0x6(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1204 <main+0xe4>
mov    -0x28(%rbp),%rax
movswq -0x6(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x10(%rbp),%eax
jge    11ee <main+0xce>
mov    -0x28(%rbp),%rax
movswq -0x6(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x10(%rbp)
mov    -0x6(%rbp),%ax
mov    %ax,-0x8(%rbp)
jmp    11f3 <main+0xd3>
mov    -0x6(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x6(%rbp)
jmp    11b5 <main+0x95>
mov    -0x10(%rbp),%eax
lea    0xdf5(%rip),%rdi
movswl %ax,%esi
call   1030 <printf@plt>
lea    0xdf7(%rip),%rdi
movswl -0x8(%rbp),%esi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeca(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1040 <scanf@plt>
mov    %rsp,%r14
mov    -0x24(%rbp),%eax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
cmpl   $0x0,-0x24(%rbp)
jle    1198 <main+0x78>
xor    %ebx,%ebx
lea    0xe97(%rip),%r15
nopl   0x0(%rax)
movswq %bx,%rax
lea    (%r12,%rax,4),%rsi
mov    %r15,%rdi
call   1040 <scanf@plt>
add    $0x1,%ebx
movswl %bx,%eax
mov    -0x24(%rbp),%ecx
cmp    %eax,%ecx
jg     1170 <main+0x50>
mov    (%r12),%eax
cmp    $0x2,%ecx
jge    119a <main+0x7a>
jmp    11ba <main+0x9a>
jmp    11ba <main+0x9a>
mov    $0x1,%dx
xchg   %ax,%ax
movswq %dx,%rdx
mov    (%r12,%rdx,4),%esi
cmp    %eax,%esi
cmovl  %edx,%ebx
cmovl  %esi,%eax
add    $0x1,%edx
movswl %dx,%esi
cmp    %esi,%ecx
jg     11a0 <main+0x80>
movswl %ax,%esi
lea    0xe3f(%rip),%rdi
call   1030 <printf@plt>
movswl %bx,%esi
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
mov    %r14,%rsp
xor    %eax,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [17 x i8] c"Menor valor: %d\0A\00"
@.str.2 = [13 x i8] c"Posicao: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i16
%3 = alloca i16
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
store i32 0, i32* %1
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%9 = load i32, i32* %4
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %6
%12 = alloca i32, i64 %10
store i64 %10, i64* %7
store i16 0, i16* %2
br label %13
13: ; preds = %23, %0
%14 = load i16, i16* %2
%15 = sext i16 %14 to i32
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %26
18: ; preds = %13
%19 = load i16, i16* %2
%20 = sext i16 %19 to i64
%21 = getelementptr inbounds i32, i32* %12, i64 %20
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %21)
br label %23
23: ; preds = %18
%24 = load i16, i16* %2
%25 = add i16 %24, 1
store i16 %25, i16* %2
br label %13
26: ; preds = %13
%27 = getelementptr inbounds i32, i32* %12, i64 0
%28 = load i32, i32* %27
store i32 %28, i32* %5
store i16 0, i16* %2
br label %29
29: ; preds = %48, %26
%30 = load i16, i16* %2
%31 = sext i16 %30 to i32
%32 = load i32, i32* %4
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %51
34: ; preds = %29
%35 = load i16, i16* %2
%36 = sext i16 %35 to i64
%37 = getelementptr inbounds i32, i32* %12, i64 %36
%38 = load i32, i32* %37
%39 = load i32, i32* %5
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %47
41: ; preds = %34
%42 = load i16, i16* %2
%43 = sext i16 %42 to i64
%44 = getelementptr inbounds i32, i32* %12, i64 %43
%45 = load i32, i32* %44
store i32 %45, i32* %5
%46 = load i16, i16* %2
store i16 %46, i16* %3
br label %47
47: ; preds = %41, %34
br label %48
48: ; preds = %47
%49 = load i16, i16* %2
%50 = add i16 %49, 1
store i16 %50, i16* %2
br label %29
51: ; preds = %29
%52 = load i32, i32* %5
%53 = trunc i32 %52 to i16
%54 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i16 signext %53)
%55 = load i16, i16* %3
%56 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i16 signext %55)
store i32 0, i32* %1
%57 = load i8*, i8** %6
%58 = load i32, i32* %1
ret i32 %58
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [17 x i8] c"Menor valor: %d\0A\00"
@.str.2 = [13 x i8] c"Posicao: %d\0A\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* %1
%5 = zext i32 %4 to i64
%6 = call i8* @llvm.stacksave()
%7 = alloca i32, i64 %5
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %35
10: ; preds = %0, %10
%11 = phi i16 [ %15, %10 ], [ 0, %0 ]
%12 = sext i16 %11 to i64
%13 = getelementptr inbounds i32, i32* %7, i64 %12
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %13)
%15 = add i16 %11, 1
%16 = sext i16 %15 to i32
%17 = load i32, i32* %1
%18 = icmp sgt i32 %17, %16
br i1 %18, label %10, label %19
19: ; preds = %10
%20 = load i32, i32* %7
%21 = icmp slt i32 %17, 2
br i1 %21, label %35, label %22
22: ; preds = %19, %22
%23 = phi i16 [ %32, %22 ], [ 1, %19 ]
%24 = phi i32 [ %31, %22 ], [ %20, %19 ]
%25 = phi i16 [ %30, %22 ], [ undef, %19 ]
%26 = sext i16 %23 to i64
%27 = getelementptr inbounds i32, i32* %7, i64 %26
%28 = load i32, i32* %27
%29 = icmp slt i32 %28, %24
%30 = select i1 %29, i16 %23, i16 %25
%31 = select i1 %29, i32 %28, i32 %24
%32 = add i16 %23, 1
%33 = sext i16 %32 to i32
%34 = icmp sgt i32 %17, %33
br i1 %34, label %22, label %35
35: ; preds = %22, %0, %19
%36 = phi i16 [ undef, %19 ], [ undef, %0 ], [ %30, %22 ]
%37 = phi i32 [ %20, %19 ], [ undef, %0 ], [ %31, %22 ]
%38 = trunc i32 %37 to i16
%39 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i16 signext %38)
%40 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i16 signext %36)
ret i32 0
}