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

/* Variables and functions */
int /*<<< orphan*/ addNode(struct link *, int);
int /*<<< orphan*/ findNode(struct link *, int);
int /*<<< orphan*/ getchar();
struct link *makeList(int);
int /*<<< orphan*/ printList(struct link *);
int /*<<< orphan*/ printf(char *);
struct link *removeList(struct link *);
struct link *removeNode(struct link *, int);
int /*<<< orphan*/ scanf(char *, int *);
struct link *sortList(struct link *);
int main() {
  struct link *head = NULL;
  int choice = -1, num;
  while (choice != 0) {
    if (head == NULL) {
      printf("\nMenu:\n(1) Make New List\n(0) Exit program\n\n--->");
      scanf("%d", &choice);
      if (choice) {
        printf("Enter head node value: ");
        scanf("%d", &num);
        head = makeList(num);
      } else if (!choice) {
      } else {
        printf("Please submit a valid input\n");
      }
    } else {
      printf("\nPlease choose an option:\n(1) Add a Node		"
             "			\n(2) Remove List\n(3) Remove a Node\n(4) Find "
             "a Node\n(5) Print the List				"
             "	\n(6) Sort List\n(0) Exit the program\n\n---> ");
      scanf("%d", &choice);
      switch (choice) {
      case 1:
        printf("Enter new Node value: ");
        scanf("%d", &num);
        addNode(head, num);
        break;
      case 2:
        head = removeList(head);
        break;
      case 3:
        printf("Remove Node of value: ");
        scanf("%d", &num);
        head = removeNode(head, num);
        break;
      case 4:
        printf("Find Node of value: ");
        scanf("%d", &num);
        if (findNode(head, num)) {
          printf("Node exists\n");
        } else {
          printf("Node not found\n");
        }
        break;
      case 5:
        printList(head);
        break;
      case 6:
        head = sortList(head);
        break;
      case 0:
        break;
      default:
        printf("Please enter a valid input\n");
      }
    }
  }
  if (head != NULL) {
    head = removeList(head);
  }
  printf("\n[Press ENTER to close]");
  getchar();
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     138a <main+0x1ea>
cmpq   $0x0,-0x10(%rbp)
jne    124b <main+0xab>
lea    0xe42(%rip),%rdi
call   1040 <printf@plt>
lea    0xe66(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1090 <scanf@plt>
cmpl   $0x0,-0x14(%rbp)
je     1226 <main+0x86>
lea    0xe4f(%rip),%rdi
call   1040 <printf@plt>
lea    0xe40(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x18(%rbp),%edi
call   1070 <makeList@plt>
mov    %rax,-0x10(%rbp)
jmp    1246 <main+0xa6>
cmpl   $0x0,-0x14(%rbp)
jne    1235 <main+0x95>
jmp    1241 <main+0xa1>
lea    0xe2b(%rip),%rdi
call   1040 <printf@plt>
jmp    1246 <main+0xa6>
jmp    1385 <main+0x1e5>
lea    0xe32(%rip),%rdi
call   1040 <printf@plt>
lea    0xdee(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x14(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x6,%rax
ja     1374 <main+0x1d4>
mov    -0x20(%rbp),%rax
lea    0xd7d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe93(%rip),%rdi
call   1040 <printf@plt>
lea    0xdad(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   10a0 <addNode@plt>
jmp    1380 <main+0x1e0>
mov    -0x10(%rbp),%rdi
call   1050 <removeList@plt>
mov    %rax,-0x10(%rbp)
jmp    1380 <main+0x1e0>
lea    0xe6b(%rip),%rdi
call   1040 <printf@plt>
lea    0xd6e(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1030 <removeNode@plt>
mov    %rax,-0x10(%rbp)
jmp    1380 <main+0x1e0>
lea    0xe51(%rip),%rdi
call   1040 <printf@plt>
lea    0xd3d(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   10c0 <findNode@plt>
cmp    $0x0,%eax
je     133e <main+0x19e>
lea    0xe35(%rip),%rdi
call   1040 <printf@plt>
jmp    134a <main+0x1aa>
lea    0xe31(%rip),%rdi
call   1040 <printf@plt>
jmp    1380 <main+0x1e0>
mov    -0x10(%rbp),%rdi
call   10b0 <printList@plt>
jmp    1380 <main+0x1e0>
mov    -0x10(%rbp),%rdi
call   1080 <sortList@plt>
mov    %rax,-0x10(%rbp)
jmp    1380 <main+0x1e0>
jmp    1380 <main+0x1e0>
lea    0xe0b(%rip),%rdi
call   1040 <printf@plt>
jmp    1385 <main+0x1e5>
jmp    11be <main+0x1e>
cmpq   $0x0,-0x10(%rbp)
je     13a2 <main+0x202>
mov    -0x10(%rbp),%rdi
call   1050 <removeList@plt>
mov    %rax,-0x10(%rbp)
lea    0xdf9(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0xffffffff,0x4(%rsp)
ff
xor    %r12d,%r12d
lea    0xe7f(%rip),%rbx
lea    0x4(%rsp),%r15
mov    %rsp,%r13
lea    0xe8b(%rip),%rbp
lea    0xe1d(%rip),%r14
jmp    120b <main+0x5b>
lea    0xf93(%rip),%rdi
call   1030 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpl   $0x0,0x4(%rsp)
je     133e <main+0x18e>
test   %r12,%r12
je     1260 <main+0xb0>
mov    %rbp,%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10a0 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x6,%rax
ja     11e5 <main+0x35>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
lea    0xecc(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <scanf@plt>
mov    (%rsp),%esi
mov    %r12,%rdi
call   10b0 <addNode@plt>
jmp    1200 <main+0x50>
nopw   0x0(%rax,%rax,1)
lea    0xdb5(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10a0 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
je     134b <main+0x19b>
lea    0xdc6(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <scanf@plt>
mov    (%rsp),%edi
call   1080 <makeList@plt>
mov    %rax,%r12
jmp    1200 <main+0x50>
mov    %r12,%rdi
call   1060 <removeList@plt>
mov    %rax,%r12
jmp    1200 <main+0x50>
lea    0xe60(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <scanf@plt>
mov    (%rsp),%esi
mov    %r12,%rdi
call   1040 <removeNode@plt>
mov    %rax,%r12
jmp    1200 <main+0x50>
lea    0xe4d(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <scanf@plt>
mov    (%rsp),%esi
mov    %r12,%rdi
call   10d0 <findNode@plt>
test   %eax,%eax
je     1332 <main+0x182>
lea    0xe63(%rip),%rdi
jmp    11ec <main+0x3c>
mov    %r12,%rdi
call   10c0 <printList@plt>
jmp    1200 <main+0x50>
mov    %r12,%rdi
call   1090 <sortList@plt>
mov    %rax,%r12
jmp    1200 <main+0x50>
lea    0xe2b(%rip),%rdi
jmp    11ec <main+0x3c>
test   %r12,%r12
je     134b <main+0x19b>
mov    %r12,%rdi
call   1060 <removeList@plt>
lea    0xdfa(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.link = type { i32 }
@.str = [48 x i8] c"\0AMenu:\0A(1) Make New List\0A(0) Exit program\0A\0A--->\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [24 x i8] c"Enter head node value: \00"
@.str.3 = [29 x i8] c"Please submit a valid input\0A\00"
@.str.4 = [162 x i8] c"\0APlease choose an option:\0A(1) Add a Node\09\09\09\09\09\0A(2) Remove List\0A(3) Remove a Node\0A(4) Find a Node\0A(5) Print the List\09\09\09\09\09\0A(6) Sort List\0A(0) Exit the program\0A\0A---> \00"
@.str.5 = [23 x i8] c"Enter new Node value: \00"
@.str.6 = [23 x i8] c"Remove Node of value: \00"
@.str.7 = [21 x i8] c"Find Node of value: \00"
@.str.8 = [13 x i8] c"Node exists\0A\00"
@.str.9 = [16 x i8] c"Node not found\0A\00"
@.str.10 = [28 x i8] c"Please enter a valid input\0A\00"
@.str.11 = [24 x i8] c"\0A[Press ENTER to close]\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.link*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store %struct.link* null, %struct.link** %2
store i32 -1, i32* %3
br label %5
5: ; preds = %70, %0
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %71
8: ; preds = %5
%9 = load %struct.link*, %struct.link** %2
%10 = icmp eq %struct.link* %9, null
br i1 %10, label %11, label %29
11: ; preds = %8
%12 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %3
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%19 = load i32, i32* %4
%20 = call %struct.link* @makeList(i32 %19)
store %struct.link* %20, %struct.link** %2
br label %28
21: ; preds = %11
%22 = load i32, i32* %3
%23 = icmp ne i32 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %21
br label %27
25: ; preds = %21
%26 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %25, %24
br label %28
28: ; preds = %27, %16
br label %70
29: ; preds = %8
%30 = call i32 @printf(i8* getelementptr inbounds ([162 x i8], [162 x i8]* @.str.4, i64 0, i64 0))
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%32 = load i32, i32* %3
switch i32 %32, label %67 [
i32 1, label %33
i32 2, label %39
i32 3, label %42
i32 4, label %48
i32 5, label %60
i32 6, label %63
i32 0, label %66
]
33: ; preds = %29
%34 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%36 = load %struct.link*, %struct.link** %2
%37 = load i32, i32* %4
%38 = call i32 @addNode(%struct.link* %36, i32 %37)
br label %69
39: ; preds = %29
%40 = load %struct.link*, %struct.link** %2
%41 = call %struct.link* @removeList(%struct.link* %40)
store %struct.link* %41, %struct.link** %2
br label %69
42: ; preds = %29
%43 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%44 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%45 = load %struct.link*, %struct.link** %2
%46 = load i32, i32* %4
%47 = call %struct.link* @removeNode(%struct.link* %45, i32 %46)
store %struct.link* %47, %struct.link** %2
br label %69
48: ; preds = %29
%49 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
%50 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%51 = load %struct.link*, %struct.link** %2
%52 = load i32, i32* %4
%53 = call i32 @findNode(%struct.link* %51, i32 %52)
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %48
%56 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
br label %59
57: ; preds = %48
%58 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
br label %59
59: ; preds = %57, %55
br label %69
60: ; preds = %29
%61 = load %struct.link*, %struct.link** %2
%62 = call i32 @printList(%struct.link* %61)
br label %69
63: ; preds = %29
%64 = load %struct.link*, %struct.link** %2
%65 = call %struct.link* @sortList(%struct.link* %64)
store %struct.link* %65, %struct.link** %2
br label %69
66: ; preds = %29
br label %69
67: ; preds = %29
%68 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0))
br label %69
69: ; preds = %67, %66, %63, %60, %59, %42, %39, %33
br label %70
70: ; preds = %69, %28
br label %5
71: ; preds = %5
%72 = load %struct.link*, %struct.link** %2
%73 = icmp ne %struct.link* %72, null
br i1 %73, label %74, label %77
74: ; preds = %71
%75 = load %struct.link*, %struct.link** %2
%76 = call %struct.link* @removeList(%struct.link* %75)
store %struct.link* %76, %struct.link** %2
br label %77
77: ; preds = %74, %71
%78 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
%79 = call i32 (...) @getchar()
%80 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
%struct.link = type { i32 }
@.str = [48 x i8] c"\0AMenu:\0A(1) Make New List\0A(0) Exit program\0A\0A--->\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [24 x i8] c"Enter head node value: \00"
@.str.4 = [162 x i8] c"\0APlease choose an option:\0A(1) Add a Node\09\09\09\09\09\0A(2) Remove List\0A(3) Remove a Node\0A(4) Find a Node\0A(5) Print the List\09\09\09\09\09\0A(6) Sort List\0A(0) Exit the program\0A\0A---> \00"
@.str.5 = [23 x i8] c"Enter new Node value: \00"
@.str.6 = [23 x i8] c"Remove Node of value: \00"
@.str.7 = [21 x i8] c"Find Node of value: \00"
@.str.11 = [24 x i8] c"\0A[Press ENTER to close]\00"
@str = [15 x i8] c"Node not found\00"
@str.12 = [12 x i8] c"Node exists\00"
@str.13 = [27 x i8] c"Please enter a valid input\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 -1, i32* %1
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %0, %50
%6 = phi %struct.link* [ null, %0 ], [ %51, %50 ]
%7 = icmp eq %struct.link* %6, null
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 0
br i1 %12, label %59, label %13
13: ; preds = %8
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %2
%17 = call %struct.link* @makeList(i32 %16)
br label %50
18: ; preds = %5
%19 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([162 x i8], [162 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%21 = load i32, i32* %1
switch i32 %21, label %48 [
i32 1, label %22
i32 2, label %27
i32 3, label %29
i32 4, label %34
i32 5, label %44
i32 6, label %46
i32 0, label %56
]
22: ; preds = %18
%23 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%25 = load i32, i32* %2
%26 = call i32 @addNode(%struct.link* %6, i32 %25)
br label %50
27: ; preds = %18
%28 = call %struct.link* @removeList(%struct.link* %6)
br label %50
29: ; preds = %18
%30 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%32 = load i32, i32* %2
%33 = call %struct.link* @removeNode(%struct.link* %6, i32 %32)
br label %50
34: ; preds = %18
%35 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%37 = load i32, i32* %2
%38 = call i32 @findNode(%struct.link* %6, i32 %37)
%39 = icmp eq i32 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %34
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.12, i64 0, i64 0))
br label %50
42: ; preds = %34
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %50
44: ; preds = %18
%45 = call i32 @printList(%struct.link* %6)
br label %50
46: ; preds = %18
%47 = call %struct.link* @sortList(%struct.link* %6)
br label %50
48: ; preds = %18
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.13, i64 0, i64 0))
br label %50
50: ; preds = %22, %27, %29, %44, %46, %48, %42, %40, %13
%51 = phi %struct.link* [ %6, %22 ], [ %28, %27 ], [ %33, %29 ], [ %6, %42 ], [ %6, %40 ], [ %6, %44 ], [ %47, %46 ], [ %6, %48 ], [ %17, %13 ]
%52 = load i32, i32* %1
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %5
54: ; preds = %50
%55 = icmp eq %struct.link* %51, null
br i1 %55, label %59, label %56
56: ; preds = %18, %54
%57 = phi %struct.link* [ %51, %54 ], [ %6, %18 ]
%58 = call %struct.link* @removeList(%struct.link* %57)
br label %59
59: ; preds = %8, %56, %54
%60 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
%61 = call i32 (...) @getchar()
%62 = call i32 (...) @getchar()
ret i32 0
}