#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 *stack, int top) {
  printf("\tTOP =>");
  while (top >= 0 && stack[top] != -9999999) {
    printf("\t%d", stack[top]);
    top--;
  }
  printf("\t<= BOTTOM");
}


x86 assembly (clang, -O0):
<displayStack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jl     1151 <displayStack+0x41>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpl   $0xff676981,(%rax,%rcx,4)
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1161 <displayStack+0x51>
jmp    1188 <displayStack+0x78>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    112d <displayStack+0x1d>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<displayStack>:
push   %r15
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r14
lea    0xedf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebx,%ebx
js     1161 <displayStack+0x51>
lea    0xed5(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%eax
mov    (%r14,%rax,4),%esi
cmp    $0xff676981,%esi
je     1161 <displayStack+0x51>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    -0x1(%rbx),%eax
test   %ebx,%ebx
mov    %eax,%ebx
jg     1140 <displayStack+0x30>
lea    0xea4(%rip),%rdi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

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

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