#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 /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int vetor[1000], i, tamanhoDoVetor;
  int indiceDoMenorValor = 0, menorValor;
  scanf("%d", &tamanhoDoVetor);
  scanf("%d", &menorValor);
  for (i = 1; i < tamanhoDoVetor; i++) {
    scanf("%d", &vetor[i]);
    if (vetor[i] < menorValor) {
      menorValor = vetor[i];
      indiceDoMenorValor = i;
    }
  }
  printf("Menor valor: %d\n", menorValor);
  printf("Posicao: %d\n", indiceDoMenorValor);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfc0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xfbc(%rbp)
lea    0xebd(%rip),%rdi
lea    -0xfb8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeaa(%rip),%rdi
lea    -0xfc0(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0xfb4(%rbp)
mov    -0xfb4(%rbp),%eax
cmp    -0xfb8(%rbp),%eax
jge    11f2 <main+0xd2>
movslq -0xfb4(%rbp),%rax
lea    -0xfb0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe66(%rip),%rdi
call   1040 <scanf@plt>
movslq -0xfb4(%rbp),%rax
mov    -0xfb0(%rbp,%rax,4),%eax
cmp    -0xfc0(%rbp),%eax
jge    11d9 <main+0xb9>
movslq -0xfb4(%rbp),%rax
mov    -0xfb0(%rbp,%rax,4),%eax
mov    %eax,-0xfc0(%rbp)
mov    -0xfb4(%rbp),%eax
mov    %eax,-0xfbc(%rbp)
jmp    11de <main+0xbe>
mov    -0xfb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb4(%rbp)
jmp    116c <main+0x4c>
mov    -0xfc0(%rbp),%esi
lea    0xe04(%rip),%rdi
call   1030 <printf@plt>
mov    -0xfbc(%rbp),%esi
lea    0xe03(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xfc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xfb8,%rsp
lea    0xecc(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
cmpl   $0x2,0xc(%rsp)
jl     11a9 <main+0x89>
xor    %r14d,%r14d
mov    $0x1,%ebp
mov    $0x4,%ebx
lea    0xe97(%rip),%r15
jmp    1182 <main+0x62>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
movslq 0xc(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jge    11b0 <main+0x90>
lea    (%rsp,%rbx,1),%rsi
add    $0x10,%rsi
mov    %r15,%rdi
call   1040 <scanf@plt>
mov    0x10(%rsp,%rbp,4),%eax
mov    0x8(%rsp),%esi
cmp    %esi,%eax
jge    1170 <main+0x50>
mov    %eax,0x8(%rsp)
mov    %eax,%esi
mov    %ebp,%r14d
jmp    1170 <main+0x50>
xor    %r14d,%r14d
mov    0x8(%rsp),%esi
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
lea    0xe51(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xfb8,%rsp
pop    %rbx
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 [1000 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
store i32 1, i32* %3
br label %9
9: ; preds = %31, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %34
13: ; preds = %9
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [1000 x i32], [1000 x i32]* %2, i64 0, i64 %15
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %16)
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [1000 x i32], [1000 x i32]* %2, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = load i32, i32* %6
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %30
24: ; preds = %13
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [1000 x i32], [1000 x i32]* %2, i64 0, i64 %26
%28 = load i32, i32* %27
store i32 %28, i32* %6
%29 = load i32, i32* %3
store i32 %29, i32* %5
br label %30
30: ; preds = %24, %13
br label %31
31: ; preds = %30
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %9
34: ; preds = %9
%35 = load i32, i32* %6
%36 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %5
%38 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %37)
ret i32 0
}

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 [1000 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [1000 x i32]* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %2
%10 = icmp sgt i32 %9, 1
br i1 %10, label %13, label %11
11: ; preds = %0
%12 = load i32, i32* %3
br label %30
13: ; preds = %0, %23
%14 = phi i64 [ %26, %23 ], [ 1, %0 ]
%15 = phi i32 [ %25, %23 ], [ 0, %0 ]
%16 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %14
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %16)
%18 = load i32, i32* %16
%19 = load i32, i32* %3
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %13
store i32 %18, i32* %3
%22 = trunc i64 %14 to i32
br label %23
23: ; preds = %13, %21
%24 = phi i32 [ %18, %21 ], [ %19, %13 ]
%25 = phi i32 [ %22, %21 ], [ %15, %13 ]
%26 = add nuw nsw i64 %14, 1
%27 = load i32, i32* %2
%28 = sext i32 %27 to i64
%29 = icmp slt i64 %26, %28
br i1 %29, label %13, label %30
30: ; preds = %23, %11
%31 = phi i32 [ %12, %11 ], [ %24, %23 ]
%32 = phi i32 [ 0, %11 ], [ %25, %23 ]
%33 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%34 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %32)
ret i32 0
}