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

/* Variables and functions */
int /*<<< orphan*/ displayList(struct item *);
int /*<<< orphan*/ insertAfter(struct item *, int, int);
struct item *insertAtEnd(struct item *, int);
struct item *insertAtFront(struct item *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char **argv) {
  int choice, number, previous;
  struct item *start = NULL;
  do {
    printf("<-- Linked list insertion menu -->\n");
    printf("\t1. At the beginning \n");
    printf("\t2. After an element \n");
    printf("\t3. At the end \n");
    printf("\t4. Display the linked list.\n");
    printf("\t5. Exit\n");
    printf("<-- Enter choice -->\n");
    scanf("%d", &choice);
    switch (choice) {
    case 1:
      printf("<-- Enter the number to be inserted -->\n");
      scanf("%d", &number);
      start = insertAtFront(start, number);
      break;
    case 2:
      printf("<-- Enter the number to be inserted -->\n");
      scanf("%d", &number);
      printf("<-- Enter the number after which %d is to be inserted -->\n",
             number);
      scanf("%d", &previous);
      insertAfter(start, previous, number);
      break;
    case 3:
      printf("<-- Enter the number to be inserted -->\n");
      scanf("%d", &number);
      start = insertAtEnd(start, number);
      break;
    case 4:
      displayList(start);
      break;
    case 5:
      break;
    default:
      printf("<-- Invalid choice! -->\n");
    }
  } while (choice != 5);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xe8f(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x31(%rbp)
call   1040 <printf@plt>
mov    -0x31(%rbp),%al
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x31(%rbp),%al
lea    0xea7(%rip),%rdi
call   1040 <printf@plt>
mov    -0x31(%rbp),%al
lea    0xeaf(%rip),%rdi
call   1040 <printf@plt>
mov    -0x31(%rbp),%al
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
mov    -0x31(%rbp),%al
lea    0xec0(%rip),%rdi
call   1040 <printf@plt>
mov    -0x31(%rbp),%al
lea    0xebb(%rip),%rdi
call   1040 <printf@plt>
lea    0xec5(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x4,%eax
ja     12ee <main+0x18e>
mov    -0x30(%rbp),%rax
lea    0xde7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe7e(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1030 <insertAtFront@plt>
mov    %rax,-0x28(%rbp)
jmp    12fc <main+0x19c>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe4b(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x18(%rbp),%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe2a(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1080 <insertAfter@plt>
jmp    12fc <main+0x19c>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdf8(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1050 <insertAtEnd@plt>
mov    %rax,-0x28(%rbp)
jmp    12fc <main+0x19c>
mov    -0x28(%rbp),%rdi
call   1060 <displayList@plt>
jmp    12fc <main+0x19c>
jmp    12fc <main+0x19c>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1301 <main+0x1a1>
cmpl   $0x5,-0x14(%rbp)
jne    117e <main+0x1e>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xf49(%rip),%rbp
lea    0xf4b(%rip),%r14
lea    0xe81(%rip),%r15
lea    0x10(%rsp),%r12
lea    0xe61(%rip),%rbx
xor    %r13d,%r13d
jmp    11cb <main+0x5b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xf5d(%rip),%rdi
call   1040 <puts@plt>
nopl   0x0(%rax)
cmpl   $0x5,0x10(%rsp)
je     12fd <main+0x18d>
lea    0xe80(%rip),%rdi
call   1040 <puts@plt>
lea    0xe97(%rip),%rdi
call   1040 <puts@plt>
lea    0xea1(%rip),%rdi
call   1040 <puts@plt>
lea    0xeab(%rip),%rdi
call   1040 <puts@plt>
lea    0xeaf(%rip),%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <scanf@plt>
mov    0x10(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     11b0 <main+0x40>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
lea    0xeae(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf@plt>
mov    0xc(%rsp),%esi
mov    %r13,%rdi
call   1030 <insertAtFront@plt>
mov    %rax,%r13
jmp    11c0 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xe75(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0xd83(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
lea    0x14(%rsp),%rsi
call   1080 <scanf@plt>
mov    0x14(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %r13,%rdi
call   1090 <insertAfter@plt>
jmp    11c0 <main+0x50>
nopl   (%rax)
lea    0xe25(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf@plt>
mov    0xc(%rsp),%esi
mov    %r13,%rdi
call   1060 <insertAtEnd@plt>
mov    %rax,%r13
jmp    11c0 <main+0x50>
nopl   (%rax)
mov    %r13,%rdi
call   1070 <displayList@plt>
jmp    11c0 <main+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.item = type { i32 }
@.str = [36 x i8] c"<-- Linked list insertion menu -->\0A\00"
@.str.1 = [23 x i8] c"\091. At the beginning \0A\00"
@.str.2 = [23 x i8] c"\092. After an element \0A\00"
@.str.3 = [17 x i8] c"\093. At the end \0A\00"
@.str.4 = [30 x i8] c"\094. Display the linked list.\0A\00"
@.str.5 = [10 x i8] c"\095. Exit\0A\00"
@.str.6 = [22 x i8] c"<-- Enter choice -->\0A\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [41 x i8] c"<-- Enter the number to be inserted -->\0A\00"
@.str.9 = [59 x i8] c"<-- Enter the number after which %d is to be inserted -->\0A\00"
@.str.10 = [25 x i8] c"<-- Invalid choice! -->\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.item*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.item* null, %struct.item** %9
br label %10
10: ; preds = %49, %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %6)
%19 = load i32, i32* %6
switch i32 %19, label %46 [
i32 1, label %20
i32 2, label %26
i32 3, label %36
i32 4, label %42
i32 5, label %45
]
20: ; preds = %10
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %7)
%23 = load %struct.item*, %struct.item** %9
%24 = load i32, i32* %7
%25 = call %struct.item* @insertAtFront(%struct.item* %23, i32 %24)
store %struct.item* %25, %struct.item** %9
br label %48
26: ; preds = %10
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0))
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %7)
%29 = load i32, i32* %7
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.9, i64 0, i64 0), i32 %29)
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %8)
%32 = load %struct.item*, %struct.item** %9
%33 = load i32, i32* %8
%34 = load i32, i32* %7
%35 = call i32 @insertAfter(%struct.item* %32, i32 %33, i32 %34)
br label %48
36: ; preds = %10
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0))
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %7)
%39 = load %struct.item*, %struct.item** %9
%40 = load i32, i32* %7
%41 = call %struct.item* @insertAtEnd(%struct.item* %39, i32 %40)
store %struct.item* %41, %struct.item** %9
br label %48
42: ; preds = %10
%43 = load %struct.item*, %struct.item** %9
%44 = call i32 @displayList(%struct.item* %43)
br label %48
45: ; preds = %10
br label %48
46: ; preds = %10
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0))
br label %48
48: ; preds = %46, %45, %42, %36, %26, %20
br label %49
49: ; preds = %48
%50 = load i32, i32* %6
%51 = icmp ne i32 %50, 5
br i1 %51, label %10, label %52
52: ; preds = %49
ret i32 0
}

