#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 STK_size(struct Stack *);
scalar_t__ STK_top(struct Stack *);
int /*<<< orphan*/ assert(int);
int main(void) {
  struct Stack *testStack = STK_newStack();
  int testInt = 4;
  STK_push(testStack, &testInt);
  assert(STK_size(testStack) == 1);
  int *testPtr = (int *)STK_top(testStack);
  assert(testPtr != NULL);
  assert(testPtr == &testInt);
  STK_pop(testStack);
  assert(STK_size(testStack) == 0);
  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   1050 <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>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1070 <STK_top@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x14(%rbp),%rax
cmp    %rax,-0x20(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1040 <STK_pop@plt>
mov    -0x10(%rbp),%rdi
call   1080 <STK_size@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@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   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1050 <STK_newStack@plt>
mov    %rax,%r15
movl   $0x4,0xc(%rsp)
lea    0xc(%rsp),%r14
mov    %rax,%rdi
mov    %r14,%rsi
call   1090 <STK_push@plt>
mov    %r15,%rdi
call   1080 <STK_size@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
mov    %r15,%rdi
call   1070 <STK_top@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmp    %rbx,%r14
sete   %dil
call   1060 <assert@plt>
mov    %r15,%rdi
call   1040 <STK_pop@plt>
mov    %r15,%rdi
call   1080 <STK_size@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
mov    %r15,%rdi
call   1030 <STK_deleteStack@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.Stack = type { i32 }
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 = icmp eq i32 %9, 1
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load %struct.Stack*, %struct.Stack** %2
%14 = call i64 @STK_top(%struct.Stack* %13)
%15 = inttoptr i64 %14 to i32*
store i32* %15, i32** %4
%16 = load i32*, i32** %4
%17 = icmp ne i32* %16, null
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load i32*, i32** %4
%21 = icmp eq i32* %20, %3
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load %struct.Stack*, %struct.Stack** %2
%25 = call i32 @STK_pop(%struct.Stack* %24)
%26 = load %struct.Stack*, %struct.Stack** %2
%27 = call i32 @STK_size(%struct.Stack* %26)
%28 = icmp eq i32 %27, 0
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load %struct.Stack*, %struct.Stack** %2
%32 = call i32 @STK_deleteStack(%struct.Stack* %31)
ret i32 0
}

LLVM IR (-O2):
%struct.Stack = type { i32 }
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 = icmp eq i32 %5, 1
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = call i64 @STK_top(%struct.Stack* %2)
%10 = inttoptr i64 %9 to i32*
%11 = icmp ne i64 %9, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = icmp eq i32* %1, %10
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = call i32 @STK_pop(%struct.Stack* %2)
%18 = call i32 @STK_size(%struct.Stack* %2)
%19 = icmp eq i32 %18, 0
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = call i32 @STK_deleteStack(%struct.Stack* %2)
ret i32 0
}