#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 */
struct stack *create_stack();
int /*<<< orphan*/ dispose(struct stack *);
int pop(struct stack *);
int /*<<< orphan*/ push(struct stack *, int);
int main() {
  struct stack *s = create_stack();
  push(s, 1);
  push(s, 2);
  push(s, 3);
  int r1 = pop(s);
  int r2 = pop(s);
  int r3 = pop(s);
  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   1050 <create_stack@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1060 <push@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
call   1060 <push@plt>
mov    -0x10(%rbp),%rdi
mov    $0x3,%esi
call   1060 <push@plt>
mov    -0x10(%rbp),%rdi
call   1040 <pop@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <pop@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <pop@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <dispose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1050 <create_stack@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1,%esi
call   1060 <push@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1060 <push@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1060 <push@plt>
mov    %rbx,%rdi
call   1040 <pop@plt>
mov    %rbx,%rdi
call   1040 <pop@plt>
mov    %rbx,%rdi
call   1040 <pop@plt>
mov    %rbx,%rdi
call   1030 <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 @push(%struct.stack* %7, i32 1)
%9 = load %struct.stack*, %struct.stack** %2
%10 = call i32 @push(%struct.stack* %9, i32 2)
%11 = load %struct.stack*, %struct.stack** %2
%12 = call i32 @push(%struct.stack* %11, i32 3)
%13 = load %struct.stack*, %struct.stack** %2
%14 = call i32 @pop(%struct.stack* %13)
store i32 %14, i32* %3
%15 = load %struct.stack*, %struct.stack** %2
%16 = call i32 @pop(%struct.stack* %15)
store i32 %16, i32* %4
%17 = load %struct.stack*, %struct.stack** %2
%18 = call i32 @pop(%struct.stack* %17)
store i32 %18, i32* %5
%19 = load %struct.stack*, %struct.stack** %2
%20 = call i32 @dispose(%struct.stack* %19)
ret i32 0
}

LLVM IR (-O2):
%struct.stack = type { i32 }
define i32 @main() {
%1 = tail call %struct.stack* (...) @create_stack()
%2 = tail call i32 @push(%struct.stack* %1, i32 1)
%3 = tail call i32 @push(%struct.stack* %1, i32 2)
%4 = tail call i32 @push(%struct.stack* %1, i32 3)
%5 = tail call i32 @pop(%struct.stack* %1)
%6 = tail call i32 @pop(%struct.stack* %1)
%7 = tail call i32 @pop(%struct.stack* %1)
%8 = tail call i32 @dispose(%struct.stack* %1)
ret i32 0
}