#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*/ add_ch(char);
int /*<<< orphan*/ display();
char peek();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ remove_ch();
int /*<<< orphan*/ scanf(char *, int *);
int size();
int main(int argc, char *argv[]) {
  int option;
  char Mem[5];
  int front = -1;
  int rear = -1;
  char ch;
  char fro = Mem[front];
  int pek = rear + 1 - front;
  printf("\n..IMPLEMENTING A QUEUE OF CHARS IN C..\n");
  printf("----------------------------------------\n\n");
  do {
    printf("1.To ADD a character:\n2.To REMOVE a character:\n3.To DISPLAY "
           "Queue:\n4.PEEK of Queue:\n5.SIZE of Queue:\n6.EXIT: ");
    printf("\nEnter a choice: ");
    scanf("%d", &option);
    switch (option) {
    case 1:
      add_ch(ch);
      break;
    case 2:
      remove_ch();
      break;
    case 3:
      display();
      break;
    case 4:
      fro = peek();
      break;
    case 5:
      pek = size();
      break;
    case 6:
      return 0;
    default:
      return 0;
    }
  } while (option > 0 && option < 7);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x20(%rbp)
movl   $0xffffffff,-0x24(%rbp)
movslq -0x20(%rbp),%rax
mov    -0x19(%rbp,%rax,1),%al
mov    %al,-0x26(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    0xe66(%rip),%rdi
call   1070 <printf@plt>
lea    0xe83(%rip),%rdi
call   1070 <printf@plt>
lea    0xea2(%rip),%rdi
call   1070 <printf@plt>
lea    0xf04(%rip),%rdi
call   1070 <printf@plt>
lea    0xf0a(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x5,%eax
ja     1264 <main+0xf4>
mov    -0x38(%rbp),%rax
lea    0xdf5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsbl -0x25(%rbp),%edi
call   1060 <add_ch@plt>
jmp    1270 <main+0x100>
mov    $0x0,%al
call   1080 <remove_ch@plt>
jmp    1270 <main+0x100>
mov    $0x0,%al
call   1050 <display@plt>
jmp    1270 <main+0x100>
mov    $0x0,%al
call   1030 <peek@plt>
mov    %al,-0x26(%rbp)
jmp    1270 <main+0x100>
mov    $0x0,%al
call   1040 <size@plt>
mov    %eax,-0x2c(%rbp)
jmp    1270 <main+0x100>
movl   $0x0,-0x4(%rbp)
jmp    12a0 <main+0x130>
movl   $0x0,-0x4(%rbp)
jmp    12a0 <main+0x130>
jmp    1275 <main+0x105>
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x39(%rbp)
jle    128e <main+0x11e>
cmpl   $0x7,-0x14(%rbp)
setl   %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    11c3 <main+0x53>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xf03(%rip),%rdi
call   1050 <puts@plt>
lea    0xf1f(%rip),%rdi
call   1050 <puts@plt>
lea    0xe68(%rip),%r14
lea    0xecf(%rip),%r15
lea    0xeda(%rip),%r12
lea    0xc(%rsp),%r13
lea    0xe3a(%rip),%rbx
jmp    11ec <main+0x6c>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <size@plt>
nopw   0x0(%rax,%rax,1)
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x6,%eax
jae    1259 <main+0xd9>
mov    %r14,%rdi
call   1080 <printf@plt>
mov    %r15,%rdi
call   1080 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   10a0 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     1259 <main+0xd9>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
xor    %edi,%edi
call   1070 <add_ch@plt>
jmp    11e0 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1090 <remove_ch@plt>
jmp    11e0 <main+0x60>
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <display@plt>
jmp    11e0 <main+0x60>
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <peek@plt>
jmp    11e0 <main+0x60>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [41 x i8] c"\0A..IMPLEMENTING A QUEUE OF CHARS IN C..\0A\00"
@.str.1 = [43 x i8] c"----------------------------------------\0A\0A\00"
@.str.2 = [110 x i8] c"1.To ADD a character:\0A2.To REMOVE a character:\0A3.To DISPLAY Queue:\0A4.PEEK of Queue:\0A5.SIZE of Queue:\0A6.EXIT: \00"
@.str.3 = [18 x i8] c"\0AEnter a choice: \00"
@.str.4 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [5 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
%11 = alloca i8
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %8
store i32 -1, i32* %9
%13 = load i32, i32* %8
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 %14
%16 = load i8, i8* %15
store i8 %16, i8* %11
%17 = load i32, i32* %9
%18 = add nsw i32 %17, 1
%19 = load i32, i32* %8
%20 = sub nsw i32 %18, %19
store i32 %20, i32* %12
%21 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %48, %2
%24 = call i32 @printf(i8* getelementptr inbounds ([110 x i8], [110 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %6)
%27 = load i32, i32* %6
switch i32 %27, label %40 [
i32 1, label %28
i32 2, label %31
i32 3, label %33
i32 4, label %35
i32 5, label %37
i32 6, label %39
]
28: ; preds = %23
%29 = load i8, i8* %10
%30 = call i32 @add_ch(i8 signext %29)
br label %41
31: ; preds = %23
%32 = call i32 (...) @remove_ch()
br label %41
33: ; preds = %23
%34 = call i32 (...) @display()
br label %41
35: ; preds = %23
%36 = call signext i8 (...) @peek()
store i8 %36, i8* %11
br label %41
37: ; preds = %23
%38 = call i32 (...) @size()
store i32 %38, i32* %12
br label %41
39: ; preds = %23
store i32 0, i32* %3
br label %51
40: ; preds = %23
store i32 0, i32* %3
br label %51
41: ; preds = %37, %35, %33, %31, %28
br label %42
42: ; preds = %41
%43 = load i32, i32* %6
%44 = icmp sgt i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load i32, i32* %6
%47 = icmp slt i32 %46, 7
br label %48
48: ; preds = %45, %42
%49 = phi i1 [ false, %42 ], [ %47, %45 ]
br i1 %49, label %23, label %50
50: ; preds = %48
store i32 0, i32* %3
br label %51
51: ; preds = %50, %40, %39
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@.str.2 = [110 x i8] c"1.To ADD a character:\0A2.To REMOVE a character:\0A3.To DISPLAY Queue:\0A4.PEEK of Queue:\0A5.SIZE of Queue:\0A6.EXIT: \00"
@.str.3 = [18 x i8] c"\0AEnter a choice: \00"
@.str.4 = [3 x i8] c"%d\00"
@str = [40 x i8] c"\0A..IMPLEMENTING A QUEUE OF CHARS IN C..\00"
@str.5 = [42 x i8] c"----------------------------------------\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.5, i64 0, i64 0))
br label %7
7: ; preds = %22, %2
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([110 x i8], [110 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
switch i32 %11, label %26 [
i32 1, label %12
i32 2, label %14
i32 3, label %16
i32 4, label %18
i32 5, label %20
]
12: ; preds = %7
%13 = call i32 @add_ch(i8 signext undef)
br label %22
14: ; preds = %7
%15 = call i32 (...) @remove_ch()
br label %22
16: ; preds = %7
%17 = call i32 (...) @display()
br label %22
18: ; preds = %7
%19 = call signext i8 (...) @peek()
br label %22
20: ; preds = %7
%21 = call i32 (...) @size()
br label %22
22: ; preds = %12, %14, %16, %18, %20
%23 = load i32, i32* %3
%24 = add i32 %23, -1
%25 = icmp ult i32 %24, 6
br i1 %25, label %7, label %26
26: ; preds = %22, %7
ret i32 0
}