#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*/ assert(int);
struct stack *create_stack();
int /*<<< orphan*/ stack_dispose(struct stack *);
int stack_pop(struct stack *);
int /*<<< orphan*/ stack_push(struct stack *, int);
int main() {
  struct stack *s = create_stack();
  stack_push(s, 10);
  stack_push(s, 20);
  int v1 = stack_pop(s);
  assert(v1 == 20);
  int v2 = stack_pop(s);
  assert(v2 == 10);
  stack_dispose(s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <create_stack@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1050 <stack_push@plt>
mov    -0x10(%rbp),%rdi
mov    $0x14,%esi
call   1050 <stack_push@plt>
mov    -0x10(%rbp),%rdi
call   1060 <stack_pop@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x14,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1060 <stack_pop@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1070 <stack_dispose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <create_stack@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0xa,%esi
call   1050 <stack_push@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1050 <stack_push@plt>
mov    %rbx,%rdi
call   1060 <stack_pop@plt>
xor    %edi,%edi
cmp    $0x14,%eax
sete   %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
call   1060 <stack_pop@plt>
xor    %edi,%edi
cmp    $0xa,%eax
sete   %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
call   1070 <stack_dispose@plt>
xor    %eax,%eax
pop    %rbx
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* (...) @create_stack()
store %struct.stack* %5, %struct.stack** %2
%6 = load %struct.stack*, %struct.stack** %2
%7 = call i32 @stack_push(%struct.stack* %6, i32 10)
%8 = load %struct.stack*, %struct.stack** %2
%9 = call i32 @stack_push(%struct.stack* %8, i32 20)
%10 = load %struct.stack*, %struct.stack** %2
%11 = call i32 @stack_pop(%struct.stack* %10)
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 20
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load %struct.stack*, %struct.stack** %2
%17 = call i32 @stack_pop(%struct.stack* %16)
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 10
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load %struct.stack*, %struct.stack** %2
%23 = call i32 @stack_dispose(%struct.stack* %22)
ret i32 0
}

LLVM IR (-O2):
%struct.stack = type { i32 }
define i32 @main() {
%1 = tail call %struct.stack* (...) @create_stack()
%2 = tail call i32 @stack_push(%struct.stack* %1, i32 10)
%3 = tail call i32 @stack_push(%struct.stack* %1, i32 20)
%4 = tail call i32 @stack_pop(%struct.stack* %1)
%5 = icmp eq i32 %4, 20
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = tail call i32 @stack_pop(%struct.stack* %1)
%9 = icmp eq i32 %8, 10
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = tail call i32 @stack_dispose(%struct.stack* %1)
ret i32 0
}