#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*/ pop_at_end();
int /*<<< orphan*/ pop_at_start();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ push_at_end(int);
int /*<<< orphan*/ push_at_start(int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int x, c;
  while (1) {
    printf("1.enter at front\n2.enter at back\n3.remove from front\n4.remove "
           "from back\n5.exit\n\n");
    scanf("%d", &c);
    switch (c) {
    case 1:
      printf("enter element: ");
      scanf("%d", &x);
      push_at_start(x);
      break;
    case 2:
      printf("enter element: ");
      scanf("%d", &x);
      push_at_end(x);
      break;
    case 3:
      pop_at_start();
      break;
    case 4:
      pop_at_end();
      break;
    case 5:
      goto end;
    }
  }
end:;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
lea    0xee3(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x4,%eax
ja     1223 <main+0xc3>
mov    -0x18(%rbp),%rax
lea    0xe55(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1040 <push_at_start@plt>
jmp    1223 <main+0xc3>
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
lea    0xe75(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1060 <push_at_end@plt>
jmp    1223 <main+0xc3>
mov    $0x0,%al
call   1080 <pop_at_start@plt>
jmp    1223 <main+0xc3>
mov    $0x0,%al
call   1070 <pop_at_end@plt>
jmp    1223 <main+0xc3>
jmp    1228 <main+0xc8>
jmp    116f <main+0xf>
mov    -0x4(%rbp),%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    0xea5(%rip),%r14
lea    0xe8b(%rip),%rbx
lea    0x4(%rsp),%r15
lea    0xe6b(%rip),%rbp
lea    0xe7b(%rip),%r12
mov    %rsp,%r13
jmp    11b0 <main+0x40>
xor    %eax,%eax
call   1080 <pop_at_end@plt>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     11b0 <main+0x40>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    %r12,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
mov    (%rsp),%edi
call   1050 <push_at_start@plt>
jmp    11b0 <main+0x40>
mov    %r12,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
mov    (%rsp),%edi
call   1070 <push_at_end@plt>
jmp    11b0 <main+0x40>
xor    %eax,%eax
call   1090 <pop_at_start@plt>
jmp    11b0 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [81 x i8] c"1.enter at front\0A2.enter at back\0A3.remove from front\0A4.remove from back\0A5.exit\0A\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"enter element: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %0, %23
%5 = call i32 @printf(i8* getelementptr inbounds ([81 x i8], [81 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 %23 [
i32 1, label %8
i32 2, label %13
i32 3, label %18
i32 4, label %20
i32 5, label %22
]
8: ; preds = %4
%9 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
%12 = call i32 @push_at_start(i32 %11)
br label %23
13: ; preds = %4
%14 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %2
%17 = call i32 @push_at_end(i32 %16)
br label %23
18: ; preds = %4
%19 = call i32 (...) @pop_at_start()
br label %23
20: ; preds = %4
%21 = call i32 (...) @pop_at_end()
br label %23
22: ; preds = %4
br label %24
23: ; preds = %4, %20, %18, %13, %8
br label %4
24: ; preds = %22
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"enter element: \00"
@str = [80 x i8] c"1.enter at front\0A2.enter at back\0A3.remove from front\0A4.remove from back\0A5.exit\0A\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 = %9, %0
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 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 %9 [
i32 1, label %10
i32 2, label %15
i32 3, label %20
i32 4, label %22
i32 5, label %24
]
9: ; preds = %5, %22, %20, %15, %10
br label %5
10: ; preds = %5
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%13 = load i32, i32* %1
%14 = call i32 @push_at_start(i32 %13)
br label %9
15: ; preds = %5
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%18 = load i32, i32* %1
%19 = call i32 @push_at_end(i32 %18)
br label %9
20: ; preds = %5
%21 = call i32 (...) @pop_at_start()
br label %9
22: ; preds = %5
%23 = call i32 (...) @pop_at_end()
br label %9
24: ; preds = %5
ret i32 0
}