#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 *);
void main() {
  int n[20], menor, pos;
  for (int i = 0; i < 20; i++) {
    printf("Informe a posicao %d: ", i + 1);
    scanf("%d", &n[i]);
    if (i == 0) {
      menor = n[i];
      pos = i;
    } else {
      if (menor > n[i]) {
        menor = n[i];
        pos = i;
      }
    }
  }
  printf("O menor elemento de N eh: %d\n", menor);
  printf("E sua posicao dentro do vetor eh: %d\n", pos + 1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x5c(%rbp)
cmpl   $0x14,-0x5c(%rbp)
jge    11c0 <main+0xa0>
mov    -0x5c(%rbp),%esi
add    $0x1,%esi
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
movslq -0x5c(%rbp),%rax
lea    -0x50(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xeb6(%rip),%rdi
call   1040 <scanf@plt>
cmpl   $0x0,-0x5c(%rbp)
jne    1186 <main+0x66>
movslq -0x5c(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%eax
mov    %eax,-0x54(%rbp)
mov    -0x5c(%rbp),%eax
mov    %eax,-0x58(%rbp)
jmp    11ad <main+0x8d>
mov    -0x54(%rbp),%eax
movslq -0x5c(%rbp),%rcx
cmp    -0x50(%rbp,%rcx,4),%eax
jle    11a8 <main+0x88>
movslq -0x5c(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%eax
mov    %eax,-0x54(%rbp)
mov    -0x5c(%rbp),%eax
mov    %eax,-0x58(%rbp)
jmp    11ad <main+0x8d>
jmp    11b2 <main+0x92>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    112f <main+0xf>
mov    -0x54(%rbp),%esi
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
mov    -0x58(%rbp),%esi
add    $0x1,%esi
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xecb(%rip),%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%r13d
lea    0x4(%rsp),%rbp
xor    %r12d,%r12d
mov    $0x1,%r14d
mov    $0x2,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x1(%r14),%r15
lea    0xe85(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
lea    0xe8e(%rip),%rdi
mov    %rbp,%rsi
call   1040 <scanf@plt>
mov    0x0(%rbp),%eax
cmp    %eax,%r13d
cmovg  %eax,%r13d
cmovg  %r14d,%r12d
add    $0x4,%rbp
add    $0x1,%ebx
mov    %r15,%r14
cmp    $0x14,%r15
jne    1170 <main+0x50>
lea    0xe64(%rip),%rdi
mov    %r13d,%esi
call   1030 <printf@plt>
add    $0x1,%r12d
lea    0xe6f(%rip),%rdi
mov    %r12d,%esi
call   1030 <printf@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Informe a posicao %d: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"O menor elemento de N eh: %d\0A\00"
@.str.3 = [38 x i8] c"E sua posicao dentro do vetor eh: %d\0A\00"
define void @main() {
%1 = alloca [20 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %4
br label %5
5: ; preds = %39, %0
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 20
br i1 %7, label %8, label %42
8: ; preds = %5
%9 = load i32, i32* %4
%10 = add nsw i32 %9, 1
%11 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %13
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %8
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %20
%22 = load i32, i32* %21
store i32 %22, i32* %2
%23 = load i32, i32* %4
store i32 %23, i32* %3
br label %38
24: ; preds = %8
%25 = load i32, i32* %2
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = icmp sgt i32 %25, %29
br i1 %30, label %31, label %37
31: ; preds = %24
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %33
%35 = load i32, i32* %34
store i32 %35, i32* %2
%36 = load i32, i32* %4
store i32 %36, i32* %3
br label %37
37: ; preds = %31, %24
br label %38
38: ; preds = %37, %18
br label %39
39: ; preds = %38
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %5
42: ; preds = %5
%43 = load i32, i32* %2
%44 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %3
%46 = add nsw i32 %45, 1
%47 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %46)
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"Informe a posicao %d: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"O menor elemento de N eh: %d\0A\00"
@.str.3 = [38 x i8] c"E sua posicao dentro do vetor eh: %d\0A\00"
define void @main() {
%1 = alloca [20 x i32]
%2 = bitcast [20 x i32]* %1 to i8*
%3 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 1)
%4 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%6 = load i32, i32* %4
br label %11
7: ; preds = %11
%8 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%9 = add nsw i32 %24, 1
%10 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %9)
ret void
11: ; preds = %0, %11
%12 = phi i64 [ 1, %0 ], [ %15, %11 ]
%13 = phi i32 [ 0, %0 ], [ %24, %11 ]
%14 = phi i32 [ %6, %0 ], [ %22, %11 ]
%15 = add nuw nsw i64 %12, 1
%16 = trunc i64 %15 to i32
%17 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %12
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %18)
%20 = load i32, i32* %18
%21 = icmp sgt i32 %14, %20
%22 = select i1 %21, i32 %20, i32 %14
%23 = trunc i64 %12 to i32
%24 = select i1 %21, i32 %23, i32 %13
%25 = icmp eq i64 %15, 20
br i1 %25, label %7, label %11
}