#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 */
int /*<<< orphan*/ append_node(struct node *, struct node *);
struct node *create_list(struct node *);
struct node *create_node(int);
int /*<<< orphan*/ print_list(struct node *);
int /*<<< orphan*/ printf(char *);
struct node *remove_node(struct node *, struct node *);
int main(void) {
  struct node *list = NULL;
  struct node *node_1, *node_2, *node_3;
  int value_1 = 1, value_2 = 2, value_3 = 3;
  node_1 = create_node(value_1);
  if (!node_1) {
    printf("Cannot create node :(\n");
  }
  list = create_list(node_1);
  node_2 = create_node(value_2);
  if (!node_2) {
    printf("Cannot create node :(\n");
  }
  node_3 = create_node(value_3);
  if (!node_3) {
    printf("Cannot create node :(\n");
  }
  append_node(list, node_2);
  append_node(list, node_3);
  printf("After adding two nodes.\n");
  print_list(list);
  list = remove_node(list, node_1);
  printf("After removing one node.\n");
  print_list(list);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x2,-0x30(%rbp)
movl   $0x3,-0x34(%rbp)
mov    -0x2c(%rbp),%edi
call   1080 <create_node@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11af <main+0x4f>
lea    0xe56(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <create_list@plt>
mov    %rax,-0x10(%rbp)
mov    -0x30(%rbp),%edi
call   1080 <create_node@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11df <main+0x7f>
lea    0xe26(%rip),%rdi
call   1050 <printf@plt>
mov    -0x34(%rbp),%edi
call   1080 <create_node@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1202 <main+0xa2>
lea    0xe03(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <append_node@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <append_node@plt>
lea    0xdf4(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <print_list@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <remove_node@plt>
mov    %rax,-0x10(%rbp)
lea    0xde7(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <print_list@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x1,%edi
call   1080 <create_node@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1186 <main+0x26>
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1050 <create_list@plt>
mov    %rax,%r12
mov    $0x2,%edi
call   1080 <create_node@plt>
mov    %rax,%r15
test   %rax,%rax
jne    11af <main+0x4f>
lea    0xe56(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1080 <create_node@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11cd <main+0x6d>
lea    0xe38(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1060 <append_node@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <append_node@plt>
lea    0xe2c(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1040 <print_list@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1070 <remove_node@plt>
mov    %rax,%rbx
lea    0xe22(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <print_list@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [23 x i8] c"Cannot create node :(\0A\00"
@.str.1 = [25 x i8] c"After adding two nodes.\0A\00"
@.str.2 = [26 x i8] c"After removing one node.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.node*
%3 = alloca %struct.node*
%4 = alloca %struct.node*
%5 = alloca %struct.node*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store %struct.node* null, %struct.node** %2
store i32 1, i32* %6
store i32 2, i32* %7
store i32 3, i32* %8
%9 = load i32, i32* %6
%10 = call %struct.node* @create_node(i32 %9)
store %struct.node* %10, %struct.node** %3
%11 = load %struct.node*, %struct.node** %3
%12 = icmp ne %struct.node* %11, null
br i1 %12, label %15, label %13
13: ; preds = %0
%14 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %0
%16 = load %struct.node*, %struct.node** %3
%17 = call %struct.node* @create_list(%struct.node* %16)
store %struct.node* %17, %struct.node** %2
%18 = load i32, i32* %7
%19 = call %struct.node* @create_node(i32 %18)
store %struct.node* %19, %struct.node** %4
%20 = load %struct.node*, %struct.node** %4
%21 = icmp ne %struct.node* %20, null
br i1 %21, label %24, label %22
22: ; preds = %15
%23 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %15
%25 = load i32, i32* %8
%26 = call %struct.node* @create_node(i32 %25)
store %struct.node* %26, %struct.node** %5
%27 = load %struct.node*, %struct.node** %5
%28 = icmp ne %struct.node* %27, null
br i1 %28, label %31, label %29
29: ; preds = %24
%30 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %29, %24
%32 = load %struct.node*, %struct.node** %2
%33 = load %struct.node*, %struct.node** %4
%34 = call i32 @append_node(%struct.node* %32, %struct.node* %33)
%35 = load %struct.node*, %struct.node** %2
%36 = load %struct.node*, %struct.node** %5
%37 = call i32 @append_node(%struct.node* %35, %struct.node* %36)
%38 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%39 = load %struct.node*, %struct.node** %2
%40 = call i32 @print_list(%struct.node* %39)
%41 = load %struct.node*, %struct.node** %2
%42 = load %struct.node*, %struct.node** %3
%43 = call %struct.node* @remove_node(%struct.node* %41, %struct.node* %42)
store %struct.node* %43, %struct.node** %2
%44 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%45 = load %struct.node*, %struct.node** %2
%46 = call i32 @print_list(%struct.node* %45)
ret i32 0
}

LLVM IR (-O2):
%struct.node = type { i32 }
@str.4 = [22 x i8] c"Cannot create node :(\00"
@str.5 = [24 x i8] c"After adding two nodes.\00"
@str.6 = [25 x i8] c"After removing one node.\00"
define i32 @main() {
%1 = tail call %struct.node* @create_node(i32 1)
%2 = icmp eq %struct.node* %1, null
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.4, i64 0, i64 0))
br label %5
5: ; preds = %3, %0
%6 = tail call %struct.node* @create_list(%struct.node* %1)
%7 = tail call %struct.node* @create_node(i32 2)
%8 = icmp eq %struct.node* %7, null
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.4, i64 0, i64 0))
br label %11
11: ; preds = %9, %5
%12 = tail call %struct.node* @create_node(i32 3)
%13 = icmp eq %struct.node* %12, null
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.4, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
%17 = tail call i32 @append_node(%struct.node* %6, %struct.node* %7)
%18 = tail call i32 @append_node(%struct.node* %6, %struct.node* %12)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.5, i64 0, i64 0))
%20 = tail call i32 @print_list(%struct.node* %6)
%21 = tail call %struct.node* @remove_node(%struct.node* %6, %struct.node* %1)
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.6, i64 0, i64 0))
%23 = tail call i32 @print_list(%struct.node* %21)
ret i32 0
}