void view_displayStack(void) {
  struct Node *topNode = getTopNode();
  int i = 0;
  puts("Display Stack...");
  for (i = 0; i < model_stack_count(); i++) {
    printf("%d\n", topNode);
  }
}


x86 assembly (clang, -O0):
<view_displayStack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <getTopNode@plt>
cltq
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <puts@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <model_stack_count@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jge    11ab <view_displayStack+0x6b>
mov    -0x8(%rbp),%rsi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1171 <view_displayStack+0x31>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<view_displayStack>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1060 <getTopNode@plt>
mov    %eax,%ebx
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <model_stack_count@plt>
test   %eax,%eax
jle    119b <view_displayStack+0x5b>
movslq %ebx,%rbx
lea    0xea1(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
xor    %eax,%eax
call   1050 <model_stack_count@plt>
cmp    %eax,%ebp
jl     1180 <view_displayStack+0x40>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.Node = type opaque
@.str = [17 x i8] c"Display Stack...\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define void @view_displayStack() {
%1 = alloca %struct.Node*
%2 = alloca i32
%3 = call i32 (...) @getTopNode()
%4 = sext i32 %3 to i64
%5 = inttoptr i64 %4 to %struct.Node*
store %struct.Node* %5, %struct.Node** %1
store i32 0, i32* %2
%6 = call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %7
7: ; preds = %14, %0
%8 = load i32, i32* %2
%9 = call i32 (...) @model_stack_count()
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %17
11: ; preds = %7
%12 = load %struct.Node*, %struct.Node** %1
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %struct.Node* %12)
br label %14
14: ; preds = %11
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %2
br label %7
17: ; preds = %7
ret void
}

LLVM IR (-O2):
%struct.Node = type opaque
@.str = [17 x i8] c"Display Stack...\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define void @view_displayStack() {
%1 = tail call i32 (...) @getTopNode()
%2 = sext i32 %1 to i64
%3 = inttoptr i64 %2 to %struct.Node*
%4 = tail call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (...) @model_stack_count()
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %0, %7
%8 = phi i32 [ %10, %7 ], [ 0, %0 ]
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %struct.Node* %3)
%10 = add nuw nsw i32 %8, 1
%11 = tail call i32 (...) @model_stack_count()
%12 = icmp slt i32 %10, %11
br i1 %12, label %7, label %13
13: ; preds = %7, %0
ret void
}