LLVM IR (-O2):
%struct.item = type { i32 }
@.str.7 = [3 x i8] c"%d\00"
@.str.9 = [59 x i8] c"<-- Enter the number after which %d is to be inserted -->\0A\00"
@str = [35 x i8] c"<-- Linked list insertion menu -->\00"
@str.11 = [22 x i8] c"\091. At the beginning \00"
@str.12 = [22 x i8] c"\092. After an element \00"
@str.13 = [16 x i8] c"\093. At the end \00"
@str.14 = [29 x i8] c"\094. Display the linked list.\00"
@str.15 = [9 x i8] c"\095. Exit\00"
@str.16 = [21 x i8] c"<-- Enter choice -->\00"
@str.19 = [40 x i8] c"<-- Enter the number to be inserted -->\00"
@str.20 = [24 x i8] c"<-- Invalid choice! -->\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
br label %9
9: ; preds = %43, %2
%10 = phi %struct.item* [ null, %2 ], [ %44, %43 ]
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.11, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.12, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.13, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.14, i64 0, i64 0))
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.15, i64 0, i64 0))
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.16, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %3)
%19 = load i32, i32* %3
switch i32 %19, label %41 [
i32 1, label %20
i32 2, label %25
i32 3, label %34
i32 4, label %39
i32 5, label %47
]
20: ; preds = %9
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.19, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %4)
%23 = load i32, i32* %4
%24 = call %struct.item* @insertAtFront(%struct.item* %10, i32 %23)
br label %43
25: ; preds = %9
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.19, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %4)
%28 = load i32, i32* %4
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.9, i64 0, i64 0), i32 %28)
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %5)
%31 = load i32, i32* %5
%32 = load i32, i32* %4
%33 = call i32 @insertAfter(%struct.item* %10, i32 %31, i32 %32)
br label %43
34: ; preds = %9
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.19, i64 0, i64 0))
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %4)
%37 = load i32, i32* %4
%38 = call %struct.item* @insertAtEnd(%struct.item* %10, i32 %37)
br label %43
39: ; preds = %9
%40 = call i32 @displayList(%struct.item* %10)
br label %43
41: ; preds = %9
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.20, i64 0, i64 0))
br label %43
43: ; preds = %20, %25, %34, %39, %41
%44 = phi %struct.item* [ %24, %20 ], [ %10, %25 ], [ %38, %34 ], [ %10, %39 ], [ %10, %41 ]
%45 = load i32, i32* %3
%46 = icmp eq i32 %45, 5
br i1 %46, label %47, label %9
47: ; preds = %9, %43
ret i32 0
}