#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void searchQueue(int *queue, int begin, int end) {
  int i, query;
  printf("\ninsert value to search at the queue: ");
  scanf("%d", &query);
  for (i = begin; i <= end; i++) {
    if (queue[i] == query) {
      printf("\n%d - value: %d\n", i, queue[i]);
    }
  }
}


x86 assembly (clang, -O0):
<searchQueue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11a5 <searchQueue+0x85>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x18(%rbp),%eax
jne    1192 <searchQueue+0x72>
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1197 <searchQueue+0x77>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <searchQueue+0x36>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<searchQueue>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%ebp
mov    %rdi,%r14
lea    0xeca(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee3(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
cmp    %r15d,%ebp
jle    115e <searchQueue+0x3e>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
movslq %ebp,%rax
add    $0x1,%r15d
lea    (%r14,%rax,4),%rbx
lea    0xeba(%rip),%r14
jmp    118c <searchQueue+0x6c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebp
add    $0x4,%rbx
cmp    %ebp,%r15d
je     1153 <searchQueue+0x33>
mov    (%rbx),%edx
cmp    0x4(%rsp),%edx
jne    1180 <searchQueue+0x60>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1180 <searchQueue+0x60>

LLVM IR (-O0):
@.str = [39 x i8] c"\0Ainsert value to search at the queue: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"\0A%d - value: %d\0A\00"
define void @searchQueue(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%11 = load i32, i32* %5
store i32 %11, i32* %7
br label %12
12: ; preds = %33, %3
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %36
16: ; preds = %12
%17 = load i32*, i32** %4
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = load i32, i32* %8
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %32
24: ; preds = %16
%25 = load i32, i32* %7
%26 = load i32*, i32** %4
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %25, i32 %30)
br label %32
32: ; preds = %24, %16
br label %33
33: ; preds = %32
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %12
36: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [39 x i8] c"\0Ainsert value to search at the queue: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"\0A%d - value: %d\0A\00"
define void @searchQueue(i32* nocapture %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 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* %4)
%8 = icmp sgt i32 %1, %2
br i1 %8, label %25, label %9
9: ; preds = %3
%10 = sext i32 %1 to i64
%11 = add i32 %2, 1
br label %12
12: ; preds = %9, %21
%13 = phi i64 [ %10, %9 ], [ %22, %21 ]
%14 = getelementptr inbounds i32, i32* %0, i64 %13
%15 = load i32, i32* %14
%16 = load i32, i32* %4
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = trunc i64 %13 to i32
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %15)
br label %21
21: ; preds = %12, %18
%22 = add nsw i64 %13, 1
%23 = trunc i64 %22 to i32
%24 = icmp eq i32 %11, %23
br i1 %24, label %25, label %12
25: ; preds = %21, %3
ret void
}