#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 node {
  int dummy;
};
struct list {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ list_add(struct list *, struct node *);
struct list *list_create();
int /*<<< orphan*/ list_dispose(struct list *);
int list_remove(struct list *);
struct node *node_malloc(int);
int main(void) {
  int i;
  struct list *l = list_create();
  struct node *n1 = node_malloc(1);
  struct node *n2 = node_malloc(2);
  struct node *n3 = node_malloc(3);
  list_add(l, n1);
  list_add(l, n2);
  list_add(l, n3);
  i = list_remove(l);
  list_dispose(l);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <list_create@plt>
mov    %rax,-0x10(%rbp)
mov    $0x1,%edi
call   1040 <node_malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x2,%edi
call   1040 <node_malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x3,%edi
call   1040 <node_malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <list_add@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <list_add@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <list_add@plt>
mov    -0x10(%rbp),%rdi
call   1070 <list_remove@plt>
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <list_dispose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <list_create@plt>
mov    %rax,%rbx
mov    $0x1,%edi
call   1040 <node_malloc@plt>
mov    %rax,%r14
mov    $0x2,%edi
call   1040 <node_malloc@plt>
mov    %rax,%r15
mov    $0x3,%edi
call   1040 <node_malloc@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <list_add@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <list_add@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <list_add@plt>
mov    %rbx,%rdi
call   1070 <list_remove@plt>
mov    %rbx,%rdi
call   1030 <list_dispose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.list = type { i32 }
%struct.node = type { i32 }
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.list*
%4 = alloca %struct.node*
%5 = alloca %struct.node*
%6 = alloca %struct.node*
store i32 0, i32* %1
%7 = call %struct.list* (...) @list_create()
store %struct.list* %7, %struct.list** %3
%8 = call %struct.node* @node_malloc(i32 1)
store %struct.node* %8, %struct.node** %4
%9 = call %struct.node* @node_malloc(i32 2)
store %struct.node* %9, %struct.node** %5
%10 = call %struct.node* @node_malloc(i32 3)
store %struct.node* %10, %struct.node** %6
%11 = load %struct.list*, %struct.list** %3
%12 = load %struct.node*, %struct.node** %4
%13 = call i32 @list_add(%struct.list* %11, %struct.node* %12)
%14 = load %struct.list*, %struct.list** %3
%15 = load %struct.node*, %struct.node** %5
%16 = call i32 @list_add(%struct.list* %14, %struct.node* %15)
%17 = load %struct.list*, %struct.list** %3
%18 = load %struct.node*, %struct.node** %6
%19 = call i32 @list_add(%struct.list* %17, %struct.node* %18)
%20 = load %struct.list*, %struct.list** %3
%21 = call i32 @list_remove(%struct.list* %20)
store i32 %21, i32* %2
%22 = load %struct.list*, %struct.list** %3
%23 = call i32 @list_dispose(%struct.list* %22)
ret i32 0
}

LLVM IR (-O2):
%struct.list = type { i32 }
%struct.node = type { i32 }
define i32 @main() {
%1 = tail call %struct.list* (...) @list_create()
%2 = tail call %struct.node* @node_malloc(i32 1)
%3 = tail call %struct.node* @node_malloc(i32 2)
%4 = tail call %struct.node* @node_malloc(i32 3)
%5 = tail call i32 @list_add(%struct.list* %1, %struct.node* %2)
%6 = tail call i32 @list_add(%struct.list* %1, %struct.node* %3)
%7 = tail call i32 @list_add(%struct.list* %1, %struct.node* %4)
%8 = tail call i32 @list_remove(%struct.list* %1)
%9 = tail call i32 @list_dispose(%struct.list* %1)
ret i32 0
}