#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 (int);
int /*<<< orphan*/ display();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ insertAtFront(int);
int /*<<< orphan*/ insertToLeftOf(int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main(void) {
  printf("Doubly Linked List Test\n");
  int val, left, choice;
  while (1) {
    printf("\nDoubly Linked List Operations : \n");
    printf("1. insert at front\n2. insert to left of \n3. delete\n4. "
           "display\n5. Quit\n");
    scanf("%d", &choice);
    switch (choice) {
    case 1:
      printf("Enter element to insert\n");
      scanf("%d", &val);
      insertAtFront(val);
      break;
    case 2:
      printf("Enter element to delete and left of element \n");
      scanf("%d %d", &val, &left);
      insertToLeftOf(val, left);
      break;
    case 3:
      printf("Enter element to delete\n");
      scanf("%d", &val);
      delete (val);
      break;
    case 4:
      display();
      break;
    case 5:
      exit(0);
    default:
      printf("Wrong entry : \n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8e(%rip),%rdi
call   1050 <printf@plt>
lea    0xe9b(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb2(%rip),%rdi
call   1050 <printf@plt>
lea    0xf37(%rip),%rdi
xor    %eax,%eax
lea    -0x10(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x4,%eax
ja     1279 <main+0x109>
mov    -0x18(%rbp),%rax
lea    0xe2b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeb2(%rip),%rdi
call   1050 <printf@plt>
lea    0xef0(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1030 <insertAtFront@plt>
jmp    1285 <main+0x115>
lea    0xea0(%rip),%rdi
call   1050 <printf@plt>
lea    0xec2(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <insertToLeftOf@plt>
jmp    1285 <main+0x115>
lea    0xea2(%rip),%rdi
call   1050 <printf@plt>
lea    0xe93(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1080 <delete@plt>
jmp    1285 <main+0x115>
mov    $0x0,%al
call   1040 <display@plt>
jmp    1285 <main+0x115>
xor    %edi,%edi
call   1090 <exit@plt>
lea    0xe7d(%rip),%rdi
call   1050 <printf@plt>
jmp    118b <main+0x1b>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe95(%rip),%rdi
call   1040 <puts@plt>
lea    0xea1(%rip),%r14
lea    0xebc(%rip),%r15
lea    0xe78(%rip),%rbx
lea    0x10(%rsp),%r12
lea    0xe55(%rip),%rbp
lea    0xc(%rsp),%r13
jmp    11c0 <main+0x50>
xor    %eax,%eax
call   1050 <display@plt>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x10(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     123b <main+0xcb>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
lea    0xee5(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0xc(%rsp),%edi
call   1030 <insertAtFront@plt>
jmp    11c0 <main+0x50>
lea    0xe7c(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0xc(%rsp),%edi
call   1080 <delete@plt>
jmp    11c0 <main+0x50>
lea    0xeb5(%rip),%rdi
call   1040 <puts@plt>
jmp    11c0 <main+0x50>
lea    0xe5f(%rip),%rdi
call   1040 <puts@plt>
lea    0xdb5(%rip),%rdi
mov    %r13,%rsi
lea    0x14(%rsp),%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0xc(%rsp),%edi
mov    0x14(%rsp),%esi
call   1060 <insertToLeftOf@plt>
jmp    11c0 <main+0x50>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"Doubly Linked List Test\0A\00"
@.str.1 = [35 x i8] c"\0ADoubly Linked List Operations : \0A\00"
@.str.2 = [71 x i8] c"1. insert at front\0A2. insert to left of \0A3. delete\0A4. display\0A5. Quit\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [25 x i8] c"Enter element to insert\0A\00"
@.str.5 = [46 x i8] c"Enter element to delete and left of element \0A\00"
@.str.6 = [6 x i8] c"%d %d\00"
@.str.7 = [25 x i8] c"Enter element to delete\0A\00"
@.str.8 = [16 x i8] c"Wrong entry : \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %0, %33
%7 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%10 = load i32, i32* %4
switch i32 %10, label %31 [
i32 1, label %11
i32 2, label %16
i32 3, label %22
i32 4, label %27
i32 5, label %29
]
11: ; preds = %6
%12 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
%15 = call i32 @insertAtFront(i32 %14)
br label %33
16: ; preds = %6
%17 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32* %2, i32* %3)
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = call i32 @insertToLeftOf(i32 %19, i32 %20)
br label %33
22: ; preds = %6
%23 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%24 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%25 = load i32, i32* %2
%26 = call i32 @delete(i32 %25)
br label %33
27: ; preds = %6
%28 = call i32 (...) @display()
br label %33
29: ; preds = %6
%30 = call i32 @exit(i32 0)
unreachable
31: ; preds = %6
%32 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
br label %33
33: ; preds = %31, %27, %22, %16, %11
br label %6
}

LLVM IR (-O2):
@.str.3 = [3 x i8] c"%d\00"
@.str.6 = [6 x i8] c"%d %d\00"
@str = [24 x i8] c"Doubly Linked List Test\00"
@str.9 = [34 x i8] c"\0ADoubly Linked List Operations : \00"
@str.10 = [70 x i8] c"1. insert at front\0A2. insert to left of \0A3. delete\0A4. display\0A5. Quit\00"
@str.11 = [24 x i8] c"Enter element to delete\00"
@str.12 = [45 x i8] c"Enter element to delete and left of element \00"
@str.13 = [24 x i8] c"Enter element to insert\00"
@str.14 = [15 x i8] c"Wrong entry : \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
br label %8
8: ; preds = %35, %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.9, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str.10, i64 0, i64 0))
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%12 = load i32, i32* %3
switch i32 %12, label %33 [
i32 1, label %13
i32 2, label %18
i32 3, label %24
i32 4, label %29
i32 5, label %31
]
13: ; preds = %8
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.13, i64 0, i64 0))
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%16 = load i32, i32* %1
%17 = call i32 @insertAtFront(i32 %16)
br label %35
18: ; preds = %8
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.12, i64 0, i64 0))
%20 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32* %1, i32* %2)
%21 = load i32, i32* %1
%22 = load i32, i32* %2
%23 = call i32 @insertToLeftOf(i32 %21, i32 %22)
br label %35
24: ; preds = %8
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.11, i64 0, i64 0))
%26 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%27 = load i32, i32* %1
%28 = call i32 @delete(i32 %27)
br label %35
29: ; preds = %8
%30 = call i32 (...) @display()
br label %35
31: ; preds = %8
%32 = call i32 @exit(i32 0)
unreachable
33: ; preds = %8
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.14, i64 0, i64 0))
br label %35
35: ; preds = %33, %29, %24, %18, %13
br label %8
}