#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 */

/* Variables and functions */
int count();
int /*<<< orphan*/ deleteele(int);
int /*<<< orphan*/ display();
int /*<<< orphan*/ insertbeg(int);
int /*<<< orphan*/ insertend(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ reverse();
int /*<<< orphan*/ scanf(char *, int *);
int search(int);
void main() {
  int ch, ele, z;
  while (1) {
    printf("Enter choice: 1. Insertbeg 2. Insertend 3. Delete ele 4. Count 5. "
           "Search 6. Reverse 7. Display 8. Exit - ");
    scanf("%d", &ch);
    if (ch == 8)
      break;
    switch (ch) {
    case 1:
      printf("Enter element to be inserted\n");
      scanf("%d", &ele);
      insertbeg(ele);
      display();
      break;
    case 2:
      printf("Enter element to be inserted\n");
      scanf("%d", &ele);
      insertend(ele);
      display();
      break;
    case 3:
      printf("Enter element to be deleted\n");
      scanf("%d", &ele);
      deleteele(ele);
      display();
      break;
    case 4:
      z = count();
      printf("Count = %d", z);
      break;
    case 5:
      printf("Enter element to be searched\n");
      scanf("%d", &ele);
      z = search(ele);
      if (z == 1)
        printf("Element found\n");
      else
        printf("Element not found\n");
      break;
    case 6:
      reverse();
      display();
      break;
    case 7:
      display();
      break;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xf1c(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   10a0 <scanf@plt>
cmpl   $0x8,-0x4(%rbp)
jne    11c5 <main+0x35>
jmp    131c <main+0x18c>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x6,%eax
ja     1317 <main+0x187>
mov    -0x18(%rbp),%rax
lea    0xe1b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xec6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   10a0 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1090 <insertbeg@plt>
mov    $0x0,%al
call   1060 <display@plt>
jmp    1317 <main+0x187>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe94(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   10a0 <scanf@plt>
mov    -0x8(%rbp),%edi
call   10b0 <insertend@plt>
mov    $0x0,%al
call   1060 <display@plt>
jmp    1317 <main+0x187>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe62(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   10a0 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1050 <deleteele@plt>
mov    $0x0,%al
call   1060 <display@plt>
jmp    1317 <main+0x187>
mov    $0x0,%al
call   1030 <count@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1317 <main+0x187>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe10(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   10a0 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1080 <search@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    12ea <main+0x15a>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    12f8 <main+0x168>
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1317 <main+0x187>
mov    $0x0,%al
call   1040 <reverse@plt>
mov    $0x0,%al
call   1060 <display@plt>
jmp    1317 <main+0x187>
mov    $0x0,%al
call   1060 <display@plt>
jmp    1198 <main+0x8>
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
lea    0xe6e(%rip),%r14
lea    0xed9(%rip),%rbx
lea    0x4(%rsp),%r15
lea    0xe3b(%rip),%rbp
lea    0xf22(%rip),%r12
mov    %rsp,%r13
jmp    11e7 <main+0x47>
xor    %eax,%eax
call   1040 <reverse@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <display@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10b0 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x7,%eax
ja     11e7 <main+0x47>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    %r12,%rdi
call   1060 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <scanf@plt>
mov    (%rsp),%edi
call   10a0 <insertbeg@plt>
jmp    11e0 <main+0x40>
mov    %r12,%rdi
call   1060 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <scanf@plt>
mov    (%rsp),%edi
call   10c0 <insertend@plt>
jmp    11e0 <main+0x40>
lea    0xe7f(%rip),%rdi
call   1060 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <scanf@plt>
mov    (%rsp),%edi
call   1050 <deleteele@plt>
jmp    11e0 <main+0x40>
xor    %eax,%eax
call   1030 <count@plt>
lea    0xe0c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    11e7 <main+0x47>
lea    0xe02(%rip),%rdi
call   1060 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <scanf@plt>
mov    (%rsp),%edi
call   1090 <search@plt>
cmp    $0x1,%eax
jne    12c1 <main+0x121>
lea    0xe0d(%rip),%rdi
call   1060 <puts@plt>
jmp    11e7 <main+0x47>
lea    0xdea(%rip),%rdi
call   1060 <puts@plt>
jmp    11e7 <main+0x47>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [106 x i8] c"Enter choice: 1. Insertbeg 2. Insertend 3. Delete ele 4. Count 5. Search 6. Reverse 7. Display 8. Exit - \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"Enter element to be inserted\0A\00"
@.str.3 = [29 x i8] c"Enter element to be deleted\0A\00"
@.str.4 = [11 x i8] c"Count = %d\00"
@.str.5 = [30 x i8] c"Enter element to be searched\0A\00"
@.str.6 = [15 x i8] c"Element found\0A\00"
@.str.7 = [19 x i8] c"Element not found\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
br label %4
4: ; preds = %0, %51
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([106 x i8], [106 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 8
br i1 %8, label %9, label %10
9: ; preds = %4
br label %52
10: ; preds = %4
%11 = load i32, i32* %1
switch i32 %11, label %51 [
i32 1, label %12
i32 2, label %18
i32 3, label %24
i32 4, label %30
i32 5, label %34
i32 6, label %46
i32 7, label %49
]
12: ; preds = %10
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%15 = load i32, i32* %2
%16 = call i32 @insertbeg(i32 %15)
%17 = call i32 (...) @display()
br label %51
18: ; preds = %10
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%21 = load i32, i32* %2
%22 = call i32 @insertend(i32 %21)
%23 = call i32 (...) @display()
br label %51
24: ; preds = %10
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%27 = load i32, i32* %2
%28 = call i32 @deleteele(i32 %27)
%29 = call i32 (...) @display()
br label %51
30: ; preds = %10
%31 = call i32 (...) @count()
store i32 %31, i32* %3
%32 = load i32, i32* %3
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %32)
br label %51
34: ; preds = %10
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, 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 @search(i32 %37)
store i32 %38, i32* %3
%39 = load i32, i32* %3
%40 = icmp eq i32 %39, 1
br i1 %40, label %41, label %43
41: ; preds = %34
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %45
43: ; preds = %34
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
br label %45
45: ; preds = %43, %41
br label %51
46: ; preds = %10
%47 = call i32 (...) @reverse()
%48 = call i32 (...) @display()
br label %51
49: ; preds = %10
%50 = call i32 (...) @display()
br label %51
51: ; preds = %10, %49, %46, %45, %30, %24, %18, %12
br label %4
52: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [106 x i8] c"Enter choice: 1. Insertbeg 2. Insertend 3. Delete ele 4. Count 5. Search 6. Reverse 7. Display 8. Exit - \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [11 x i8] c"Count = %d\00"
@str = [29 x i8] c"Enter element to be searched\00"
@str.8 = [18 x i8] c"Element not found\00"
@str.9 = [14 x i8] c"Element found\00"
@str.10 = [28 x i8] c"Enter element to be deleted\00"
@str.12 = [29 x i8] c"Enter element to be inserted\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %9, %0
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([106 x i8], [106 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
switch i32 %8, label %9 [
i32 8, label %46
i32 1, label %10
i32 2, label %16
i32 3, label %22
i32 4, label %28
i32 5, label %31
i32 6, label %41
i32 7, label %44
]
9: ; preds = %5, %37, %39, %44, %41, %28, %22, %16, %10
br label %5
10: ; preds = %5
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.12, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
%14 = call i32 @insertbeg(i32 %13)
%15 = call i32 (...) @display()
br label %9
16: ; preds = %5
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.12, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%19 = load i32, i32* %2
%20 = call i32 @insertend(i32 %19)
%21 = call i32 (...) @display()
br label %9
22: ; preds = %5
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.10, 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 @deleteele(i32 %25)
%27 = call i32 (...) @display()
br label %9
28: ; preds = %5
%29 = call i32 (...) @count()
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %29)
br label %9
31: ; preds = %5
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%34 = load i32, i32* %2
%35 = call i32 @search(i32 %34)
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %39
37: ; preds = %31
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.9, i64 0, i64 0))
br label %9
39: ; preds = %31
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.8, i64 0, i64 0))
br label %9
41: ; preds = %5
%42 = call i32 (...) @reverse()
%43 = call i32 (...) @display()
br label %9
44: ; preds = %5
%45 = call i32 (...) @display()
br label %9
46: ; preds = %5
ret void
}