#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 *, ...);
void DisplayStack(int arr[], int top) {
  int i;
  if (top == -1) {
    printf("Empty.\n");
    return;
  }
  for (i = top; i >= 0; i--) {
    printf("%d\n", arr[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<DisplayStack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    113c <DisplayStack+0x2c>
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1181 <DisplayStack+0x71>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     1173 <DisplayStack+0x63>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1142 <DisplayStack+0x32>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DisplayStack>:
cmp    $0xffffffff,%esi
je     1173 <DisplayStack+0x43>
push   %r15
push   %r14
push   %rbx
test   %esi,%esi
js     1164 <DisplayStack+0x34>
mov    %rdi,%r15
mov    %esi,%ebx
lea    0xeb6(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffffffffffff,%rbx
jb     1150 <DisplayStack+0x20>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>
lea    0xe8a(%rip),%rdi
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"Empty.\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @DisplayStack(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %27
10: ; preds = %2
%11 = load i32, i32* %4
store i32 %11, i32* %5
br label %12
12: ; preds = %22, %10
%13 = load i32, i32* %5
%14 = icmp sge i32 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = load i32*, i32** %3
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %15
%23 = load i32, i32* %5
%24 = add nsw i32 %23, -1
store i32 %24, i32* %5
br label %12
25: ; preds = %12
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %25, %8
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d\0A\00"
@str = [7 x i8] c"Empty.\00"
define void @DisplayStack(i32* nocapture %0, i32 %1) {
%3 = icmp eq i32 %1, -1
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = icmp sgt i32 %1, -1
br i1 %5, label %6, label %17
6: ; preds = %4
%7 = zext i32 %1 to i64
br label %10
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %19
10: ; preds = %6, %10
%11 = phi i64 [ %7, %6 ], [ %15, %10 ]
%12 = getelementptr inbounds i32, i32* %0, i64 %11
%13 = load i32, i32* %12
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = add nsw i64 %11, -1
%16 = icmp eq i64 %11, 0
br i1 %16, label %17, label %10
17: ; preds = %10, %4
%18 = tail call i32 @putchar(i32 10)
br label %19
19: ; preds = %17, %8
ret void
}