#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 */
typedef scalar_t__ KeySym;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int);
int /*<<< orphan*/ stderr;
int find_in(KeySym needle, KeySym *haystack, int nr) {
  int i;
  for (i = 0; i < nr; i++) {
    fprintf(stderr, "Comparing: %c ?= %c\n", (int)needle, (int)haystack[i]);
    if (needle == haystack[i])
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<find_in>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1194 <find_in+0x84>
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %eax,%ecx
lea    0xea6(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq -0x20(%rbp),%rdx
cmp    (%rcx,%rdx,8),%rax
jne    1181 <find_in+0x71>
movl   $0x1,-0x4(%rbp)
jmp    119b <find_in+0x8b>
jmp    1186 <find_in+0x76>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112a <find_in+0x1a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_in>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    1161 <find_in+0x51>
mov    %rsi,%r14
mov    %rdi,%r13
mov    %edx,%r12d
xor    %ebx,%ebx
mov    0x2eaf(%rip),%rbp
lea    0xec8(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp),%edi
mov    (%r14,%rbx,8),%ecx
mov    %r15,%rsi
mov    %r13d,%edx
call   1030 <fprintf@plt>
cmp    %r13,(%r14,%rbx,8)
je     1165 <find_in+0x55>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <find_in+0x30>
xor    %eax,%eax
jmp    116a <find_in+0x5a>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"Comparing: %c ?= %c\0A\00"
define i32 @find_in(i64 %0, i64* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64*
%7 = alloca i32
%8 = alloca i32
store i64 %0, i64* %5
store i64* %1, i64** %6
store i32 %2, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %33, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %7
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %36
13: ; preds = %9
%14 = load i32, i32* @stderr
%15 = load i64, i64* %5
%16 = trunc i64 %15 to i32
%17 = load i64*, i64** %6
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i64, i64* %17, i64 %19
%21 = load i64, i64* %20
%22 = trunc i64 %21 to i32
%23 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %22)
%24 = load i64, i64* %5
%25 = load i64*, i64** %6
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i64, i64* %25, i64 %27
%29 = load i64, i64* %28
%30 = icmp eq i64 %24, %29
br i1 %30, label %31, label %32
31: ; preds = %13
store i32 1, i32* %4
br label %37
32: ; preds = %13
br label %33
33: ; preds = %32
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %9
36: ; preds = %9
store i32 0, i32* %4
br label %37
37: ; preds = %36, %31
%38 = load i32, i32* %4
ret i32 %38
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"Comparing: %c ?= %c\0A\00"
define i32 @find_in(i64 %0, i64* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %20
5: ; preds = %3
%6 = trunc i64 %0 to i32
%7 = zext i32 %2 to i64
br label %10
8: ; preds = %10
%9 = icmp eq i64 %19, %7
br i1 %9, label %20, label %10
10: ; preds = %5, %8
%11 = phi i64 [ 0, %5 ], [ %19, %8 ]
%12 = load i32, i32* @stderr
%13 = getelementptr inbounds i64, i64* %1, i64 %11
%14 = load i64, i64* %13
%15 = trunc i64 %14 to i32
%16 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %15)
%17 = load i64, i64* %13
%18 = icmp eq i64 %17, %0
%19 = add nuw nsw i64 %11, 1
br i1 %18, label %20, label %8
20: ; preds = %10, %8, %3
%21 = phi i32 [ 0, %3 ], [ 0, %8 ], [ 1, %10 ]
ret i32 %21
}