#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, a[20], n;
  printf("Enter no. of elements\n");
  scanf("%d", &n);
  printf("Enter the elements\n");
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  printf("Array 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    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
lea    -0x64(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    1197 <main+0x77>
movslq -0x8(%rbp),%rax
lea    -0x60(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe93(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1162 <main+0x42>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x64(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     11dc <main+0xbc>
movslq -0x8(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%esi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    11ae <main+0x8e>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb4(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xec0(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    119d <main+0x6d>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xe89(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jl     1180 <main+0x50>
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
jle    11db <main+0xab>
add    $0x1,%rbx
lea    0xe47(%rip),%r14
nopl   0x0(%rax)
lea    -0x2(%rbx),%eax
mov    0x10(%rsp,%rax,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     11c0 <main+0x90>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Enter no. of elements\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"Enter the elements\0A\00"
@.str.3 = [24 x i8] c"Array in reverse order\0A\00"
@.str.4 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [20 x i32]
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 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* %4)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %8
8: ; preds = %17, %0
%9 = load i32, i32* %2
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %20
12: ; preds = %8
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 %14
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %15)
br label %17
17: ; preds = %12
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
br label %8
20: ; preds = %8
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%22 = load i32, i32* %4
%23 = sub nsw i32 %22, 1
store i32 %23, i32* %2
br label %24
24: ; preds = %33, %20
%25 = load i32, i32* %2
%26 = icmp sge i32 %25, 0
br i1 %26, label %27, label %36
27: ; preds = %24
%28 = load i32, i32* %2
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %27
%34 = load i32, i32* %2
%35 = add nsw i32 %34, -1
store i32 %35, i32* %2
br label %24
36: ; preds = %24
%37 = load i32, i32* %1
ret i32 %37
}

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