#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 Stack {
  int dummy;
};
struct Element {
  int dummy;
};

/* Variables and functions */
struct Stack *SPCStack_init();
struct Element *SPCStack_new_elem(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ SPCStack_pop(struct Stack *, struct Element *);
int /*<<< orphan*/ SPCStack_print(struct Stack *);
int /*<<< orphan*/ SPCStack_push(struct Stack *, struct Element *);
int /*<<< orphan*/ SPC_FREE();
int /*<<< orphan*/ SPC_INIT();
int main() {
  struct Stack *stk = NULL;
  struct Element *elem;
  SPC_INIT();
  stk = SPCStack_init();
  SPCStack_print(stk);
  elem = SPCStack_new_elem("ELEM1", NULL);
  SPCStack_push(stk, elem);
  elem = SPCStack_new_elem("ELEM2", NULL);
  SPCStack_push(stk, elem);
  elem = SPCStack_new_elem("ELEM3", NULL);
  SPCStack_push(stk, elem);
  elem = SPCStack_new_elem("ELEM4", NULL);
  SPCStack_push(stk, elem);
  elem = SPCStack_new_elem("ELEM5", NULL);
  SPCStack_push(stk, elem);
  SPCStack_print(stk);
  SPCStack_pop(stk, elem);
  SPCStack_pop(stk, elem);
  SPCStack_pop(stk, elem);
  SPCStack_print(stk);
  SPC_FREE();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1070 <SPC_INIT@plt>
mov    $0x0,%al
call   1040 <SPCStack_init@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <SPCStack_print@plt>
lea    0xe57(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <SPCStack_new_elem@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <SPCStack_push@plt>
lea    0xe3c(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <SPCStack_new_elem@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <SPCStack_push@plt>
lea    0xe21(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <SPCStack_new_elem@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <SPCStack_push@plt>
lea    0xe06(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <SPCStack_new_elem@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <SPCStack_push@plt>
lea    0xdeb(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <SPCStack_new_elem@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <SPCStack_push@plt>
mov    -0x10(%rbp),%rdi
call   1050 <SPCStack_print@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <SPCStack_pop@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <SPCStack_pop@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <SPCStack_pop@plt>
mov    -0x10(%rbp),%rdi
call   1050 <SPCStack_print@plt>
mov    $0x0,%al
call   1090 <SPC_FREE@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1070 <SPC_INIT@plt>
xor    %eax,%eax
call   1040 <SPCStack_init@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <SPCStack_print@plt>
lea    0xe6c(%rip),%rdi
xor    %esi,%esi
call   1030 <SPCStack_new_elem@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <SPCStack_push@plt>
lea    0xe59(%rip),%rdi
xor    %esi,%esi
call   1030 <SPCStack_new_elem@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <SPCStack_push@plt>
lea    0xe46(%rip),%rdi
xor    %esi,%esi
call   1030 <SPCStack_new_elem@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <SPCStack_push@plt>
lea    0xe33(%rip),%rdi
xor    %esi,%esi
call   1030 <SPCStack_new_elem@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <SPCStack_push@plt>
lea    0xe20(%rip),%rdi
xor    %esi,%esi
call   1030 <SPCStack_new_elem@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <SPCStack_push@plt>
mov    %rbx,%rdi
call   1050 <SPCStack_print@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <SPCStack_pop@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <SPCStack_pop@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <SPCStack_pop@plt>
mov    %rbx,%rdi
call   1050 <SPCStack_print@plt>
xor    %eax,%eax
call   1090 <SPC_FREE@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.Stack = type { i32 }
%struct.Element = type { i32 }
@.str = [6 x i8] c"ELEM1\00"
@.str.1 = [6 x i8] c"ELEM2\00"
@.str.2 = [6 x i8] c"ELEM3\00"
@.str.3 = [6 x i8] c"ELEM4\00"
@.str.4 = [6 x i8] c"ELEM5\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.Stack*
%3 = alloca %struct.Element*
store i32 0, i32* %1
store %struct.Stack* null, %struct.Stack** %2
%4 = call i32 (...) @SPC_INIT()
%5 = call %struct.Stack* (...) @SPCStack_init()
store %struct.Stack* %5, %struct.Stack** %2
%6 = load %struct.Stack*, %struct.Stack** %2
%7 = call i32 @SPCStack_print(%struct.Stack* %6)
%8 = call %struct.Element* @SPCStack_new_elem(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* null)
store %struct.Element* %8, %struct.Element** %3
%9 = load %struct.Stack*, %struct.Stack** %2
%10 = load %struct.Element*, %struct.Element** %3
%11 = call i32 @SPCStack_push(%struct.Stack* %9, %struct.Element* %10)
%12 = call %struct.Element* @SPCStack_new_elem(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* null)
store %struct.Element* %12, %struct.Element** %3
%13 = load %struct.Stack*, %struct.Stack** %2
%14 = load %struct.Element*, %struct.Element** %3
%15 = call i32 @SPCStack_push(%struct.Stack* %13, %struct.Element* %14)
%16 = call %struct.Element* @SPCStack_new_elem(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* null)
store %struct.Element* %16, %struct.Element** %3
%17 = load %struct.Stack*, %struct.Stack** %2
%18 = load %struct.Element*, %struct.Element** %3
%19 = call i32 @SPCStack_push(%struct.Stack* %17, %struct.Element* %18)
%20 = call %struct.Element* @SPCStack_new_elem(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* null)
store %struct.Element* %20, %struct.Element** %3
%21 = load %struct.Stack*, %struct.Stack** %2
%22 = load %struct.Element*, %struct.Element** %3
%23 = call i32 @SPCStack_push(%struct.Stack* %21, %struct.Element* %22)
%24 = call %struct.Element* @SPCStack_new_elem(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* null)
store %struct.Element* %24, %struct.Element** %3
%25 = load %struct.Stack*, %struct.Stack** %2
%26 = load %struct.Element*, %struct.Element** %3
%27 = call i32 @SPCStack_push(%struct.Stack* %25, %struct.Element* %26)
%28 = load %struct.Stack*, %struct.Stack** %2
%29 = call i32 @SPCStack_print(%struct.Stack* %28)
%30 = load %struct.Stack*, %struct.Stack** %2
%31 = load %struct.Element*, %struct.Element** %3
%32 = call i32 @SPCStack_pop(%struct.Stack* %30, %struct.Element* %31)
%33 = load %struct.Stack*, %struct.Stack** %2
%34 = load %struct.Element*, %struct.Element** %3
%35 = call i32 @SPCStack_pop(%struct.Stack* %33, %struct.Element* %34)
%36 = load %struct.Stack*, %struct.Stack** %2
%37 = load %struct.Element*, %struct.Element** %3
%38 = call i32 @SPCStack_pop(%struct.Stack* %36, %struct.Element* %37)
%39 = load %struct.Stack*, %struct.Stack** %2
%40 = call i32 @SPCStack_print(%struct.Stack* %39)
%41 = call i32 (...) @SPC_FREE()
ret i32 0
}

LLVM IR (-O2):
%struct.Stack = type { i32 }
%struct.Element = type { i32 }
@.str = [6 x i8] c"ELEM1\00"
@.str.1 = [6 x i8] c"ELEM2\00"
@.str.2 = [6 x i8] c"ELEM3\00"
@.str.3 = [6 x i8] c"ELEM4\00"
@.str.4 = [6 x i8] c"ELEM5\00"
define i32 @main() {
%1 = tail call i32 (...) @SPC_INIT()
%2 = tail call %struct.Stack* (...) @SPCStack_init()
%3 = tail call i32 @SPCStack_print(%struct.Stack* %2)
%4 = tail call %struct.Element* @SPCStack_new_elem(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* null)
%5 = tail call i32 @SPCStack_push(%struct.Stack* %2, %struct.Element* %4)
%6 = tail call %struct.Element* @SPCStack_new_elem(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* null)
%7 = tail call i32 @SPCStack_push(%struct.Stack* %2, %struct.Element* %6)
%8 = tail call %struct.Element* @SPCStack_new_elem(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* null)
%9 = tail call i32 @SPCStack_push(%struct.Stack* %2, %struct.Element* %8)
%10 = tail call %struct.Element* @SPCStack_new_elem(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* null)
%11 = tail call i32 @SPCStack_push(%struct.Stack* %2, %struct.Element* %10)
%12 = tail call %struct.Element* @SPCStack_new_elem(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* null)
%13 = tail call i32 @SPCStack_push(%struct.Stack* %2, %struct.Element* %12)
%14 = tail call i32 @SPCStack_print(%struct.Stack* %2)
%15 = tail call i32 @SPCStack_pop(%struct.Stack* %2, %struct.Element* %12)
%16 = tail call i32 @SPCStack_pop(%struct.Stack* %2, %struct.Element* %12)
%17 = tail call i32 @SPCStack_pop(%struct.Stack* %2, %struct.Element* %12)
%18 = tail call i32 @SPCStack_print(%struct.Stack* %2)
%19 = tail call i32 (...) @SPC_FREE()
ret i32 0
}