#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*/ listappendcopy(struct node *, struct node *);
struct node *listcopy(struct node *);
struct node *listdelelem(struct node *, int);
int /*<<< orphan*/ listfree(struct node *);
int /*<<< orphan*/ listinsert(struct node *, int, struct node *);
struct node *listnew(int);
int /*<<< orphan*/ multiples(struct node *, int);
int /*<<< orphan*/ print_list(struct node *);
int /*<<< orphan*/ printf(char *);
int main(void) {
  struct node *myList = listnew(6), *otherList = listnew(3), *copyList;
  multiples(myList, 3);
  multiples(otherList, 2);
  printf("Data in my list:\n");
  print_list(myList);
  printf("Data in other list:\n");
  print_list(otherList);
  printf("Appending copy of other list to my list:\n");
  listappendcopy(myList, otherList);
  printf("Data in my list:\n");
  print_list(myList);
  printf("Inserting other list at index 3 in my list:\n");
  listinsert(myList, 3, otherList);
  printf("Data in my list:\n");
  print_list(myList);
  printf("Deleting element 2 of my list\n");
  listdelelem(myList, 2);
  print_list(myList);
  printf("Deleting element 0 of my list\n");
  myList = listdelelem(myList, 0);
  print_list(myList);
  printf("Copying my list.\n");
  copyList = listcopy(myList);
  printf("Deleting my list.\n");
  listfree(myList);
  myList = otherList = NULL;
  printf("Contents of copy list:\n");
  print_list(copyList);
  listfree(copyList);
  copyList = NULL;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x6,%edi
call   1090 <listnew@plt>
mov    %rax,-0x10(%rbp)
mov    $0x3,%edi
call   1090 <listnew@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3,%esi
call   1060 <multiples@plt>
mov    -0x18(%rbp),%rdi
mov    $0x2,%esi
call   1060 <multiples@plt>
lea    0xe22(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <print_list@plt>
lea    0xe1f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <print_list@plt>
lea    0xe1f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <listappendcopy@plt>
lea    0xddf(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <print_list@plt>
lea    0xe1b(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x3,%esi
call   10a0 <listinsert@plt>
lea    0xdac(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <print_list@plt>
lea    0xe15(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
call   1080 <listdelelem@plt>
mov    -0x10(%rbp),%rdi
call   1040 <print_list@plt>
lea    0xe11(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1080 <listdelelem@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <print_list@plt>
lea    0xe0c(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   10b0 <listcopy@plt>
mov    %rax,-0x20(%rbp)
lea    0xe05(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <listfree@plt>
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xdf3(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <print_list@plt>
mov    -0x20(%rbp),%rdi
call   1030 <listfree@plt>
movq   $0x0,-0x20(%rbp)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x6,%edi
call   1090 <listnew@plt>
mov    %rax,%rbx
mov    $0x3,%edi
call   1090 <listnew@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    $0x3,%esi
call   1060 <multiples@plt>
mov    %r14,%rdi
mov    $0x2,%esi
call   1060 <multiples@plt>
lea    0xe99(%rip),%r15
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <print_list@plt>
lea    0xe19(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1050 <print_list@plt>
lea    0xe19(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <listappendcopy@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <print_list@plt>
lea    0xe1b(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %r14,%rdx
call   10a0 <listinsert@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <print_list@plt>
lea    0xe2c(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1080 <listdelelem@plt>
mov    %rbx,%rdi
call   1050 <print_list@plt>
lea    0xe29(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <listdelelem@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <print_list@plt>
lea    0xe26(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   10b0 <listcopy@plt>
mov    %rax,%r14
lea    0xe20(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <listfree@plt>
lea    0xe1e(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1050 <print_list@plt>
mov    %r14,%rdi
call   1030 <listfree@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [18 x i8] c"Data in my list:\0A\00"
@.str.1 = [21 x i8] c"Data in other list:\0A\00"
@.str.2 = [42 x i8] c"Appending copy of other list to my list:\0A\00"
@.str.3 = [45 x i8] c"Inserting other list at index 3 in my list:\0A\00"
@.str.4 = [31 x i8] c"Deleting element 2 of my list\0A\00"
@.str.5 = [31 x i8] c"Deleting element 0 of my list\0A\00"
@.str.6 = [18 x i8] c"Copying my list.\0A\00"
@.str.7 = [19 x i8] c"Deleting my list.\0A\00"
@.str.8 = [24 x i8] c"Contents of copy list:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.node*
%3 = alloca %struct.node*
%4 = alloca %struct.node*
store i32 0, i32* %1
%5 = call %struct.node* @listnew(i32 6)
store %struct.node* %5, %struct.node** %2
%6 = call %struct.node* @listnew(i32 3)
store %struct.node* %6, %struct.node** %3
%7 = load %struct.node*, %struct.node** %2
%8 = call i32 @multiples(%struct.node* %7, i32 3)
%9 = load %struct.node*, %struct.node** %3
%10 = call i32 @multiples(%struct.node* %9, i32 2)
%11 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%12 = load %struct.node*, %struct.node** %2
%13 = call i32 @print_list(%struct.node* %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%15 = load %struct.node*, %struct.node** %3
%16 = call i32 @print_list(%struct.node* %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%18 = load %struct.node*, %struct.node** %2
%19 = load %struct.node*, %struct.node** %3
%20 = call i32 @listappendcopy(%struct.node* %18, %struct.node* %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%22 = load %struct.node*, %struct.node** %2
%23 = call i32 @print_list(%struct.node* %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%25 = load %struct.node*, %struct.node** %2
%26 = load %struct.node*, %struct.node** %3
%27 = call i32 @listinsert(%struct.node* %25, i32 3, %struct.node* %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%29 = load %struct.node*, %struct.node** %2
%30 = call i32 @print_list(%struct.node* %29)
%31 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%32 = load %struct.node*, %struct.node** %2
%33 = call %struct.node* @listdelelem(%struct.node* %32, i32 2)
%34 = load %struct.node*, %struct.node** %2
%35 = call i32 @print_list(%struct.node* %34)
%36 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%37 = load %struct.node*, %struct.node** %2
%38 = call %struct.node* @listdelelem(%struct.node* %37, i32 0)
store %struct.node* %38, %struct.node** %2
%39 = load %struct.node*, %struct.node** %2
%40 = call i32 @print_list(%struct.node* %39)
%41 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%42 = load %struct.node*, %struct.node** %2
%43 = call %struct.node* @listcopy(%struct.node* %42)
store %struct.node* %43, %struct.node** %4
%44 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%45 = load %struct.node*, %struct.node** %2
%46 = call i32 @listfree(%struct.node* %45)
store %struct.node* null, %struct.node** %3
store %struct.node* null, %struct.node** %2
%47 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
%48 = load %struct.node*, %struct.node** %4
%49 = call i32 @print_list(%struct.node* %48)
%50 = load %struct.node*, %struct.node** %4
%51 = call i32 @listfree(%struct.node* %50)
store %struct.node* null, %struct.node** %4
ret i32 0
}

LLVM IR (-O2):
%struct.node = type { i32 }
@str.9 = [20 x i8] c"Data in other list:\00"
@str.10 = [41 x i8] c"Appending copy of other list to my list:\00"
@str.12 = [44 x i8] c"Inserting other list at index 3 in my list:\00"
@str.13 = [17 x i8] c"Data in my list:\00"
@str.14 = [30 x i8] c"Deleting element 2 of my list\00"
@str.15 = [30 x i8] c"Deleting element 0 of my list\00"
@str.16 = [17 x i8] c"Copying my list.\00"
@str.17 = [18 x i8] c"Deleting my list.\00"
@str.18 = [23 x i8] c"Contents of copy list:\00"
define i32 @main() {
%1 = tail call %struct.node* @listnew(i32 6)
%2 = tail call %struct.node* @listnew(i32 3)
%3 = tail call i32 @multiples(%struct.node* %1, i32 3)
%4 = tail call i32 @multiples(%struct.node* %2, i32 2)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.13, i64 0, i64 0))
%6 = tail call i32 @print_list(%struct.node* %1)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.9, i64 0, i64 0))
%8 = tail call i32 @print_list(%struct.node* %2)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.10, i64 0, i64 0))
%10 = tail call i32 @listappendcopy(%struct.node* %1, %struct.node* %2)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.13, i64 0, i64 0))
%12 = tail call i32 @print_list(%struct.node* %1)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.12, i64 0, i64 0))
%14 = tail call i32 @listinsert(%struct.node* %1, i32 3, %struct.node* %2)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.13, i64 0, i64 0))
%16 = tail call i32 @print_list(%struct.node* %1)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.14, i64 0, i64 0))
%18 = tail call %struct.node* @listdelelem(%struct.node* %1, i32 2)
%19 = tail call i32 @print_list(%struct.node* %1)
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.15, i64 0, i64 0))
%21 = tail call %struct.node* @listdelelem(%struct.node* %1, i32 0)
%22 = tail call i32 @print_list(%struct.node* %21)
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.16, i64 0, i64 0))
%24 = tail call %struct.node* @listcopy(%struct.node* %21)
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.17, i64 0, i64 0))
%26 = tail call i32 @listfree(%struct.node* %21)
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.18, i64 0, i64 0))
%28 = tail call i32 @print_list(%struct.node* %24)
%29 = tail call i32 @listfree(%struct.node* %24)
ret i32 0
}