#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*/ create_dlink_stack();
int /*<<< orphan*/ destroy_dlink_stack();
int peek();
int pop();
int /*<<< orphan*/ print_dlink_stack();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ push(int);
void main() {
  int tmp = 0;
  create_dlink_stack();
  push(10);
  push(20);
  push(30);
  tmp = pop();
  printf("tmp=%d\n", tmp);
  tmp = peek();
  printf("tmp=%d\n", tmp);
  push(40);
  print_dlink_stack();
  destroy_dlink_stack();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <create_dlink_stack@plt>
mov    $0xa,%edi
call   1080 <push@plt>
mov    $0x14,%edi
call   1080 <push@plt>
mov    $0x1e,%edi
call   1080 <push@plt>
mov    $0x0,%al
call   1070 <pop@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe48(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <peek@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe2f(%rip),%rdi
call   1050 <printf@plt>
mov    $0x28,%edi
call   1080 <push@plt>
mov    $0x0,%al
call   1060 <print_dlink_stack@plt>
mov    $0x0,%al
call   1090 <destroy_dlink_stack@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <create_dlink_stack@plt>
mov    $0xa,%edi
call   1080 <push@plt>
mov    $0x14,%edi
call   1080 <push@plt>
mov    $0x1e,%edi
call   1080 <push@plt>
xor    %eax,%eax
call   1070 <pop@plt>
lea    0xe5c(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <peek@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0x28,%edi
call   1080 <push@plt>
xor    %eax,%eax
call   1060 <print_dlink_stack@plt>
xor    %eax,%eax
pop    %rbx
jmp    1090 <destroy_dlink_stack@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"tmp=%d\0A\00"
define void @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @create_dlink_stack()
%3 = call i32 @push(i32 10)
%4 = call i32 @push(i32 20)
%5 = call i32 @push(i32 30)
%6 = call i32 (...) @pop()
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 (...) @peek()
store i32 %9, i32* %1
%10 = load i32, i32* %1
%11 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 @push(i32 40)
%13 = call i32 (...) @print_dlink_stack()
%14 = call i32 (...) @destroy_dlink_stack()
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"tmp=%d\0A\00"
define void @main() {
%1 = tail call i32 (...) @create_dlink_stack()
%2 = tail call i32 @push(i32 10)
%3 = tail call i32 @push(i32 20)
%4 = tail call i32 @push(i32 30)
%5 = tail call i32 (...) @pop()
%6 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 (...) @peek()
%8 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = tail call i32 @push(i32 40)
%10 = tail call i32 (...) @print_dlink_stack()
%11 = tail call i32 (...) @destroy_dlink_stack()
ret void
}