#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 *malloc(int);
int minvec(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ mostrad(int *, int, int);
int /*<<< orphan*/ printf(char *, int, ...);
int scanf(char *, int *);
int main() {
  int *v = NULL, tam = 0;
  int lido = 0;
  v = malloc(sizeof(int) * 100);
  while (scanf("%d", &lido) == 1) {
    v[tam] = lido;
    tam++;
  }
  if (0) {
    printf(" Dados do vetor, tam: %d último lido: %d \n", tam, lido);
  }
  lido = minvec(v, 0, tam - 1);
  printf("Minvec: %d\n", lido + 1);
  mostrad(v, lido, tam);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    $0x190,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    0xe76(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11b8 <main+0x68>
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1183 <main+0x33>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1070 <minvec@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
add    $0x1,%esi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1060 <mostrad@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
mov    $0x190,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
lea    0xe8c(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
xor    %ebx,%ebx
cmp    $0x1,%eax
jne    11bc <main+0x6c>
xor    %ebx,%ebx
lea    0xe72(%rip),%r15
lea    0x4(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x4(%rsp),%eax
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
je     11a0 <main+0x50>
lea    -0x1(%rbx),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1070 <minvec@plt>
mov    %eax,0x4(%rsp)
lea    0x1(%rax),%esi
lea    0xe2c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
mov    %r14,%rdi
mov    %ebx,%edx
call   1060 <mostrad@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [12 x i8] c"Minvec: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32* null, i32** %2
store i32 0, i32* %3
store i32 0, i32* %4
%5 = call i32* @malloc(i32 400)
store i32* %5, i32** %2
br label %6
6: ; preds = %9, %0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = load i32, i32* %4
%11 = load i32*, i32** %2
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %11, i64 %13
store i32 %10, i32* %14
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %6
17: ; preds = %6
%18 = load i32*, i32** %2
%19 = load i32, i32* %3
%20 = sub nsw i32 %19, 1
%21 = call i32 @minvec(i32* %18, i32 0, i32 %20)
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = load i32*, i32** %2
%26 = load i32, i32* %4
%27 = load i32, i32* %3
%28 = call i32 @mostrad(i32* %25, i32 %26, i32 %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [12 x i8] c"Minvec: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32* @malloc(i32 400)
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %15
6: ; preds = %0, %6
%7 = phi i64 [ %10, %6 ], [ 0, %0 ]
%8 = load i32, i32* %1
%9 = getelementptr inbounds i32, i32* %3, i64 %7
store i32 %8, i32* %9
%10 = add nuw i64 %7, 1
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%12 = icmp eq i32 %11, 1
br i1 %12, label %6, label %13
13: ; preds = %6
%14 = trunc i64 %10 to i32
br label %15
15: ; preds = %13, %0
%16 = phi i32 [ 0, %0 ], [ %14, %13 ]
%17 = add nsw i32 %16, -1
%18 = call i32 @minvec(i32* %3, i32 0, i32 %17)
store i32 %18, i32* %1
%19 = add nsw i32 %18, 1
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %1
%22 = call i32 @mostrad(i32* %3, i32 %21, i32 %16)
ret i32 0
}