#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_ptr_equals(char *, int, void *, int /*<<< orphan*/);
struct stack *alloc_stack();
int /*<<< orphan*/ free_stack(struct stack *);
int /*<<< orphan*/ stack_pop(struct stack *);
int /*<<< orphan*/ stack_push(struct stack *, void *);
void test_stack_retains_elements(void) {
  struct stack *stack = alloc_stack();
  stack_push(stack, (void *)0);
  stack_push(stack, (void *)1);
  __assert_ptr_equals("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                      "outputs/2022-01-22/02-19-57/repos/headius/jato/refs/"
                      "heads/master/test/unit/vm/stack-test.c",
                      16, ((void *)1), (stack_pop(stack)));
  __assert_ptr_equals("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                      "outputs/2022-01-22/02-19-57/repos/headius/jato/refs/"
                      "heads/master/test/unit/vm/stack-test.c",
                      17, ((void *)0), (stack_pop(stack)));
  free_stack(stack);
}


x86 assembly (clang, -O0):
<test_stack_retains_elements>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <alloc_stack@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <stack_push@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1050 <stack_push@plt>
mov    -0x8(%rbp),%rdi
call   1060 <stack_pop@plt>
mov    %eax,%ecx
lea    0xe70(%rip),%rdi
mov    $0x10,%esi
mov    $0x1,%edx
call   1070 <__assert_ptr_equals@plt>
mov    -0x8(%rbp),%rdi
call   1060 <stack_pop@plt>
mov    %eax,%ecx
lea    0xe4f(%rip),%rdi
mov    $0x11,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1070 <__assert_ptr_equals@plt>
mov    -0x8(%rbp),%rdi
call   1040 <free_stack@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_stack_retains_elements>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <alloc_stack@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
call   1050 <stack_push@plt>
mov    $0x1,%esi
mov    %rbx,%rdi
call   1050 <stack_push@plt>
mov    %rbx,%rdi
call   1060 <stack_pop@plt>
lea    0xe7c(%rip),%r14
mov    $0x1,%edx
mov    %r14,%rdi
mov    $0x10,%esi
mov    %eax,%ecx
call   1070 <__assert_ptr_equals@plt>
mov    %rbx,%rdi
call   1060 <stack_pop@plt>
mov    %r14,%rdi
mov    $0x11,%esi
xor    %edx,%edx
mov    %eax,%ecx
call   1070 <__assert_ptr_equals@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <free_stack@plt>

LLVM IR (-O0):
%struct.stack = type { i32 }
@.str = [147 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/headius/jato/refs/heads/master/test/unit/vm/stack-test.c\00"
define void @test_stack_retains_elements() {
%1 = alloca %struct.stack*
%2 = call %struct.stack* (...) @alloc_stack()
store %struct.stack* %2, %struct.stack** %1
%3 = load %struct.stack*, %struct.stack** %1
%4 = call i32 @stack_push(%struct.stack* %3, i8* null)
%5 = load %struct.stack*, %struct.stack** %1
%6 = call i32 @stack_push(%struct.stack* %5, i8* inttoptr (i64 1 to i8*))
%7 = load %struct.stack*, %struct.stack** %1
%8 = call i32 @stack_pop(%struct.stack* %7)
%9 = call i32 @__assert_ptr_equals(i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str, i64 0, i64 0), i32 16, i8* inttoptr (i64 1 to i8*), i32 %8)
%10 = load %struct.stack*, %struct.stack** %1
%11 = call i32 @stack_pop(%struct.stack* %10)
%12 = call i32 @__assert_ptr_equals(i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str, i64 0, i64 0), i32 17, i8* null, i32 %11)
%13 = load %struct.stack*, %struct.stack** %1
%14 = call i32 @free_stack(%struct.stack* %13)
ret void
}

LLVM IR (-O2):
%struct.stack = type { i32 }
@.str = [147 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/headius/jato/refs/heads/master/test/unit/vm/stack-test.c\00"
define void @test_stack_retains_elements() {
%1 = tail call %struct.stack* (...) @alloc_stack()
%2 = tail call i32 @stack_push(%struct.stack* %1, i8* null)
%3 = tail call i32 @stack_push(%struct.stack* %1, i8* inttoptr (i64 1 to i8*))
%4 = tail call i32 @stack_pop(%struct.stack* %1)
%5 = tail call i32 @__assert_ptr_equals(i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str, i64 0, i64 0), i32 16, i8* inttoptr (i64 1 to i8*), i32 %4)
%6 = tail call i32 @stack_pop(%struct.stack* %1)
%7 = tail call i32 @__assert_ptr_equals(i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str, i64 0, i64 0), i32 17, i8* null, i32 %6)
%8 = tail call i32 @free_stack(%struct.stack* %1)
ret void
}