#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n;
  int i;
  int *a;
  printf("Enter the size of the array: ");
  scanf("%d", &n);
  a = (int *)malloc(n * sizeof(int));
  for (i = 0; i < n; i++) {
    scanf("%d", (a + i));
  }
  printf("Here are the same numbers in reverse order: \n");
  for (i = n - 1; i >= 0; i--) {
    printf("%d \n", a[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ac <main+0x7c>
mov    -0x18(%rbp),%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe85(%rip),%rdi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1177 <main+0x47>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     11f4 <main+0xc4>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    11c3 <main+0x93>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
cmpl   $0x0,0x4(%rsp)
jle    11ad <main+0x6d>
xor    %r12d,%r12d
lea    0xe97(%rip),%r14
mov    %r15,%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
add    $0x1,%r12
movslq 0x4(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%r12
jl     1190 <main+0x50>
lea    0xe72(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%ebx
test   %ebx,%ebx
jle    11eb <main+0xab>
add    $0x1,%rbx
lea    0xe55(%rip),%r14
nopl   0x0(%rax)
lea    -0x2(%rbx),%eax
mov    (%r15,%rax,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     11d0 <main+0x90>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Enter the size of the array: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [46 x i8] c"Here are the same numbers in reverse order: \0A\00"
@.str.3 = [5 x i8] c"%d \0A\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 ([30 x i8], [30 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 = sext i32 %7 to i64
%9 = mul i64 %8, 4
%10 = trunc i64 %9 to i32
%11 = call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i32*
store i32* %12, i32** %4
store i32 0, i32* %3
br label %13
13: ; preds = %23, %0
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %26
17: ; preds = %13
%18 = load i32*, i32** %4
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %21)
br label %23
23: ; preds = %17
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %13
26: ; preds = %13
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
%28 = load i32, i32* %2
%29 = sub nsw i32 %28, 1
store i32 %29, i32* %3
br label %30
30: ; preds = %40, %26
%31 = load i32, i32* %3
%32 = icmp sge i32 %31, 0
br i1 %32, label %33, label %43
33: ; preds = %30
%34 = load i32*, i32** %4
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %33
%41 = load i32, i32* %3
%42 = add nsw i32 %41, -1
store i32 %42, i32* %3
br label %30
43: ; preds = %30
%44 = load i32, i32* %1
ret i32 %44
}

LLVM IR (-O2):
@.str = [30 x i8] c"Enter the size of the array: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [5 x i8] c"%d \0A\00"
@str = [45 x i8] c"Here are the same numbers in reverse order: \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 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 = call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i32*
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %0, %11
%12 = phi i64 [ %15, %11 ], [ 0, %0 ]
%13 = getelementptr inbounds i32, i32* %8, i64 %12
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %13)
%15 = add nuw nsw i64 %12, 1
%16 = load i32, i32* %1
%17 = sext i32 %16 to i64
%18 = icmp slt i64 %15, %17
br i1 %18, label %11, label %19
19: ; preds = %11, %0
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%21 = load i32, i32* %1
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %33
23: ; preds = %19
%24 = zext i32 %21 to i64
br label %25
25: ; preds = %23, %25
%26 = phi i64 [ %24, %23 ], [ %27, %25 ]
%27 = add nsw i64 %26, -1
%28 = and i64 %27, 4294967295
%29 = getelementptr inbounds i32, i32* %8, i64 %28
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = icmp ugt i64 %26, 1
br i1 %32, label %25, label %33
33: ; preds = %25, %19
ret i32 0
}