#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_array_stack(int);
int /*<<< orphan*/ destroy_array_stack();
int /*<<< orphan*/ getchar();
int peek();
int pop();
int /*<<< orphan*/ print_array_stack();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(int);
int main() {
  int tmp = 0;
  create_array_stack(12);
  push(10);
  push(20);
  push(30);
  print_array_stack();
  printf("\n");
  tmp = pop();
  printf("tmp = %d\n", tmp);
  print_array_stack();
  printf("\n");
  tmp = peek();
  printf("tmp = %d\n", tmp);
  print_array_stack();
  printf("\n");
  push(40);
  print_array_stack();
  printf("\n");
  destroy_array_stack();
  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    $0xc,%edi
call   1080 <create_array_stack@plt>
mov    $0xa,%edi
call   1090 <push@plt>
mov    $0x14,%edi
call   1090 <push@plt>
mov    $0x1e,%edi
call   1090 <push@plt>
mov    $0x0,%al
call   1040 <print_array_stack@plt>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <pop@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <print_array_stack@plt>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <peek@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <print_array_stack@plt>
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x28,%edi
call   1090 <push@plt>
mov    $0x0,%al
call   1040 <print_array_stack@plt>
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   10a0 <destroy_array_stack@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0xc,%edi
call   1090 <create_array_stack@plt>
mov    $0xa,%edi
call   10a0 <push@plt>
mov    $0x14,%edi
call   10a0 <push@plt>
mov    $0x1e,%edi
call   10a0 <push@plt>
xor    %eax,%eax
call   1050 <print_array_stack@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
call   1070 <pop@plt>
lea    0xe28(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <print_array_stack@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
call   1030 <peek@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <print_array_stack@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    $0x28,%edi
call   10a0 <push@plt>
xor    %eax,%eax
call   1050 <print_array_stack@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
call   10b0 <destroy_array_stack@plt>
xor    %eax,%eax
call   1080 <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 @create_array_stack(i32 12)
%4 = call i32 @push(i32 10)
%5 = call i32 @push(i32 20)
%6 = call i32 @push(i32 30)
%7 = call i32 (...) @print_array_stack()
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (...) @pop()
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = call i32 (...) @print_array_stack()
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = call i32 (...) @peek()
store i32 %14, i32* %2
%15 = load i32, i32* %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = call i32 (...) @print_array_stack()
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @push(i32 40)
%20 = call i32 (...) @print_array_stack()
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = call i32 (...) @destroy_array_stack()
%23 = 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 @create_array_stack(i32 12)
%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 (...) @print_array_stack()
%6 = tail call i32 @putchar(i32 10)
%7 = tail call i32 (...) @pop()
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = tail call i32 (...) @print_array_stack()
%10 = tail call i32 @putchar(i32 10)
%11 = tail call i32 (...) @peek()
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = tail call i32 (...) @print_array_stack()
%14 = tail call i32 @putchar(i32 10)
%15 = tail call i32 @push(i32 40)
%16 = tail call i32 (...) @print_array_stack()
%17 = tail call i32 @putchar(i32 10)
%18 = tail call i32 (...) @destroy_array_stack()
%19 = tail call i32 (...) @getchar()
ret i32 0
}