#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*/ delete_at_beginning();
int /*<<< orphan*/ delete_at_end();
int /*<<< orphan*/ display();
int /*<<< orphan*/ insert_at_beginning();
int /*<<< orphan*/ insert_at_end();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ search();
void main() {
  int f = 1, choice;
  while (f) {
    printf("\nSingly Circular Linked List :\n");
    printf("---------------------------------\n");
    printf("1. Insert a node at beginning\n");
    printf("2. Insert a node at end\n");
    printf("3. Delete a node at beginning\n");
    printf("4. Delete a node at end\n");
    printf("5. Display list\n");
    printf("6. Search\n");
    printf("7. Exit\n");
    printf("---------------------------------\n");
    printf("Enter your choice: ");
    scanf("%d", &choice);
    switch (choice) {
    case 1: {
      insert_at_beginning();
      break;
    }
    case 2: {
      insert_at_end();
      break;
    }
    case 3: {
      delete_at_beginning();
      break;
    }
    case 4: {
      delete_at_end();
      break;
    }
    case 5: {
      display();
      break;
    }
    case 6: {
      search();
      break;
    }
    case 7: {
      f = 0;
      break;
    }
    default: {
      printf("Invalid Choice\n");
    }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x1,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     12bc <main+0x13c>
lea    0xe7c(%rip),%rdi
call   1050 <printf@plt>
lea    0xe90(%rip),%rdi
mov    %rdi,-0x18(%rbp)
call   1050 <printf@plt>
lea    0xea3(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb6(%rip),%rdi
call   1050 <printf@plt>
lea    0xec3(%rip),%rdi
call   1050 <printf@plt>
lea    0xed6(%rip),%rdi
call   1050 <printf@plt>
lea    0xee3(%rip),%rdi
call   1050 <printf@plt>
lea    0xee8(%rip),%rdi
call   1050 <printf@plt>
lea    0xee7(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <printf@plt>
lea    0xedb(%rip),%rdi
call   1050 <printf@plt>
lea    0xee3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x6,%eax
ja     12ab <main+0x12b>
mov    -0x10(%rbp),%rax
lea    0xdb2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1080 <insert_at_beginning@plt>
jmp    12b7 <main+0x137>
mov    $0x0,%al
call   1070 <insert_at_end@plt>
jmp    12b7 <main+0x137>
mov    $0x0,%al
call   1030 <delete_at_beginning@plt>
jmp    12b7 <main+0x137>
mov    $0x0,%al
call   10a0 <delete_at_end@plt>
jmp    12b7 <main+0x137>
mov    $0x0,%al
call   1040 <display@plt>
jmp    12b7 <main+0x137>
mov    $0x0,%al
call   1060 <search@plt>
jmp    12b7 <main+0x137>
movl   $0x0,-0x4(%rbp)
jmp    12b7 <main+0x137>
lea    0xe59(%rip),%rdi
call   1050 <printf@plt>
jmp    118f <main+0xf>
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    0xf3e(%rip),%rbx
lea    0xf2f(%rip),%r12
lea    0xe6c(%rip),%r13
lea    0xe79(%rip),%rbp
lea    0x4(%rsp),%r14
lea    0xe3d(%rip),%r15
jmp    11d0 <main+0x40>
xor    %eax,%eax
call   1070 <search@plt>
nopl   0x0(%rax)
lea    0xe5c(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xe67(%rip),%rdi
call   1040 <puts@plt>
lea    0xe79(%rip),%rdi
call   1040 <puts@plt>
lea    0xe85(%rip),%rdi
call   1040 <puts@plt>
lea    0xe97(%rip),%rdi
call   1040 <puts@plt>
lea    0xea3(%rip),%rdi
call   1040 <puts@plt>
lea    0xea7(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1060 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   10a0 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x6,%eax
ja     1270 <main+0xe0>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
xor    %eax,%eax
call   1090 <insert_at_beginning@plt>
jmp    11d0 <main+0x40>
lea    0xe8b(%rip),%rdi
call   1040 <puts@plt>
jmp    11d0 <main+0x40>
xor    %eax,%eax
call   1080 <insert_at_end@plt>
jmp    11d0 <main+0x40>
xor    %eax,%eax
call   1030 <delete_at_beginning@plt>
jmp    11d0 <main+0x40>
xor    %eax,%eax
call   10b0 <delete_at_end@plt>
jmp    11d0 <main+0x40>
xor    %eax,%eax
call   1050 <display@plt>
jmp    11d0 <main+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"\0ASingly Circular Linked List :\0A\00"
@.str.1 = [35 x i8] c"---------------------------------\0A\00"
@.str.2 = [31 x i8] c"1. Insert a node at beginning\0A\00"
@.str.3 = [25 x i8] c"2. Insert a node at end\0A\00"
@.str.4 = [31 x i8] c"3. Delete a node at beginning\0A\00"
@.str.5 = [25 x i8] c"4. Delete a node at end\0A\00"
@.str.6 = [17 x i8] c"5. Display list\0A\00"
@.str.7 = [11 x i8] c"6. Search\0A\00"
@.str.8 = [9 x i8] c"7. Exit\0A\00"
@.str.9 = [20 x i8] c"Enter your choice: \00"
@.str.10 = [3 x i8] c"%d\00"
@.str.11 = [16 x i8] c"Invalid Choice\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
store i32 1, i32* %1
br label %3
3: ; preds = %35, %0
%4 = load i32, i32* %1
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %36
6: ; preds = %3
%7 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32* %2)
%19 = load i32, i32* %2
switch i32 %19, label %33 [
i32 1, label %20
i32 2, label %22
i32 3, label %24
i32 4, label %26
i32 5, label %28
i32 6, label %30
i32 7, label %32
]
20: ; preds = %6
%21 = call i32 (...) @insert_at_beginning()
br label %35
22: ; preds = %6
%23 = call i32 (...) @insert_at_end()
br label %35
24: ; preds = %6
%25 = call i32 (...) @delete_at_beginning()
br label %35
26: ; preds = %6
%27 = call i32 (...) @delete_at_end()
br label %35
28: ; preds = %6
%29 = call i32 (...) @display()
br label %35
30: ; preds = %6
%31 = call i32 (...) @search()
br label %35
32: ; preds = %6
store i32 0, i32* %1
br label %35
33: ; preds = %6
%34 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
br label %35
35: ; preds = %33, %32, %30, %28, %26, %24, %22, %20
br label %3
36: ; preds = %3
ret void
}

LLVM IR (-O2):
@.str.9 = [20 x i8] c"Enter your choice: \00"
@.str.10 = [3 x i8] c"%d\00"
@str = [31 x i8] c"\0ASingly Circular Linked List :\00"
@str.13 = [30 x i8] c"1. Insert a node at beginning\00"
@str.14 = [24 x i8] c"2. Insert a node at end\00"
@str.15 = [30 x i8] c"3. Delete a node at beginning\00"
@str.16 = [24 x i8] c"4. Delete a node at end\00"
@str.17 = [16 x i8] c"5. Display list\00"
@str.18 = [10 x i8] c"6. Search\00"
@str.19 = [8 x i8] c"7. Exit\00"
@str.20 = [34 x i8] c"---------------------------------\00"
@str.21 = [15 x i8] c"Invalid Choice\00"
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %31, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.20, i64 0, i64 0))
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.13, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.14, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.15, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.16, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.17, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.18, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.19, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.20, i64 0, i64 0))
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32* %1)
%16 = load i32, i32* %1
switch i32 %16, label %29 [
i32 1, label %17
i32 2, label %19
i32 3, label %21
i32 4, label %23
i32 5, label %25
i32 6, label %27
i32 7, label %32
]
17: ; preds = %3
%18 = call i32 (...) @insert_at_beginning()
br label %31
19: ; preds = %3
%20 = call i32 (...) @insert_at_end()
br label %31
21: ; preds = %3
%22 = call i32 (...) @delete_at_beginning()
br label %31
23: ; preds = %3
%24 = call i32 (...) @delete_at_end()
br label %31
25: ; preds = %3
%26 = call i32 (...) @display()
br label %31
27: ; preds = %3
%28 = call i32 (...) @search()
br label %31
29: ; preds = %3
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.21, i64 0, i64 0))
br label %31
31: ; preds = %29, %27, %25, %23, %21, %19, %17
br label %3
32: ; preds = %3
ret void
}