#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(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printVector(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int *revertVector(int *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int N, j;
  int *vec;
  printf("Entre com o tamanho desejado do vetor de inteiros: ");
  scanf("%d", &N);
  vec = (int *)malloc(sizeof(int) * (N - 1));
  printf("Entre com cada inteiro \n");
  for (j = 0; j < N; j++) {
    printf("inteiro numero %d: ", 1 + j);
    scanf("%i", vec);
    vec++;
  }
  vec -= j;
  printVector(vec, N);
  printVector(revertVector(vec, N), N);
  free(vec);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1203 <main+0xa3>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe80(%rip),%rdi
call   1080 <scanf@plt>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b9 <main+0x59>
mov    -0xc(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <printVector@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <revertVector@plt>
mov    %rax,%rdi
mov    -0x8(%rbp),%esi
call   1050 <printVector@plt>
mov    -0x18(%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    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1090 <scanf@plt>
mov    0x4(%rsp),%eax
lea    -0x4(,%rax,4),%edi
call   1080 <malloc@plt>
mov    %rax,%r14
lea    0xe9b(%rip),%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    11f7 <main+0x87>
lea    0xe70(%rip),%r15
lea    0xe7d(%rip),%r12
xor    %ebx,%ebx
add    $0x1,%rbx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1090 <scanf@plt>
add    $0x4,%r14
mov    0x4(%rsp),%esi
cmp    %esi,%ebx
jl     11d0 <main+0x60>
shl    $0x2,%rbx
sub    %rbx,%r14
mov    %r14,%rdi
call   1060 <printVector@plt>
mov    0x4(%rsp),%esi
mov    %r14,%rdi
call   1070 <revertVector@plt>
mov    0x4(%rsp),%esi
mov    %rax,%rdi
call   1060 <printVector@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 = [52 x i8] c"Entre com o tamanho desejado do vetor de inteiros: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [25 x i8] c"Entre com cada inteiro \0A\00"
@.str.3 = [20 x i8] c"inteiro numero %d: \00"
@.str.4 = [3 x i8] c"%i\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 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* %2)
%7 = load i32, i32* %2
%8 = sub nsw i32 %7, 1
%9 = sext i32 %8 to i64
%10 = mul i64 4, %9
%11 = trunc i64 %10 to i32
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i32*
store i32* %13, i32** %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %15
15: ; preds = %27, %0
%16 = load i32, i32* %3
%17 = load i32, i32* %2
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %30
19: ; preds = %15
%20 = load i32, i32* %3
%21 = add nsw i32 1, %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = load i32*, i32** %4
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %23)
%25 = load i32*, i32** %4
%26 = getelementptr inbounds i32, i32* %25, i32 1
store i32* %26, i32** %4
br label %27
27: ; preds = %19
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %15
30: ; preds = %15
%31 = load i32, i32* %3
%32 = load i32*, i32** %4
%33 = sext i32 %31 to i64
%34 = sub i64 0, %33
%35 = getelementptr inbounds i32, i32* %32, i64 %34
store i32* %35, i32** %4
%36 = load i32*, i32** %4
%37 = load i32, i32* %2
%38 = call i32 @printVector(i32* %36, i32 %37)
%39 = load i32*, i32** %4
%40 = load i32, i32* %2
%41 = call i32* @revertVector(i32* %39, i32 %40)
%42 = load i32, i32* %2
%43 = call i32 @printVector(i32* %41, i32 %42)
%44 = load i32*, i32** %4
%45 = call i32 @free(i32* %44)
ret i32 0
}

LLVM IR (-O2):
@.str = [52 x i8] c"Entre com o tamanho desejado do vetor de inteiros: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [20 x i8] c"inteiro numero %d: \00"
@.str.4 = [3 x i8] c"%i\00"
@str = [24 x i8] c"Entre com cada inteiro \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = shl i32 %5, 2
%7 = add i32 %6, -4
%8 = call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to i32*
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %24
13: ; preds = %0, %13
%14 = phi i32* [ %19, %13 ], [ %9, %0 ]
%15 = phi i32 [ %16, %13 ], [ 0, %0 ]
%16 = add nuw nsw i32 %15, 1
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %14)
%19 = getelementptr inbounds i32, i32* %14, i64 1
%20 = load i32, i32* %1
%21 = icmp slt i32 %16, %20
br i1 %21, label %13, label %22
22: ; preds = %13
%23 = zext i32 %16 to i64
br label %24
24: ; preds = %22, %0
%25 = phi i64 [ 0, %0 ], [ %23, %22 ]
%26 = phi i32* [ %9, %0 ], [ %19, %22 ]
%27 = phi i32 [ %11, %0 ], [ %20, %22 ]
%28 = sub nsw i64 0, %25
%29 = getelementptr inbounds i32, i32* %26, i64 %28
%30 = call i32 @printVector(i32* %29, i32 %27)
%31 = load i32, i32* %1
%32 = call i32* @revertVector(i32* %29, i32 %31)
%33 = load i32, i32* %1
%34 = call i32 @printVector(i32* %32, i32 %33)
%35 = call i32 @free(i32* %29)
ret i32 0
}