#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 my_list {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ free(struct my_list *);
int /*<<< orphan*/ list_add_element(struct my_list *, int);
int /*<<< orphan*/ list_free(struct my_list *);
struct my_list *list_new();
int /*<<< orphan*/ list_print(struct my_list *);
int /*<<< orphan*/ list_remove_element(struct my_list *);
int main(void) {
  struct my_list *mt = NULL;
  mt = list_new();
  list_add_element(mt, 1);
  list_add_element(mt, 2);
  list_add_element(mt, 3);
  list_add_element(mt, 4);
  list_print(mt);
  list_remove_element(mt);
  list_print(mt);
  list_free(mt);
  free(mt);
  mt = NULL;
  list_print(mt);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1070 <list_new@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1080 <list_add_element@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
call   1080 <list_add_element@plt>
mov    -0x10(%rbp),%rdi
mov    $0x3,%esi
call   1080 <list_add_element@plt>
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1080 <list_add_element@plt>
mov    -0x10(%rbp),%rdi
call   1040 <list_print@plt>
mov    -0x10(%rbp),%rdi
call   1060 <list_remove_element@plt>
mov    -0x10(%rbp),%rdi
call   1040 <list_print@plt>
mov    -0x10(%rbp),%rdi
call   1050 <list_free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <list_print@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1070 <list_new@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1,%esi
call   1080 <list_add_element@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1080 <list_add_element@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1080 <list_add_element@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1080 <list_add_element@plt>
mov    %rbx,%rdi
call   1040 <list_print@plt>
mov    %rbx,%rdi
call   1060 <list_remove_element@plt>
mov    %rbx,%rdi
call   1040 <list_print@plt>
mov    %rbx,%rdi
call   1050 <list_free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1040 <list_print@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.my_list = type { i32 }
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.my_list*
store i32 0, i32* %1
store %struct.my_list* null, %struct.my_list** %2
%3 = call %struct.my_list* (...) @list_new()
store %struct.my_list* %3, %struct.my_list** %2
%4 = load %struct.my_list*, %struct.my_list** %2
%5 = call i32 @list_add_element(%struct.my_list* %4, i32 1)
%6 = load %struct.my_list*, %struct.my_list** %2
%7 = call i32 @list_add_element(%struct.my_list* %6, i32 2)
%8 = load %struct.my_list*, %struct.my_list** %2
%9 = call i32 @list_add_element(%struct.my_list* %8, i32 3)
%10 = load %struct.my_list*, %struct.my_list** %2
%11 = call i32 @list_add_element(%struct.my_list* %10, i32 4)
%12 = load %struct.my_list*, %struct.my_list** %2
%13 = call i32 @list_print(%struct.my_list* %12)
%14 = load %struct.my_list*, %struct.my_list** %2
%15 = call i32 @list_remove_element(%struct.my_list* %14)
%16 = load %struct.my_list*, %struct.my_list** %2
%17 = call i32 @list_print(%struct.my_list* %16)
%18 = load %struct.my_list*, %struct.my_list** %2
%19 = call i32 @list_free(%struct.my_list* %18)
%20 = load %struct.my_list*, %struct.my_list** %2
%21 = call i32 @free(%struct.my_list* %20)
store %struct.my_list* null, %struct.my_list** %2
%22 = load %struct.my_list*, %struct.my_list** %2
%23 = call i32 @list_print(%struct.my_list* %22)
ret i32 0
}

LLVM IR (-O2):
%struct.my_list = type { i32 }
define i32 @main() {
%1 = tail call %struct.my_list* (...) @list_new()
%2 = tail call i32 @list_add_element(%struct.my_list* %1, i32 1)
%3 = tail call i32 @list_add_element(%struct.my_list* %1, i32 2)
%4 = tail call i32 @list_add_element(%struct.my_list* %1, i32 3)
%5 = tail call i32 @list_add_element(%struct.my_list* %1, i32 4)
%6 = tail call i32 @list_print(%struct.my_list* %1)
%7 = tail call i32 @list_remove_element(%struct.my_list* %1)
%8 = tail call i32 @list_print(%struct.my_list* %1)
%9 = tail call i32 @list_free(%struct.my_list* %1)
%10 = tail call i32 @free(%struct.my_list* %1)
%11 = tail call i32 @list_print(%struct.my_list* null)
ret i32 0
}