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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0xa,%edi
call   1070 <push@plt>
mov    $0x14,%edi
call   1070 <push@plt>
mov    $0x1e,%edi
call   1070 <push@plt>
mov    $0x0,%al
call   1080 <print_single_link@plt>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <pop@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <peek@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x28,%edi
call   1070 <push@plt>
mov    $0x0,%al
call   1080 <print_single_link@plt>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
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   1090 <print_single_link@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
call   1060 <pop@plt>
lea    0xe52(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <peek@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    $0x28,%edi
call   1080 <push@plt>
xor    %eax,%eax
call   1090 <print_single_link@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
pop    %rbx
ret

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

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