#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;
};

/* Variables and functions */
int /*<<< orphan*/ STK_deleteStack(struct Stack *);
struct Stack *STK_newStack();
int /*<<< orphan*/ STK_pop(struct Stack *);
int /*<<< orphan*/ STK_push(struct Stack *, int *);
int /*<<< orphan*/ STK_size(struct Stack *);
scalar_t__ STK_top(struct Stack *);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  struct Stack *testStack = STK_newStack();
  int testInt = 4;
  STK_push(testStack, &testInt);
  STK_size(testStack);
  int *testPtr = (int *)STK_top(testStack);
  printf("Number of items: %d", *testPtr);
  STK_pop(testStack);
  STK_size(testStack);
  STK_deleteStack(testStack);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <STK_newStack@plt>
mov    %rax,-0x10(%rbp)
movl   $0x4,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1090 <STK_push@plt>
mov    -0x10(%rbp),%rdi
call   1080 <STK_size@plt>
mov    -0x10(%rbp),%rdi
call   1070 <STK_top@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
lea    0xe3f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <STK_pop@plt>
mov    -0x10(%rbp),%rdi
call   1080 <STK_size@plt>
mov    -0x10(%rbp),%rdi
call   1030 <STK_deleteStack@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1060 <STK_newStack@plt>
mov    %rax,%rbx
movl   $0x4,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    %rax,%rdi
call   1090 <STK_push@plt>
mov    %rbx,%rdi
call   1080 <STK_size@plt>
mov    %rbx,%rdi
call   1070 <STK_top@plt>
mov    (%rax),%esi
lea    0xe53(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <STK_pop@plt>
mov    %rbx,%rdi
call   1080 <STK_size@plt>
mov    %rbx,%rdi
call   1030 <STK_deleteStack@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.Stack = type { i32 }
@.str = [20 x i8] c"Number of items: %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.Stack*
%3 = alloca i32
%4 = alloca i32*
store i32 0, i32* %1
%5 = call %struct.Stack* (...) @STK_newStack()
store %struct.Stack* %5, %struct.Stack** %2
store i32 4, i32* %3
%6 = load %struct.Stack*, %struct.Stack** %2
%7 = call i32 @STK_push(%struct.Stack* %6, i32* %3)
%8 = load %struct.Stack*, %struct.Stack** %2
%9 = call i32 @STK_size(%struct.Stack* %8)
%10 = load %struct.Stack*, %struct.Stack** %2
%11 = call i64 @STK_top(%struct.Stack* %10)
%12 = inttoptr i64 %11 to i32*
store i32* %12, i32** %4
%13 = load i32*, i32** %4
%14 = load i32, i32* %13
%15 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load %struct.Stack*, %struct.Stack** %2
%17 = call i32 @STK_pop(%struct.Stack* %16)
%18 = load %struct.Stack*, %struct.Stack** %2
%19 = call i32 @STK_size(%struct.Stack* %18)
%20 = load %struct.Stack*, %struct.Stack** %2
%21 = call i32 @STK_deleteStack(%struct.Stack* %20)
ret i32 0
}

LLVM IR (-O2):
%struct.Stack = type { i32 }
@.str = [20 x i8] c"Number of items: %d\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call %struct.Stack* (...) @STK_newStack()
%3 = bitcast i32* %1 to i8*
store i32 4, i32* %1
%4 = call i32 @STK_push(%struct.Stack* %2, i32* %1)
%5 = call i32 @STK_size(%struct.Stack* %2)
%6 = call i64 @STK_top(%struct.Stack* %2)
%7 = inttoptr i64 %6 to i32*
%8 = load i32, i32* %7
%9 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32 @STK_pop(%struct.Stack* %2)
%11 = call i32 @STK_size(%struct.Stack* %2)
%12 = call i32 @STK_deleteStack(%struct.Stack* %2)
ret i32 0
}