#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);
int /*<<< orphan*/ delete_stack(struct Stack *);
int pop(struct Stack *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ push(struct Stack *, int);
int main() {
  struct Stack *stack = create_stack(100);
  push(stack, 10);
  push(stack, 20);
  push(stack, 30);
  printf("%d popped from stack\n", pop(stack));
  printf("%d popped from stack\n", pop(stack));
  printf("%d popped from stack\n", pop(stack));
  delete_stack(stack);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x64,%edi
call   1050 <create_stack@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1060 <push@plt>
mov    -0x10(%rbp),%rdi
mov    $0x14,%esi
call   1060 <push@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1e,%esi
call   1060 <push@plt>
mov    -0x10(%rbp),%rdi
call   1040 <pop@plt>
mov    %eax,%esi
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <pop@plt>
mov    %eax,%esi
lea    0xe40(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <pop@plt>
mov    %eax,%esi
lea    0xe29(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <delete_stack@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x64,%edi
call   1050 <create_stack@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0xa,%esi
call   1060 <push@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1060 <push@plt>
mov    %rbx,%rdi
mov    $0x1e,%esi
call   1060 <push@plt>
mov    %rbx,%rdi
call   1040 <pop@plt>
lea    0xe69(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <pop@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <pop@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1070 <delete_stack@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.Stack = type { i32 }
@.str = [22 x i8] c"%d popped from stack\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.Stack*
store i32 0, i32* %1
%3 = call %struct.Stack* @create_stack(i32 100)
store %struct.Stack* %3, %struct.Stack** %2
%4 = load %struct.Stack*, %struct.Stack** %2
%5 = call i32 @push(%struct.Stack* %4, i32 10)
%6 = load %struct.Stack*, %struct.Stack** %2
%7 = call i32 @push(%struct.Stack* %6, i32 20)
%8 = load %struct.Stack*, %struct.Stack** %2
%9 = call i32 @push(%struct.Stack* %8, i32 30)
%10 = load %struct.Stack*, %struct.Stack** %2
%11 = call i32 @pop(%struct.Stack* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load %struct.Stack*, %struct.Stack** %2
%14 = call i32 @pop(%struct.Stack* %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load %struct.Stack*, %struct.Stack** %2
%17 = call i32 @pop(%struct.Stack* %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load %struct.Stack*, %struct.Stack** %2
%20 = call i32 @delete_stack(%struct.Stack* %19)
ret i32 0
}

LLVM IR (-O2):
%struct.Stack = type { i32 }
@.str = [22 x i8] c"%d popped from stack\0A\00"
define i32 @main() {
%1 = tail call %struct.Stack* @create_stack(i32 100)
%2 = tail call i32 @push(%struct.Stack* %1, i32 10)
%3 = tail call i32 @push(%struct.Stack* %1, i32 20)
%4 = tail call i32 @push(%struct.Stack* %1, i32 30)
%5 = tail call i32 @pop(%struct.Stack* %1)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 @pop(%struct.Stack* %1)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = tail call i32 @pop(%struct.Stack* %1)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = tail call i32 @delete_stack(%struct.Stack* %1)
ret i32 0
}