#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 /*<<< orphan*/ any_pos_del(int);
int /*<<< orphan*/ any_pos_ins(int);
int /*<<< orphan*/ del_beg();
int /*<<< orphan*/ del_end();
int /*<<< orphan*/ display();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ ins_beg();
int /*<<< orphan*/ ins_end();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n;
  int choice;
  do {
    printf("1)Insert at begining\n2)Insert at end\n3)Insert at any "
           "position\n4)Delete at beginging\n5)Delete at end\n6)Delete at any "
           "position\n7)Display\n9)Exit\n");
    scanf("%d", &choice);
    switch (choice) {
    case 1:
      ins_beg();
      break;
    case 2:
      ins_end();
      break;
    case 3:
      printf("Enter the position\n");
      scanf("%d", &n);
      any_pos_ins(n);
      printf("\n");
      break;
    case 4:
      del_beg();
      break;
    case 5:
      del_end();
      break;
    case 6:
      printf("Enter the position\n");
      scanf("%d", &n);
      any_pos_del(n);
      printf("\n");
      break;
    case 7:
      display();
      break;
    case 8:
      exit(0);
    }
  } while (choice != 8);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe6a(%rip),%rdi
call   1070 <printf@plt>
lea    0xeed(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   10a0 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x7,%eax
ja     12a1 <main+0x101>
mov    -0x18(%rbp),%rax
lea    0xe15(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1060 <ins_beg@plt>
jmp    12a1 <main+0x101>
mov    $0x0,%al
call   1030 <ins_end@plt>
jmp    12a1 <main+0x101>
lea    0xe9f(%rip),%rdi
call   1070 <printf@plt>
lea    0xe90(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   10a0 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1090 <any_pos_ins@plt>
lea    0xe8d(%rip),%rdi
call   1070 <printf@plt>
jmp    12a1 <main+0x101>
mov    $0x0,%al
call   10c0 <del_beg@plt>
jmp    12a1 <main+0x101>
mov    $0x0,%al
call   1080 <del_end@plt>
jmp    12a1 <main+0x101>
lea    0xe52(%rip),%rdi
call   1070 <printf@plt>
lea    0xe43(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   10a0 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1040 <any_pos_del@plt>
lea    0xe40(%rip),%rdi
call   1070 <printf@plt>
jmp    12a1 <main+0x101>
mov    $0x0,%al
call   1050 <display@plt>
jmp    12a1 <main+0x101>
xor    %edi,%edi
call   10b0 <exit@plt>
jmp    12a6 <main+0x106>
cmpl   $0x8,-0xc(%rbp)
jne    11af <main+0xf>
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
lea    0xe61(%rip),%r14
lea    0xe57(%rip),%rbx
mov    %rsp,%r15
lea    0xe2d(%rip),%rbp
lea    0xed7(%rip),%r12
lea    0x4(%rsp),%r13
jmp    120f <main+0x5f>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <scanf@plt>
mov    0x4(%rsp),%edi
call   10a0 <any_pos_ins@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%rsp),%eax
cmp    $0x8,%eax
je     1282 <main+0xd2>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10b0 <scanf@plt>
mov    (%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    $0x7,%ecx
ja     120a <main+0x5a>
movslq 0x0(%rbp,%rcx,4),%rax
add    %rbp,%rax
jmp    *%rax
xor    %eax,%eax
call   1080 <ins_beg@plt>
jmp    1207 <main+0x57>
xor    %eax,%eax
call   1050 <ins_end@plt>
jmp    1207 <main+0x57>
xor    %eax,%eax
call   10d0 <del_beg@plt>
jmp    1207 <main+0x57>
xor    %eax,%eax
call   1090 <del_end@plt>
jmp    1207 <main+0x57>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <scanf@plt>
mov    0x4(%rsp),%edi
call   1060 <any_pos_del@plt>
jmp    11fd <main+0x4d>
xor    %eax,%eax
call   1070 <display@plt>
jmp    1207 <main+0x57>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [143 x i8] c"1)Insert at begining\0A2)Insert at end\0A3)Insert at any position\0A4)Delete at beginging\0A5)Delete at end\0A6)Delete at any position\0A7)Display\0A9)Exit\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"Enter the position\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %33, %0
%5 = call i32 @printf(i8* getelementptr inbounds ([143 x i8], [143 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* %3)
%7 = load i32, i32* %3
switch i32 %7, label %32 [
i32 1, label %8
i32 2, label %10
i32 3, label %12
i32 4, label %18
i32 5, label %20
i32 6, label %22
i32 7, label %28
i32 8, label %30
]
8: ; preds = %4
%9 = call i32 (...) @ins_beg()
br label %32
10: ; preds = %4
%11 = call i32 (...) @ins_end()
br label %32
12: ; preds = %4
%13 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 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 @any_pos_ins(i32 %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %32
18: ; preds = %4
%19 = call i32 (...) @del_beg()
br label %32
20: ; preds = %4
%21 = call i32 (...) @del_end()
br label %32
22: ; preds = %4
%23 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, 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 @any_pos_del(i32 %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %32
28: ; preds = %4
%29 = call i32 (...) @display()
br label %32
30: ; preds = %4
%31 = call i32 @exit(i32 0)
unreachable
32: ; preds = %4, %28, %22, %20, %18, %12, %10, %8
br label %33
33: ; preds = %32
%34 = load i32, i32* %3
%35 = icmp ne i32 %34, 8
br i1 %35, label %4, label %36
36: ; preds = %33
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [142 x i8] c"1)Insert at begining\0A2)Insert at end\0A3)Insert at any position\0A4)Delete at beginging\0A5)Delete at end\0A6)Delete at any position\0A7)Display\0A9)Exit\00"
@str.5 = [19 x i8] c"Enter the position\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %35, %0
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([142 x i8], [142 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* %2)
%8 = load i32, i32* %2
switch i32 %8, label %35 [
i32 1, label %9
i32 2, label %11
i32 3, label %13
i32 4, label %19
i32 5, label %21
i32 6, label %23
i32 7, label %29
i32 8, label %31
]
9: ; preds = %5
%10 = call i32 (...) @ins_beg()
br label %33
11: ; preds = %5
%12 = call i32 (...) @ins_end()
br label %33
13: ; preds = %5
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.5, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%16 = load i32, i32* %1
%17 = call i32 @any_pos_ins(i32 %16)
%18 = call i32 @putchar(i32 10)
br label %33
19: ; preds = %5
%20 = call i32 (...) @del_beg()
br label %33
21: ; preds = %5
%22 = call i32 (...) @del_end()
br label %33
23: ; preds = %5
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.5, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%26 = load i32, i32* %1
%27 = call i32 @any_pos_del(i32 %26)
%28 = call i32 @putchar(i32 10)
br label %33
29: ; preds = %5
%30 = call i32 (...) @display()
br label %33
31: ; preds = %5
%32 = call i32 @exit(i32 0)
unreachable
33: ; preds = %29, %23, %21, %19, %13, %11, %9
%34 = load i32, i32* %2
br label %35
35: ; preds = %33, %5
%36 = phi i32 [ %34, %33 ], [ %8, %5 ]
%37 = icmp eq i32 %36, 8
br i1 %37, label %38, label %5
38: ; preds = %35
ret i32 0
}