#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 size, i, arr[30];
  int *ptr;
  ptr = &arr[0];
  printf("\nEnter the size of array : ");
  scanf("%d", &size);
  printf("\nEnter %d integers into array: ", size);
  for (i = 0; i < size; i++) {
    scanf("%d", ptr);
    ptr++;
  }
  ptr = &arr[size - 1];
  printf("Elements of array in reverse order are :\n");
  for (i = size - 1; i >= 0; i--) {
    printf("  Element %d is %d \n", i, *ptr);
    ptr--;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rax
mov    %rax,-0x98(%rbp)
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b5 <main+0x95>
mov    -0x98(%rbp),%rsi
lea    0xe8c(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x98(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x98(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1176 <main+0x56>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    -0x90(%rbp),%rax
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x98(%rbp)
lea    0xe65(%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     122e <main+0x10e>
mov    -0xc(%rbp),%esi
mov    -0x98(%rbp),%rax
mov    (%rax),%edx
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x98(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x98(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    11ea <main+0xca>
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
lea    0xebc(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%r15d
test   %r15d,%r15d
jle    11ac <main+0x7c>
lea    0x10(%rsp),%rbx
lea    0xe96(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    $0x4,%rbx
add    $0x1,%ebp
mov    0xc(%rsp),%r15d
cmp    %r15d,%ebp
jl     1190 <main+0x60>
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%ebp
test   %ebp,%ebp
jle    11fb <main+0xcb>
movslq %r15d,%rax
lea    (%rsp,%rax,4),%rbx
add    $0xc,%rbx
add    $0x1,%ebp
lea    0xe6a(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
lea    -0x2(%rbp),%esi
mov    (%rbx),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xfffffffffffffffc,%rbx
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     11e0 <main+0xb0>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"\0AEnter the size of array : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"\0AEnter %d integers into array: \00"
@.str.3 = [42 x i8] c"Elements of array in reverse order are :\0A\00"
@.str.4 = [21 x i8] c" Element %d is %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [30 x i32]
%5 = alloca i32*
store i32 0, i32* %1
%6 = getelementptr inbounds [30 x i32], [30 x i32]* %4, i64 0, i64 0
store i32* %6, i32** %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %9)
store i32 0, i32* %3
br label %11
11: ; preds = %20, %0
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load i32*, i32** %5
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
%18 = load i32*, i32** %5
%19 = getelementptr inbounds i32, i32* %18, i32 1
store i32* %19, i32** %5
br label %20
20: ; preds = %15
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %11
23: ; preds = %11
%24 = load i32, i32* %2
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [30 x i32], [30 x i32]* %4, i64 0, i64 %26
store i32* %27, i32** %5
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
%29 = load i32, i32* %2
%30 = sub nsw i32 %29, 1
store i32 %30, i32* %3
br label %31
31: ; preds = %41, %23
%32 = load i32, i32* %3
%33 = icmp sge i32 %32, 0
br i1 %33, label %34, label %44
34: ; preds = %31
%35 = load i32, i32* %3
%36 = load i32*, i32** %5
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %35, i32 %37)
%39 = load i32*, i32** %5
%40 = getelementptr inbounds i32, i32* %39, i32 -1
store i32* %40, i32** %5
br label %41
41: ; preds = %34
%42 = load i32, i32* %3
%43 = add nsw i32 %42, -1
store i32 %43, i32* %3
br label %31
44: ; preds = %31
%45 = load i32, i32* %1
ret i32 %45
}

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