#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_get_sum(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 sum = stack_get_sum(s);
  assert(sum == 30);
  int result1 = stack_pop(s);
  assert(result1 == 20);
  int result2 = stack_pop(s);
  assert(result2 == 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   1040 <create_stack@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1060 <stack_push@plt>
mov    -0x10(%rbp),%rdi
mov    $0x14,%esi
call   1060 <stack_push@plt>
mov    -0x10(%rbp),%rdi
call   1030 <stack_get_sum@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1e,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1070 <stack_pop@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x14,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1070 <stack_pop@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1080 <stack_dispose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

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