#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, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int X[1010], i = 0, N, menor = 999999, p_menor;
  scanf(" %d", &N);
  while (i < N) {
    scanf(" %d", &X[i]);
    if (X[i] < menor) {
      menor = X[i];
      p_menor = i;
    }
    i++;
  }
  printf("Menor valor: %d\nPosicao: %d\n", menor, p_menor);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfe0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xfd4(%rbp)
movl   $0xf423f,-0xfdc(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0xfd8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xfd4(%rbp),%eax
cmp    -0xfd8(%rbp),%eax
jge    11da <main+0xba>
movslq -0xfd4(%rbp),%rax
lea    -0xfd0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe79(%rip),%rdi
call   1040 <scanf@plt>
movslq -0xfd4(%rbp),%rax
mov    -0xfd0(%rbp,%rax,4),%eax
cmp    -0xfdc(%rbp),%eax
jge    11c6 <main+0xa6>
movslq -0xfd4(%rbp),%rax
mov    -0xfd0(%rbp,%rax,4),%eax
mov    %eax,-0xfdc(%rbp)
mov    -0xfd4(%rbp),%eax
mov    %eax,-0xfe0(%rbp)
mov    -0xfd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfd4(%rbp)
jmp    1159 <main+0x39>
mov    -0xfdc(%rbp),%esi
mov    -0xfe0(%rbp),%edx
lea    0xe17(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xfe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xfe0,%rsp
lea    0xeca(%rip),%r14
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
mov    $0xf423f,%r12d
lea    0x10(%rsp),%rbx
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    (%rbx),%eax
cmp    %r12d,%eax
cmovl  %eax,%r12d
cmovl  %ebp,%r15d
add    $0x1,%rbp
movslq 0xc(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     1150 <main+0x30>
lea    0xe83(%rip),%rdi
mov    %r12d,%esi
mov    %r15d,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xfe0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c" %d\00"
@.str.1 = [29 x i8] c"Menor valor: %d\0APosicao: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1010 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 999999, i32* %5
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %4)
br label %8
8: ; preds = %29, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %32
12: ; preds = %8
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [1010 x i32], [1010 x i32]* %2, i64 0, i64 %14
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %15)
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [1010 x i32], [1010 x i32]* %2, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = load i32, i32* %5
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %29
23: ; preds = %12
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [1010 x i32], [1010 x i32]* %2, i64 0, i64 %25
%27 = load i32, i32* %26
store i32 %27, i32* %5
%28 = load i32, i32* %3
store i32 %28, i32* %6
br label %29
29: ; preds = %23, %12
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %8
32: ; preds = %8
%33 = load i32, i32* %5
%34 = load i32, i32* %6
%35 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %33, i32 %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c" %d\00"
@.str.1 = [29 x i8] c"Menor valor: %d\0APosicao: %d\0A\00"
define i32 @main() {
%1 = alloca [1010 x i32]
%2 = alloca i32
%3 = bitcast [1010 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp sgt i32 %6, 0
br label %8
8: ; preds = %0, %8
%9 = phi i64 [ 0, %0 ], [ %19, %8 ]
%10 = phi i32 [ undef, %0 ], [ %18, %8 ]
%11 = phi i32 [ 999999, %0 ], [ %16, %8 ]
%12 = getelementptr inbounds [1010 x i32], [1010 x i32]* %1, i64 0, i64 %9
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %12)
%14 = load i32, i32* %12
%15 = icmp slt i32 %14, %11
%16 = select i1 %15, i32 %14, i32 %11
%17 = trunc i64 %9 to i32
%18 = select i1 %15, i32 %17, i32 %10
%19 = add nuw nsw i64 %9, 1
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %8, label %23
23: ; preds = %8
%24 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %18)
ret i32 0
}