#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*/ printf(char *, int);
int /*<<< orphan*/ stack_free(struct stack **);
struct stack *stack_init();
int stack_pop(struct stack **);
int /*<<< orphan*/ stack_print(struct stack *);
int /*<<< orphan*/ stack_push(struct stack **, int);
int main(int argc, const char *argv[]) {
  struct stack *stack;
  stack = stack_init();
  stack_print(stack);
  stack_push(&stack, 1);
  stack_push(&stack, 2);
  stack_push(&stack, 3);
  stack_push(&stack, 4);
  stack_push(&stack, 5);
  stack_push(&stack, 6);
  stack_print(stack);
  printf("%d\n", stack_pop(&stack));
  printf("%d\n", stack_pop(&stack));
  printf("%d\n", stack_pop(&stack));
  printf("%d\n", stack_pop(&stack));
  stack_print(stack);
  stack_free(&stack);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <stack_init@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <stack_print@plt>
lea    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   1060 <stack_push@plt>
lea    -0x18(%rbp),%rdi
mov    $0x2,%esi
call   1060 <stack_push@plt>
lea    -0x18(%rbp),%rdi
mov    $0x3,%esi
call   1060 <stack_push@plt>
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
call   1060 <stack_push@plt>
lea    -0x18(%rbp),%rdi
mov    $0x5,%esi
call   1060 <stack_push@plt>
lea    -0x18(%rbp),%rdi
mov    $0x6,%esi
call   1060 <stack_push@plt>
mov    -0x18(%rbp),%rdi
call   1050 <stack_print@plt>
lea    -0x18(%rbp),%rdi
call   1080 <stack_pop@plt>
mov    %eax,%esi
lea    0xe07(%rip),%rdi
call   1040 <printf@plt>
lea    -0x18(%rbp),%rdi
call   1080 <stack_pop@plt>
mov    %eax,%esi
lea    0xdf0(%rip),%rdi
call   1040 <printf@plt>
lea    -0x18(%rbp),%rdi
call   1080 <stack_pop@plt>
mov    %eax,%esi
lea    0xdd9(%rip),%rdi
call   1040 <printf@plt>
lea    -0x18(%rbp),%rdi
call   1080 <stack_pop@plt>
mov    %eax,%esi
lea    0xdc2(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <stack_print@plt>
lea    -0x18(%rbp),%rdi
call   1030 <stack_free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1070 <stack_init@plt>
mov    %rax,(%rsp)
mov    %rax,%rdi
call   1050 <stack_print@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1060 <stack_push@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1060 <stack_push@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1060 <stack_push@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1060 <stack_push@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1060 <stack_push@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1060 <stack_push@plt>
mov    (%rsp),%rdi
call   1050 <stack_print@plt>
mov    %rbx,%rdi
call   1080 <stack_pop@plt>
lea    0xe20(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1080 <stack_pop@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1080 <stack_pop@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1080 <stack_pop@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    (%rsp),%rdi
call   1050 <stack_print@plt>
mov    %rbx,%rdi
call   1030 <stack_free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.stack = type { i32 }
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stack*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call %struct.stack* (...) @stack_init()
store %struct.stack* %7, %struct.stack** %6
%8 = load %struct.stack*, %struct.stack** %6
%9 = call i32 @stack_print(%struct.stack* %8)
%10 = call i32 @stack_push(%struct.stack** %6, i32 1)
%11 = call i32 @stack_push(%struct.stack** %6, i32 2)
%12 = call i32 @stack_push(%struct.stack** %6, i32 3)
%13 = call i32 @stack_push(%struct.stack** %6, i32 4)
%14 = call i32 @stack_push(%struct.stack** %6, i32 5)
%15 = call i32 @stack_push(%struct.stack** %6, i32 6)
%16 = load %struct.stack*, %struct.stack** %6
%17 = call i32 @stack_print(%struct.stack* %16)
%18 = call i32 @stack_pop(%struct.stack** %6)
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = call i32 @stack_pop(%struct.stack** %6)
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = call i32 @stack_pop(%struct.stack** %6)
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = call i32 @stack_pop(%struct.stack** %6)
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = load %struct.stack*, %struct.stack** %6
%27 = call i32 @stack_print(%struct.stack* %26)
%28 = call i32 @stack_free(%struct.stack** %6)
ret i32 0
}

LLVM IR (-O2):
%struct.stack = type { i32 }
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.stack*
%4 = bitcast %struct.stack** %3 to i8*
%5 = tail call %struct.stack* (...) @stack_init()
store %struct.stack* %5, %struct.stack** %3
%6 = tail call i32 @stack_print(%struct.stack* %5)
%7 = call i32 @stack_push(%struct.stack** %3, i32 1)
%8 = call i32 @stack_push(%struct.stack** %3, i32 2)
%9 = call i32 @stack_push(%struct.stack** %3, i32 3)
%10 = call i32 @stack_push(%struct.stack** %3, i32 4)
%11 = call i32 @stack_push(%struct.stack** %3, i32 5)
%12 = call i32 @stack_push(%struct.stack** %3, i32 6)
%13 = load %struct.stack*, %struct.stack** %3
%14 = call i32 @stack_print(%struct.stack* %13)
%15 = call i32 @stack_pop(%struct.stack** %3)
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = call i32 @stack_pop(%struct.stack** %3)
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = call i32 @stack_pop(%struct.stack** %3)
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = call i32 @stack_pop(%struct.stack** %3)
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = load %struct.stack*, %struct.stack** %3
%24 = call i32 @stack_print(%struct.stack* %23)
%25 = call i32 @stack_free(%struct.stack** %3)
ret i32 0
}