#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 busca(int *, int, int);
int /*<<< orphan*/ desloca(int *, int, int);
int /*<<< orphan*/ mostra(int *, int, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int v[10] = {2, 4, 6, 8, 0, 0, 0, 0, 0, 0};
  int novo, pos_novo, ult = 3;
  mostra(v, ult, "Vetor original");
  printf("Digite um novo elemento: ");
  scanf("%d", &novo);
  pos_novo = busca(v, ult, novo);
  desloca(v, ult, pos_novo);
  v[pos_novo] = novo;
  ult++;
  mostra(v, ult, "Vetor alterado");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1060 <memset@plt>
movl   $0x2,-0x30(%rbp)
movl   $0x4,-0x2c(%rbp)
movl   $0x6,-0x28(%rbp)
movl   $0x8,-0x24(%rbp)
movl   $0x3,-0x3c(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x3c(%rbp),%esi
lea    0xe50(%rip),%rdx
call   1040 <mostra@plt>
lea    0xe53(%rip),%rdi
call   1050 <printf@plt>
lea    0xe61(%rip),%rdi
lea    -0x34(%rbp),%rsi
call   1080 <scanf@plt>
lea    -0x30(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    -0x34(%rbp),%edx
call   1070 <busca@plt>
mov    %eax,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    -0x38(%rbp),%edx
call   1030 <desloca@plt>
mov    -0x34(%rbp),%ecx
movslq -0x38(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x3c(%rbp),%esi
lea    0xe18(%rip),%rdx
call   1040 <mostra@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movq   $0x0,0x30(%rsp)
movaps 0xe92(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xe96(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <mostra@plt>
lea    0xe8c(%rip),%rdi
call   1050 <printf@plt>
lea    0xe9a(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1060 <busca@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %eax,%edx
call   1030 <desloca@plt>
mov    0xc(%rsp),%eax
movslq %ebp,%rcx
mov    %eax,0x10(%rsp,%rcx,4)
lea    0xe5f(%rip),%rdx
mov    %rbx,%rdi
mov    $0x4,%esi
call   1040 <mostra@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Vetor original\00"
@.str.1 = [26 x i8] c"Digite um novo elemento: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [15 x i8] c"Vetor alterado\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [10 x i32]* %2 to i8*
%7 = bitcast i8* %6 to [10 x i32]*
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i32 0, i32 0
store i32 2, i32* %8
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i32 0, i32 1
store i32 4, i32* %9
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i32 0, i32 2
store i32 6, i32* %10
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i32 0, i32 3
store i32 8, i32* %11
store i32 3, i32* %5
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%13 = load i32, i32* %5
%14 = call i32 @mostra(i32* %12, i32 %13, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%18 = load i32, i32* %5
%19 = load i32, i32* %3
%20 = call i32 @busca(i32* %17, i32 %18, i32 %19)
store i32 %20, i32* %4
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%22 = load i32, i32* %5
%23 = load i32, i32* %4
%24 = call i32 @desloca(i32* %21, i32 %22, i32 %23)
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %27
store i32 %25, i32* %28
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
%31 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%32 = load i32, i32* %5
%33 = call i32 @mostra(i32* %31, i32 %32, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"Vetor original\00"
@.str.1 = [26 x i8] c"Digite um novo elemento: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [15 x i8] c"Vetor alterado\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = alloca i32
%3 = bitcast [10 x i32]* %1 to i8*
%4 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%5 = bitcast i32* %4 to i8*
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%7 = bitcast [10 x i32]* %1 to <4 x i32>*
store <4 x i32> <i32 2, i32 4, i32 6, i32 8>, <4 x i32>* %7
%8 = bitcast i32* %2 to i8*
%9 = call i32 @mostra(i32* %6, i32 3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
%13 = call i32 @busca(i32* %6, i32 3, i32 %12)
%14 = call i32 @desloca(i32* %6, i32 3, i32 %13)
%15 = load i32, i32* %2
%16 = sext i32 %13 to i64
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %16
store i32 %15, i32* %17
%18 = call i32 @mostra(i32* %6, i32 4, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}