#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*/ free(float *);
scalar_t__ malloc(int);
int /*<<< orphan*/ pos_ele(float *, float, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  int tam;
  float *vet, ele;
  printf("Informe o tamanho do vetor: ");
  scanf("%d", &tam);
  vet = (float *)malloc((tam + 1) * sizeof(float));
  printf("Informe os elementos:\n");
  for (int i = 0; i < tam; i++) {
    scanf("%f", &vet[i]);
  }
  printf("Informe o elemento desejado: ");
  scanf("%f", &ele);
  pos_ele(vet, ele, tam);
  printf("O novo vetor é:\n");
  for (int i = 0; i < tam + 1; i++) {
    printf("%.2f ", vet[i]);
  }
  printf("\n");
  free(vet);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea9(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e2 <main+0x92>
mov    -0x10(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ab <main+0x5b>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe40(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x10(%rbp),%rdi
movss  -0x14(%rbp),%xmm0
mov    -0x8(%rbp),%esi
call   1050 <pos_ele@plt>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1266 <main+0x116>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe19(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1228 <main+0xd8>
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@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
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe90(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    (%rsp),%eax
lea    0x4(,%rax,4),%edi
call   1080 <malloc@plt>
mov    %rax,%r14
lea    0xe97(%rip),%rdi
call   1050 <puts@plt>
cmpl   $0x0,(%rsp)
jle    11ee <main+0x7e>
lea    0xe5e(%rip),%r15
mov    %r14,%r12
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
add    $0x1,%rbx
movslq (%rsp),%rax
add    $0x4,%r12
cmp    %rax,%rbx
jl     11d0 <main+0x60>
lea    0xe2e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe1d(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
movss  0x4(%rsp),%xmm0
mov    (%rsp),%esi
mov    %r14,%rdi
call   1070 <pos_ele@plt>
lea    0xe36(%rip),%rdi
call   1050 <puts@plt>
cmpl   $0x0,(%rsp)
js     1262 <main+0xf2>
mov    $0xffffffffffffffff,%rbx
lea    0xe01(%rip),%r15
movss  0x4(%r14,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movslq (%rsp),%rax
add    $0x1,%rbx
cmp    %rax,%rbx
jl     1240 <main+0xd0>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Informe o tamanho do vetor: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"Informe os elementos:\0A\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [30 x i8] c"Informe o elemento desejado: \00"
@.str.5 = [18 x i8] c"O novo vetor \C3\A9:\0A\00"
@.str.6 = [6 x i8] c"%.2f \00"
@.str.7 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float*
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = add nsw i32 %9, 1
%11 = sext i32 %10 to i64
%12 = mul i64 %11, 4
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to float*
store float* %15, float** %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %5
br label %17
17: ; preds = %27, %0
%18 = load i32, i32* %5
%19 = load i32, i32* %2
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = load float*, float** %3
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds float, float* %22, i64 %24
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %25)
br label %27
27: ; preds = %21
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %17
30: ; preds = %17
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
%33 = load float*, float** %3
%34 = load float, float* %4
%35 = load i32, i32* %2
%36 = call i32 @pos_ele(float* %33, float %34, i32 %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %6
br label %38
38: ; preds = %51, %30
%39 = load i32, i32* %6
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 1
%42 = icmp slt i32 %39, %41
br i1 %42, label %43, label %54
43: ; preds = %38
%44 = load float*, float** %3
%45 = load i32, i32* %6
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds float, float* %44, i64 %46
%48 = load float, float* %47
%49 = fpext float %48 to double
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), double %49)
br label %51
51: ; preds = %43
%52 = load i32, i32* %6
%53 = add nsw i32 %52, 1
store i32 %53, i32* %6
br label %38
54: ; preds = %38
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%56 = load float*, float** %3
%57 = call i32 @free(float* %56)
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"Informe o tamanho do vetor: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [30 x i8] c"Informe o elemento desejado: \00"
@.str.6 = [6 x i8] c"%.2f \00"
@str = [22 x i8] c"Informe os elementos:\00"
@str.8 = [17 x i8] c"O novo vetor \C3\A9:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = bitcast i32* %1 to i8*
%4 = bitcast float* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = shl i32 %7, 2
%9 = add i32 %8, 4
%10 = call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to float*
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%13 = load i32, i32* %1
%14 = icmp sgt i32 %13, 0
br i1 %14, label %24, label %15
15: ; preds = %24, %0
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %2)
%18 = load float, float* %2
%19 = load i32, i32* %1
%20 = call i32 @pos_ele(float* %11, float %18, i32 %19)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.8, i64 0, i64 0))
%22 = load i32, i32* %1
%23 = icmp slt i32 %22, 0
br i1 %23, label %32, label %35
24: ; preds = %0, %24
%25 = phi i64 [ %28, %24 ], [ 0, %0 ]
%26 = getelementptr inbounds float, float* %11, i64 %25
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %26)
%28 = add nuw nsw i64 %25, 1
%29 = load i32, i32* %1
%30 = sext i32 %29 to i64
%31 = icmp slt i64 %28, %30
br i1 %31, label %24, label %15
32: ; preds = %35, %15
%33 = call i32 @putchar(i32 10)
%34 = call i32 @free(float* %11)
ret i32 0
35: ; preds = %15, %35
%36 = phi i64 [ %41, %35 ], [ 0, %15 ]
%37 = getelementptr inbounds float, float* %11, i64 %36
%38 = load float, float* %37
%39 = fpext float %38 to double
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), double %39)
%41 = add nuw nsw i64 %36, 1
%42 = load i32, i32* %1
%43 = sext i32 %42 to i64
%44 = icmp slt i64 %36, %43
br i1 %44, label %35, label %32
}