#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*/ completa_vetor(int *, int);
scalar_t__ malloc(int);
int menor_do_vetor(int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char *argv[]) {
  int *vetor, tamanho_do_vetor, menor;
  printf("digite o tamanho do vetor ");
  scanf("%d", &tamanho_do_vetor);
  vetor = (int *)malloc(tamanho_do_vetor * sizeof(int));
  completa_vetor(vetor, tamanho_do_vetor);
  menor = menor_do_vetor(vetor);
  printf("O menor indice do vetor é : %d\n", menor);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea0(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <completa_vetor@plt>
mov    -0x18(%rbp),%rdi
call   1070 <menor_do_vetor@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%edi
shl    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%esi
mov    %rax,%rdi
call   1050 <completa_vetor@plt>
mov    %rbx,%rdi
call   1070 <menor_do_vetor@plt>
lea    0xe80(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"digite o tamanho do vetor \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"O menor indice do vetor \C3\A9 : %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%11 = load i32, i32* %7
%12 = sext i32 %11 to i64
%13 = mul i64 %12, 4
%14 = trunc i64 %13 to i32
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i32*
store i32* %16, i32** %6
%17 = load i32*, i32** %6
%18 = load i32, i32* %7
%19 = call i32 @completa_vetor(i32* %17, i32 %18)
%20 = load i32*, i32** %6
%21 = call i32 @menor_do_vetor(i32* %20)
store i32 %21, i32* %8
%22 = load i32, i32* %8
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"digite o tamanho do vetor \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"O menor indice do vetor \C3\A9 : %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = shl i32 %7, 2
%9 = call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i32*
%11 = load i32, i32* %3
%12 = call i32 @completa_vetor(i32* %10, i32 %11)
%13 = call i32 @menor_do_vetor(i32* %10)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %13)
ret i32 0
}