#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;
};

/* Variables and functions */
struct node *list_add(struct node *, struct node *);
int /*<<< orphan*/ list_dispose(struct node *);
struct node *list_remove(struct node *);
struct node *node_malloc(int);
int main(void) {
  struct node *l = NULL;
  struct node *n1 = node_malloc(1);
  struct node *n2 = node_malloc(2);
  struct node *n3 = node_malloc(3);
  l = list_add(l, n1);
  l = list_add(l, n2);
  l = list_add(l, n3);
  l = 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)
movq   $0x0,-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   1050 <list_add@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <list_add@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <list_add@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <list_remove@plt>
mov    %rax,-0x10(%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   %rbx
mov    $0x1,%edi
call   1040 <node_malloc@plt>
mov    %rax,%rbx
mov    $0x2,%edi
call   1040 <node_malloc@plt>
mov    %rax,%r14
mov    $0x3,%edi
call   1040 <node_malloc@plt>
mov    %rax,%r15
xor    %edi,%edi
mov    %rbx,%rsi
call   1050 <list_add@plt>
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <list_add@plt>
mov    %rax,%rdi
mov    %r15,%rsi
call   1050 <list_add@plt>
mov    %rax,%rdi
call   1060 <list_remove@plt>
mov    %rax,%rdi
call   1030 <list_dispose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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