#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*/ printf(char *, ...);
int /*<<< orphan*/ stack_clear();
int stack_is_empty();
int stack_max();
double stack_pop();
int /*<<< orphan*/ stack_print();
int /*<<< orphan*/ stack_push(int);
int stack_top();
int main() {
  stack_clear();
  printf("Pushing values...\n");
  stack_push(5);
  stack_push(9);
  stack_push(2);
  stack_push(3);
  stack_print();
  printf("Pop values...\n");
  double x = stack_pop();
  double y = stack_pop();
  printf("x=%lf y=%lf\n", x, y);
  stack_print();
  printf("top=%d max=%d\n", stack_top(), stack_max());
  printf("isempty=%d", stack_is_empty());
  printf("Pop values...\n");
  stack_pop();
  stack_pop();
  stack_print();
  printf("top=%d max=%d\n", stack_top(), stack_max());
  printf("isempty=%d", stack_is_empty());
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1070 <stack_clear@plt>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x5,%edi
call   1090 <stack_push@plt>
mov    $0x9,%edi
call   1090 <stack_push@plt>
mov    $0x2,%edi
call   1090 <stack_push@plt>
mov    $0x3,%edi
call   1090 <stack_push@plt>
mov    $0x0,%al
call   1060 <stack_print@plt>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   10a0 <stack_pop@plt>
movsd  %xmm0,-0x8(%rbp)
mov    $0x0,%al
call   10a0 <stack_pop@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    0xe1f(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <stack_print@plt>
mov    $0x0,%al
call   1030 <stack_top@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <stack_max@plt>
mov    -0x18(%rbp),%esi
mov    %eax,%edx
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <stack_is_empty@plt>
mov    %eax,%esi
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   10a0 <stack_pop@plt>
mov    $0x0,%al
call   10a0 <stack_pop@plt>
mov    $0x0,%al
call   1060 <stack_print@plt>
mov    $0x0,%al
call   1030 <stack_top@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1050 <stack_max@plt>
mov    -0x14(%rbp),%esi
mov    %eax,%edx
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <stack_is_empty@plt>
mov    %eax,%esi
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1080 <stack_clear@plt>
lea    0xe82(%rip),%rdi
call   1040 <puts@plt>
mov    $0x5,%edi
call   10a0 <stack_push@plt>
mov    $0x9,%edi
call   10a0 <stack_push@plt>
mov    $0x2,%edi
call   10a0 <stack_push@plt>
mov    $0x3,%edi
call   10a0 <stack_push@plt>
xor    %eax,%eax
call   1070 <stack_print@plt>
lea    0xe59(%rip),%r14
mov    %r14,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   10b0 <stack_pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   10b0 <stack_pop@plt>
movaps %xmm0,%xmm1
lea    0xdfb(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x2,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <stack_print@plt>
xor    %eax,%eax
call   1030 <stack_top@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <stack_max@plt>
lea    0xdde(%rip),%r15
mov    %r15,%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1090 <stack_is_empty@plt>
lea    0xdd1(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   10b0 <stack_pop@plt>
xor    %eax,%eax
call   10b0 <stack_pop@plt>
xor    %eax,%eax
call   1070 <stack_print@plt>
xor    %eax,%eax
call   1030 <stack_top@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1060 <stack_max@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1090 <stack_is_empty@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Pushing values...\0A\00"
@.str.1 = [15 x i8] c"Pop values...\0A\00"
@.str.2 = [13 x i8] c"x=%lf y=%lf\0A\00"
@.str.3 = [15 x i8] c"top=%d max=%d\0A\00"
@.str.4 = [11 x i8] c"isempty=%d\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = call i32 (...) @stack_clear()
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @stack_push(i32 5)
%6 = call i32 @stack_push(i32 9)
%7 = call i32 @stack_push(i32 2)
%8 = call i32 @stack_push(i32 3)
%9 = call i32 (...) @stack_print()
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%11 = call double (...) @stack_pop()
store double %11, double* %1
%12 = call double (...) @stack_pop()
store double %12, double* %2
%13 = load double, double* %1
%14 = load double, double* %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double %13, double %14)
%16 = call i32 (...) @stack_print()
%17 = call i32 (...) @stack_top()
%18 = call i32 (...) @stack_max()
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %17, i32 %18)
%20 = call i32 (...) @stack_is_empty()
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%23 = call double (...) @stack_pop()
%24 = call double (...) @stack_pop()
%25 = call i32 (...) @stack_print()
%26 = call i32 (...) @stack_top()
%27 = call i32 (...) @stack_max()
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %26, i32 %27)
%29 = call i32 (...) @stack_is_empty()
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %29)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [13 x i8] c"x=%lf y=%lf\0A\00"
@.str.3 = [15 x i8] c"top=%d max=%d\0A\00"
@.str.4 = [11 x i8] c"isempty=%d\00"
@str = [18 x i8] c"Pushing values...\00"
@str.6 = [14 x i8] c"Pop values...\00"
define i32 @main() {
%1 = tail call i32 (...) @stack_clear()
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @stack_push(i32 5)
%4 = tail call i32 @stack_push(i32 9)
%5 = tail call i32 @stack_push(i32 2)
%6 = tail call i32 @stack_push(i32 3)
%7 = tail call i32 (...) @stack_print()
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.6, i64 0, i64 0))
%9 = tail call double (...) @stack_pop()
%10 = tail call double (...) @stack_pop()
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double %9, double %10)
%12 = tail call i32 (...) @stack_print()
%13 = tail call i32 (...) @stack_top()
%14 = tail call i32 (...) @stack_max()
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %13, i32 %14)
%16 = tail call i32 (...) @stack_is_empty()
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %16)
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.6, i64 0, i64 0))
%19 = tail call double (...) @stack_pop()
%20 = tail call double (...) @stack_pop()
%21 = tail call i32 (...) @stack_print()
%22 = tail call i32 (...) @stack_top()
%23 = tail call i32 (...) @stack_max()
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 %23)
%25 = tail call i32 (...) @stack_is_empty()
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %25)
ret i32 0
}