#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 */
struct stack_node {
  int dummy;
};

/* Variables and functions */
int pop_stack(struct stack_node **, int *);
int /*<<< orphan*/ printf(char *, ...);
void stack_print(struct stack_node **stack) {
  int data = 0;
  int ret = 0;
  while (ret == 0) {
    ret = pop_stack(stack, &data);
    if (ret == 0)
      printf("%d -- ", data);
  }
  printf("\n");
  return;
}


x86 assembly (clang, -O0):
<stack_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1174 <stack_print+0x54>
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <pop_stack@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    116f <stack_print+0x4f>
mov    -0xc(%rbp),%esi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    113a <stack_print+0x1a>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stack_print>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rsi
call   1050 <pop_stack@plt>
test   %eax,%eax
jne    117d <stack_print+0x4d>
lea    0xea7(%rip),%r14
lea    0xc(%rsp),%r15
xchg   %ax,%ax
mov    0xc(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <pop_stack@plt>
test   %eax,%eax
je     1160 <stack_print+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.stack_node = type { i32 }
@.str = [7 x i8] c"%d -- \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @stack_print(%struct.stack_node** %0) {
%2 = alloca %struct.stack_node**
%3 = alloca i32
%4 = alloca i32
store %struct.stack_node** %0, %struct.stack_node*** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %16, %1
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %17
8: ; preds = %5
%9 = load %struct.stack_node**, %struct.stack_node*** %2
%10 = call i32 @pop_stack(%struct.stack_node** %9, i32* %3)
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i32, i32* %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %13, %8
br label %5
17: ; preds = %5
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.stack_node = type { i32 }
@.str = [7 x i8] c"%d -- \00"
define void @stack_print(%struct.stack_node** %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%4 = call i32 @pop_stack(%struct.stack_node** %0, i32* %2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %1, %6
%7 = load i32, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 @pop_stack(%struct.stack_node** %0, i32* %2)
%10 = icmp eq i32 %9, 0
br i1 %10, label %6, label %11
11: ; preds = %6, %1
%12 = call i32 @putchar(i32 10)
ret void
}