void view_displayStack(void) {
  puts("Display Stack...");
  struct Node *topNode = getTopNode();
  for (int 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
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <puts@plt>
mov    $0x0,%al
call   1060 <getTopNode@plt>
cltq
mov    %rax,-0x8(%rbp)
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    11a4 <view_displayStack+0x64>
mov    -0x8(%rbp),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116a <view_displayStack+0x2a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<view_displayStack>:
push   %rbp
push   %r14
push   %rbx
lea    0xeb5(%rip),%rdi
xor    %eax,%eax
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <getTopNode@plt>
mov    %eax,%ebx
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 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (...) @getTopNode()
%5 = sext i32 %4 to i64
%6 = inttoptr i64 %5 to %struct.Node*
store %struct.Node* %6, %struct.Node** %1
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 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @getTopNode()
%3 = sext i32 %2 to i64
%4 = inttoptr i64 %3 to %struct.Node*
%5 = tail call i32 (...) @model_stack_count()
%6 = icmp sgt i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %8, %0
ret void
8: ; preds = %0, %8
%9 = phi i32 [ %11, %8 ], [ 0, %0 ]
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %struct.Node* %4)
%11 = add nuw nsw i32 %9, 1
%12 = tail call i32 (...) @model_stack_count()
%13 = icmp slt i32 %11, %12
br i1 %13, label %8, label %7
}