#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, ...);
void search_Q(int *N_array, int *Q_array, int Q, int N, int *spp) {
  int *Q_array_next, *N_array_next, sp;
  *spp += 1;
  printf("CASE# %d:\n", *spp);
  for (int i = 0; i < Q; i++) {
    sp = 1;
    Q_array_next = Q_array + i;
    for (int j = 0; j < N; j++) {
      N_array_next = N_array + j;
      if (*Q_array_next == *N_array_next) {
        printf("%d found at %d\n", *Q_array_next, j + 1);
        sp = 0;
        break;
      }
    }
    if (sp == 1)
      printf("%d not found\n", *Q_array_next);
  }
}


x86 assembly (clang, -O0):
<search_Q>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1218 <search_Q+0x108>
movl   $0x1,-0x34(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11e7 <search_Q+0xd7>
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    -0x30(%rbp),%rcx
cmp    (%rcx),%eax
jne    11d4 <search_Q+0xc4>
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
mov    -0x3c(%rbp),%edx
add    $0x1,%edx
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
jmp    11e7 <search_Q+0xd7>
jmp    11d9 <search_Q+0xc9>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    117d <search_Q+0x6d>
cmpl   $0x1,-0x34(%rbp)
jne    1205 <search_Q+0xf5>
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120a <search_Q+0xfa>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1150 <search_Q+0x40>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search_Q>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r13d
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%r8),%esi
add    $0x1,%esi
mov    %esi,(%r8)
lea    0xec9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
test   %r15d,%r15d
jle    11a3 <search_Q+0x93>
mov    %r15d,%ebp
mov    %r13d,%r15d
xor    %r12d,%r12d
jmp    1167 <search_Q+0x57>
xchg   %ax,%ax
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%r12
cmp    %rbp,%r12
je     11a3 <search_Q+0x93>
mov    (%r14,%r12,4),%esi
test   %r13d,%r13d
jle    1150 <search_Q+0x40>
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    (%rbx,%rdx,4),%esi
je     1190 <search_Q+0x80>
add    $0x1,%rdx
cmp    %rdx,%r15
jne    1180 <search_Q+0x70>
jmp    1150 <search_Q+0x40>
add    $0x1,%edx
lea    0xe71(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    115e <search_Q+0x4e>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"CASE# %d:\0A\00"
@.str.1 = [16 x i8] c"%d found at %d\0A\00"
@.str.2 = [14 x i8] c"%d not found\0A\00"
define void @search_Q(i32* nocapture %0, i32* nocapture %1, i32 %2, i32 %3, i32* nocapture %4) {
%6 = load i32, i32* %4
%7 = add nsw i32 %6, 1
store i32 %7, i32* %4
%8 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = icmp sgt i32 %2, 0
br i1 %9, label %10, label %14
10: ; preds = %5
%11 = icmp sgt i32 %3, 0
%12 = zext i32 %2 to i64
%13 = zext i32 %3 to i64
br label %15
14: ; preds = %33, %5
ret void
15: ; preds = %10, %33
%16 = phi i64 [ 0, %10 ], [ %34, %33 ]
%17 = getelementptr inbounds i32, i32* %1, i64 %16
%18 = load i32, i32* %17
br i1 %11, label %19, label %31
19: ; preds = %15, %28
%20 = phi i64 [ %29, %28 ], [ 0, %15 ]
%21 = getelementptr inbounds i32, i32* %0, i64 %20
%22 = load i32, i32* %21
%23 = icmp eq i32 %18, %22
br i1 %23, label %24, label %28
24: ; preds = %19
%25 = trunc i64 %20 to i32
%26 = add nuw nsw i32 %25, 1
%27 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %26)
br label %33
28: ; preds = %19
%29 = add nuw nsw i64 %20, 1
%30 = icmp eq i64 %29, %13
br i1 %30, label %31, label %19
31: ; preds = %28, %15
%32 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %33
33: ; preds = %24, %31
%34 = add nuw nsw i64 %16, 1
%35 = icmp eq i64 %34, %12
br i1 %35, label %14, label %15
}