#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*/ compressQueue(int *, int, int);
int /*<<< orphan*/ isEmptyQueue(int, int);
int /*<<< orphan*/ isFullQueue(int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ showErr(int /*<<< orphan*/);
int /*<<< orphan*/ showSucess(int /*<<< orphan*/);
void insertInto(int *queue, int *begin, int *end) {
  if (!isFullQueue(*begin, *end)) {
    if (!isEmptyQueue(*begin, *end)) {
      if (*end == (5 - 1)) {
        compressQueue(queue, *begin, *end);
        *end = (*end - *begin) + 1;
        *begin = 0;
      } else {
        *end = *end + 1;
      }
    } else {
      *begin = *begin + 1;
      *end = *end + 1;
    }
  } else {
    showErr(0);
    return;
  }
  int value;
  printf("insert value at queue: ");
  scanf("%d", &value);
  queue[*end] = value;
  showSucess(0);
  return;
}


x86 assembly (clang, -O0):
<insertInto>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1090 <isFullQueue@plt>
cmp    $0x0,%eax
jne    1235 <insertInto+0xc5>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1060 <isEmptyQueue@plt>
cmp    $0x0,%eax
jne    1212 <insertInto+0xa2>
mov    -0x18(%rbp),%rax
cmpl   $0x4,(%rax)
jne    11fe <insertInto+0x8e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
call   1080 <compressQueue@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
sub    (%rax),%ecx
add    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
jmp    120d <insertInto+0x9d>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    1230 <insertInto+0xc0>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    1241 <insertInto+0xd1>
xor    %edi,%edi
call   1040 <showErr@plt>
jmp    1275 <insertInto+0x105>
lea    0xdb8(%rip),%rdi
call   1030 <printf@plt>
lea    0xdc4(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x1c(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
xor    %edi,%edi
call   1050 <showSucess@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insertInto>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rsi),%edi
mov    (%rdx),%esi
call   1090 <isFullQueue@plt>
test   %eax,%eax
je     119f <insertInto+0x2f>
xor    %edi,%edi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <showErr@plt>
mov    (%rbx),%edi
mov    (%r15),%esi
call   1060 <isEmptyQueue@plt>
test   %eax,%eax
je     11b6 <insertInto+0x46>
addl   $0x1,(%rbx)
addl   $0x1,(%r15)
jmp    11e6 <insertInto+0x76>
mov    (%r15),%eax
cmp    $0x4,%eax
jne    11e0 <insertInto+0x70>
mov    (%rbx),%esi
mov    %r14,%rdi
mov    $0x4,%edx
call   1080 <compressQueue@plt>
mov    (%r15),%eax
sub    (%rbx),%eax
add    $0x1,%eax
mov    %eax,(%r15)
movl   $0x0,(%rbx)
jmp    11e6 <insertInto+0x76>
add    $0x1,%eax
mov    %eax,(%r15)
lea    0xe13(%rip),%rdi
call   1030 <printf@plt>
lea    0xe1f(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%eax
movslq (%r15),%rcx
mov    %eax,(%r14,%rcx,4)
xor    %edi,%edi
call   1050 <showSucess@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [24 x i8] c"insert value at queue: \00"
@.str.1 = [3 x i8] c"%d\00"
define void @insertInto(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%8 = load i32*, i32** %5
%9 = load i32, i32* %8
%10 = load i32*, i32** %6
%11 = load i32, i32* %10
%12 = call i32 @isFullQueue(i32 %9, i32 %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %56, label %14
14: ; preds = %3
%15 = load i32*, i32** %5
%16 = load i32, i32* %15
%17 = load i32*, i32** %6
%18 = load i32, i32* %17
%19 = call i32 @isEmptyQueue(i32 %16, i32 %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %46, label %21
21: ; preds = %14
%22 = load i32*, i32** %6
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 4
br i1 %24, label %25, label %40
25: ; preds = %21
%26 = load i32*, i32** %4
%27 = load i32*, i32** %5
%28 = load i32, i32* %27
%29 = load i32*, i32** %6
%30 = load i32, i32* %29
%31 = call i32 @compressQueue(i32* %26, i32 %28, i32 %30)
%32 = load i32*, i32** %6
%33 = load i32, i32* %32
%34 = load i32*, i32** %5
%35 = load i32, i32* %34
%36 = sub nsw i32 %33, %35
%37 = add nsw i32 %36, 1
%38 = load i32*, i32** %6
store i32 %37, i32* %38
%39 = load i32*, i32** %5
store i32 0, i32* %39
br label %45
40: ; preds = %21
%41 = load i32*, i32** %6
%42 = load i32, i32* %41
%43 = add nsw i32 %42, 1
%44 = load i32*, i32** %6
store i32 %43, i32* %44
br label %45
45: ; preds = %40, %25
br label %55
46: ; preds = %14
%47 = load i32*, i32** %5
%48 = load i32, i32* %47
%49 = add nsw i32 %48, 1
%50 = load i32*, i32** %5
store i32 %49, i32* %50
%51 = load i32*, i32** %6
%52 = load i32, i32* %51
%53 = add nsw i32 %52, 1
%54 = load i32*, i32** %6
store i32 %53, i32* %54
br label %55
55: ; preds = %46, %45
br label %58
56: ; preds = %3
%57 = call i32 @showErr(i32 0)
br label %68
58: ; preds = %55
%59 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%60 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%61 = load i32, i32* %7
%62 = load i32*, i32** %4
%63 = load i32*, i32** %6
%64 = load i32, i32* %63
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i32, i32* %62, i64 %65
store i32 %61, i32* %66
%67 = call i32 @showSucess(i32 0)
br label %68
68: ; preds = %58, %56
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"insert value at queue: \00"
@.str.1 = [3 x i8] c"%d\00"
define void @insertInto(i32* %0, i32* nocapture %1, i32* nocapture %2) {
%4 = alloca i32
%5 = load i32, i32* %1
%6 = load i32, i32* %2
%7 = tail call i32 @isFullQueue(i32 %5, i32 %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %31
9: ; preds = %3
%10 = load i32, i32* %1
%11 = load i32, i32* %2
%12 = tail call i32 @isEmptyQueue(i32 %10, i32 %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %26
14: ; preds = %9
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 4
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load i32, i32* %1
%19 = tail call i32 @compressQueue(i32* %0, i32 %18, i32 4)
%20 = load i32, i32* %2
%21 = load i32, i32* %1
%22 = add i32 %20, 1
%23 = sub i32 %22, %21
store i32 %23, i32* %2
store i32 0, i32* %1
br label %33
24: ; preds = %14
%25 = add nsw i32 %15, 1
store i32 %25, i32* %2
br label %33
26: ; preds = %9
%27 = load i32, i32* %1
%28 = add nsw i32 %27, 1
store i32 %28, i32* %1
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %2
br label %33
31: ; preds = %3
%32 = tail call i32 @showErr(i32 0)
br label %42
33: ; preds = %26, %24, %17
%34 = bitcast i32* %4 to i8*
%35 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%37 = load i32, i32* %4
%38 = load i32, i32* %2
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %0, i64 %39
store i32 %37, i32* %40
%41 = call i32 @showSucess(i32 0)
br label %42
42: ; preds = %33, %31
ret void
}