#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 node {
  int dummy;
};

/* Variables and functions */
int EXIT_SUCCESS;
struct node *pop(struct node *, int *);
int /*<<< orphan*/ print_stack(struct node *);
int /*<<< orphan*/ printf(char *, int);
struct node *push(struct node *, int);
int size(struct node *);
int main(int argc, char *argv[]) {
  struct node *head = NULL;
  int element;
  head = push(head, 12);
  print_stack(head);
  head = push(head, 11);
  print_stack(head);
  printf("Elements in Stack: %d\n", size(head));
  head = push(head, 14);
  print_stack(head);
  head = pop(head, &element);
  print_stack(head);
  head = pop(head, &element);
  print_stack(head);
  printf("Elements in Stack: %d\n", size(head));
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0xc,%esi
call   1070 <push@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <print_stack@plt>
mov    -0x18(%rbp),%rdi
mov    $0xb,%esi
call   1070 <push@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <print_stack@plt>
mov    -0x18(%rbp),%rdi
call   1030 <size@plt>
mov    %eax,%esi
lea    0xe4a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0xe,%esi
call   1070 <push@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <print_stack@plt>
mov    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1050 <pop@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <print_stack@plt>
mov    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1050 <pop@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <print_stack@plt>
mov    -0x18(%rbp),%rdi
call   1030 <size@plt>
mov    %eax,%esi
lea    0xde4(%rip),%rdi
call   1040 <printf@plt>
mov    0x2db8(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %edi,%edi
mov    $0xc,%esi
call   1070 <push@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <print_stack@plt>
mov    %rbx,%rdi
mov    $0xb,%esi
call   1070 <push@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <print_stack@plt>
mov    %rbx,%rdi
call   1030 <size@plt>
lea    0xe69(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0xe,%esi
call   1070 <push@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <print_stack@plt>
lea    0xc(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <pop@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <print_stack@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <pop@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <print_stack@plt>
mov    %rbx,%rdi
call   1030 <size@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [23 x i8] c"Elements in Stack: %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.node*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.node* null, %struct.node** %6
%8 = load %struct.node*, %struct.node** %6
%9 = call %struct.node* @push(%struct.node* %8, i32 12)
store %struct.node* %9, %struct.node** %6
%10 = load %struct.node*, %struct.node** %6
%11 = call i32 @print_stack(%struct.node* %10)
%12 = load %struct.node*, %struct.node** %6
%13 = call %struct.node* @push(%struct.node* %12, i32 11)
store %struct.node* %13, %struct.node** %6
%14 = load %struct.node*, %struct.node** %6
%15 = call i32 @print_stack(%struct.node* %14)
%16 = load %struct.node*, %struct.node** %6
%17 = call i32 @size(%struct.node* %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load %struct.node*, %struct.node** %6
%20 = call %struct.node* @push(%struct.node* %19, i32 14)
store %struct.node* %20, %struct.node** %6
%21 = load %struct.node*, %struct.node** %6
%22 = call i32 @print_stack(%struct.node* %21)
%23 = load %struct.node*, %struct.node** %6
%24 = call %struct.node* @pop(%struct.node* %23, i32* %7)
store %struct.node* %24, %struct.node** %6
%25 = load %struct.node*, %struct.node** %6
%26 = call i32 @print_stack(%struct.node* %25)
%27 = load %struct.node*, %struct.node** %6
%28 = call %struct.node* @pop(%struct.node* %27, i32* %7)
store %struct.node* %28, %struct.node** %6
%29 = load %struct.node*, %struct.node** %6
%30 = call i32 @print_stack(%struct.node* %29)
%31 = load %struct.node*, %struct.node** %6
%32 = call i32 @size(%struct.node* %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = load i32, i32* @EXIT_SUCCESS
ret i32 %34
}

LLVM IR (-O2):
%struct.node = type { i32 }
@.str = [23 x i8] c"Elements in Stack: %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call %struct.node* @push(%struct.node* null, i32 12)
%6 = tail call i32 @print_stack(%struct.node* %5)
%7 = tail call %struct.node* @push(%struct.node* %5, i32 11)
%8 = tail call i32 @print_stack(%struct.node* %7)
%9 = tail call i32 @size(%struct.node* %7)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = tail call %struct.node* @push(%struct.node* %7, i32 14)
%12 = tail call i32 @print_stack(%struct.node* %11)
%13 = call %struct.node* @pop(%struct.node* %11, i32* %3)
%14 = call i32 @print_stack(%struct.node* %13)
%15 = call %struct.node* @pop(%struct.node* %13, i32* %3)
%16 = call i32 @print_stack(%struct.node* %15)
%17 = call i32 @size(%struct.node* %15)
%18 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* @EXIT_SUCCESS
ret i32 %19
}