#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*/ freeQueue(int *, int *, int *);
int /*<<< orphan*/ insertInto(int *, int *, int *);
int /*<<< orphan*/ isEmptyQueue(int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ removeInto(int *, int *, int *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ searchQueue(int *, int, int);
int /*<<< orphan*/ showErr(int);
int /*<<< orphan*/ showQueue(int *, int, int);
int main() {
  int queue[5], resp, begin = -1, end = -1;
  do {
    printf("\n\n0 - exit | 1 - insert | 2 - show | 3 - remove | 4 - search | 5 "
           "- free queue \n\n");
    scanf("%d", &resp);
    switch (resp) {
    case 1: {
      insertInto(queue, &begin, &end);
      break;
    }
    case 2: {
      if (!isEmptyQueue(begin, end)) {
        showQueue(queue, begin, end);
      } else {
        showErr(1);
      }
      break;
    }
    case 3: {
      if (!isEmptyQueue(begin, end)) {
        removeInto(queue, &begin, &end);
      } else {
        showErr(1);
      }
      break;
    }
    case 4: {
      if (!isEmptyQueue(begin, end)) {
        searchQueue(queue, begin, end);
      } else {
        showErr(1);
      }
      break;
    }
    case 5: {
      if (!isEmptyQueue(begin, end)) {
        freeQueue(queue, &begin, &end);
      } else {
        showErr(1);
      }
      break;
    }
    }
  } while (resp != 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x28(%rbp)
movl   $0xffffffff,-0x2c(%rbp)
lea    0xe60(%rip),%rdi
call   1040 <printf@plt>
lea    0xea5(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x4,%eax
ja     12e8 <main+0x158>
mov    -0x38(%rbp),%rax
lea    0xe17(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
call   1070 <insertInto@plt>
jmp    12e8 <main+0x158>
mov    -0x28(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1080 <isEmptyQueue@plt>
cmp    $0x0,%eax
jne    1230 <main+0xa0>
lea    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   10a0 <showQueue@plt>
jmp    123a <main+0xaa>
mov    $0x1,%edi
call   1060 <showErr@plt>
jmp    12e8 <main+0x158>
mov    -0x28(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1080 <isEmptyQueue@plt>
cmp    $0x0,%eax
jne    1269 <main+0xd9>
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
call   1030 <removeInto@plt>
jmp    1273 <main+0xe3>
mov    $0x1,%edi
call   1060 <showErr@plt>
jmp    12e8 <main+0x158>
mov    -0x28(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1080 <isEmptyQueue@plt>
cmp    $0x0,%eax
jne    12a0 <main+0x110>
lea    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   10b0 <searchQueue@plt>
jmp    12aa <main+0x11a>
mov    $0x1,%edi
call   1060 <showErr@plt>
jmp    12e8 <main+0x158>
mov    -0x28(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1080 <isEmptyQueue@plt>
cmp    $0x0,%eax
jne    12d9 <main+0x149>
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
call   1050 <freeQueue@plt>
jmp    12e3 <main+0x153>
mov    $0x1,%edi
call   1060 <showErr@plt>
jmp    12e8 <main+0x158>
jmp    12ed <main+0x15d>
cmpl   $0x0,-0x24(%rbp)
jne    11ad <main+0x1d>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movl   $0xffffffff,0x4(%rsp)
ff
movl   $0xffffffff,0x8(%rsp)
ff
lea    0xe62(%rip),%r14
lea    0xe58(%rip),%r15
lea    0xc(%rsp),%rbx
lea    0xe38(%rip),%r13
lea    0x10(%rsp),%r12
lea    0x8(%rsp),%rbp
jmp    11ff <main+0x6f>
mov    0x4(%rsp),%edi
mov    0x8(%rsp),%esi
call   1080 <isEmptyQueue@plt>
test   %eax,%eax
je     12b1 <main+0x121>
mov    $0x1,%edi
call   1060 <showErr@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     12c6 <main+0x136>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <scanf@plt>
mov    0xc(%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    $0x4,%ecx
ja     11f7 <main+0x67>
movslq 0x0(%r13,%rcx,4),%rax
add    %r13,%rax
jmp    *%rax
mov    %r12,%rdi
lea    0x4(%rsp),%rsi
mov    %rbp,%rdx
call   1070 <insertInto@plt>
jmp    11f3 <main+0x63>
mov    0x4(%rsp),%edi
mov    0x8(%rsp),%esi
call   1080 <isEmptyQueue@plt>
test   %eax,%eax
jne    11e9 <main+0x59>
mov    0x4(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r12,%rdi
call   10a0 <showQueue@plt>
jmp    11f3 <main+0x63>
mov    0x4(%rsp),%edi
mov    0x8(%rsp),%esi
call   1080 <isEmptyQueue@plt>
test   %eax,%eax
jne    11e9 <main+0x59>
mov    %r12,%rdi
lea    0x4(%rsp),%rsi
mov    %rbp,%rdx
call   1040 <removeInto@plt>
jmp    11f3 <main+0x63>
mov    0x4(%rsp),%edi
mov    0x8(%rsp),%esi
call   1080 <isEmptyQueue@plt>
test   %eax,%eax
jne    11e9 <main+0x59>
mov    0x4(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r12,%rdi
call   10b0 <searchQueue@plt>
jmp    11f3 <main+0x63>
mov    %r12,%rdi
lea    0x4(%rsp),%rsi
mov    %rbp,%rdx
call   1050 <freeQueue@plt>
jmp    11f3 <main+0x63>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [81 x i8] c"\0A\0A0 - exit | 1 - insert | 2 - show | 3 - remove | 4 - search | 5 - free queue \0A\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %4
store i32 -1, i32* %5
br label %6
6: ; preds = %62, %0
%7 = call i32 @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
switch i32 %9, label %61 [
i32 1, label %10
i32 2, label %13
i32 3, label %26
i32 4, label %37
i32 5, label %50
]
10: ; preds = %6
%11 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%12 = call i32 @insertInto(i32* %11, i32* %4, i32* %5)
br label %61
13: ; preds = %6
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = call i32 @isEmptyQueue(i32 %14, i32 %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %13
%19 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = call i32 @showQueue(i32* %19, i32 %20, i32 %21)
br label %25
23: ; preds = %13
%24 = call i32 @showErr(i32 1)
br label %25
25: ; preds = %23, %18
br label %61
26: ; preds = %6
%27 = load i32, i32* %4
%28 = load i32, i32* %5
%29 = call i32 @isEmptyQueue(i32 %27, i32 %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %26
%32 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%33 = call i32 @removeInto(i32* %32, i32* %4, i32* %5)
br label %36
34: ; preds = %26
%35 = call i32 @showErr(i32 1)
br label %36
36: ; preds = %34, %31
br label %61
37: ; preds = %6
%38 = load i32, i32* %4
%39 = load i32, i32* %5
%40 = call i32 @isEmptyQueue(i32 %38, i32 %39)
%41 = icmp ne i32 %40, 0
br i1 %41, label %47, label %42
42: ; preds = %37
%43 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%44 = load i32, i32* %4
%45 = load i32, i32* %5
%46 = call i32 @searchQueue(i32* %43, i32 %44, i32 %45)
br label %49
47: ; preds = %37
%48 = call i32 @showErr(i32 1)
br label %49
49: ; preds = %47, %42
br label %61
50: ; preds = %6
%51 = load i32, i32* %4
%52 = load i32, i32* %5
%53 = call i32 @isEmptyQueue(i32 %51, i32 %52)
%54 = icmp ne i32 %53, 0
br i1 %54, label %58, label %55
55: ; preds = %50
%56 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%57 = call i32 @freeQueue(i32* %56, i32* %4, i32* %5)
br label %60
58: ; preds = %50
%59 = call i32 @showErr(i32 1)
br label %60
60: ; preds = %58, %55
br label %61
61: ; preds = %6, %60, %49, %36, %25, %10
br label %62
62: ; preds = %61
%63 = load i32, i32* %3
%64 = icmp ne i32 %63, 0
br i1 %64, label %6, label %65
65: ; preds = %62
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [80 x i8] c"\0A\0A0 - exit | 1 - insert | 2 - show | 3 - remove | 4 - search | 5 - free queue \0A\00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [5 x i32]* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
store i32 -1, i32* %3
%8 = bitcast i32* %4 to i8*
store i32 -1, i32* %4
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
br label %10
10: ; preds = %58, %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
switch i32 %13, label %58 [
i32 1, label %14
i32 2, label %16
i32 3, label %27
i32 4, label %36
i32 5, label %47
]
14: ; preds = %10
%15 = call i32 @insertInto(i32* %9, i32* %3, i32* %4)
br label %56
16: ; preds = %10
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = call i32 @isEmptyQueue(i32 %17, i32 %18)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %16
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = call i32 @showQueue(i32* %9, i32 %22, i32 %23)
br label %56
25: ; preds = %16
%26 = call i32 @showErr(i32 1)
br label %56
27: ; preds = %10
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = call i32 @isEmptyQueue(i32 %28, i32 %29)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %27
%33 = call i32 @removeInto(i32* %9, i32* %3, i32* %4)
br label %56
34: ; preds = %27
%35 = call i32 @showErr(i32 1)
br label %56
36: ; preds = %10
%37 = load i32, i32* %3
%38 = load i32, i32* %4
%39 = call i32 @isEmptyQueue(i32 %37, i32 %38)
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %36
%42 = load i32, i32* %3
%43 = load i32, i32* %4
%44 = call i32 @searchQueue(i32* %9, i32 %42, i32 %43)
br label %56
45: ; preds = %36
%46 = call i32 @showErr(i32 1)
br label %56
47: ; preds = %10
%48 = load i32, i32* %3
%49 = load i32, i32* %4
%50 = call i32 @isEmptyQueue(i32 %48, i32 %49)
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %47
%53 = call i32 @freeQueue(i32* %9, i32* %3, i32* %4)
br label %56
54: ; preds = %47
%55 = call i32 @showErr(i32 1)
br label %56
56: ; preds = %52, %54, %41, %45, %32, %34, %21, %25, %14
%57 = load i32, i32* %2
br label %58
58: ; preds = %56, %10
%59 = phi i32 [ %57, %56 ], [ %13, %10 ]
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %10
61: ; preds = %58
ret i32 0
}