#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 */
bool already_in_sort_index(int i, int *sort_index, int size) {
  for (int n = 0; n < size; ++n) {
    if (sort_index[n] < 0)
      return false;
    if (sort_index[n] == i)
      return true;
  }
  return false;
}


x86 assembly (clang, -O0):
<already_in_sort_index>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1172 <already_in_sort_index+0x72>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jge    113f <already_in_sort_index+0x3f>
movl   $0x0,-0x4(%rbp)
jmp    1179 <already_in_sort_index+0x79>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x8(%rbp),%eax
jne    115f <already_in_sort_index+0x5f>
movl   $0x1,-0x4(%rbp)
jmp    1179 <already_in_sort_index+0x79>
jmp    1164 <already_in_sort_index+0x64>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1115 <already_in_sort_index+0x15>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<already_in_sort_index>:
test   %edx,%edx
jle    1125 <already_in_sort_index+0x25>
mov    %edx,%r8d
xor    %eax,%eax
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
mov    (%rsi,%rdx,4),%ecx
test   %ecx,%ecx
js     1124 <already_in_sort_index+0x24>
cmp    %edi,%ecx
je     1128 <already_in_sort_index+0x28>
add    $0x1,%rdx
cmp    %rdx,%r8
jne    1110 <already_in_sort_index+0x10>
ret
xor    %eax,%eax
ret
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @already_in_sort_index(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* %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %31, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %7
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %34
13: ; preds = %9
%14 = load i32*, i32** %6
%15 = load i32, i32* %8
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
%18 = load i32, i32* %17
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %13
store i32 0, i32* %4
br label %35
21: ; preds = %13
%22 = load i32*, i32** %6
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = load i32, i32* %25
%27 = load i32, i32* %5
%28 = icmp eq i32 %26, %27
br i1 %28, label %29, label %30
29: ; preds = %21
store i32 1, i32* %4
br label %35
30: ; preds = %21
br label %31
31: ; preds = %30
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
store i32 %33, i32* %8
br label %9
34: ; preds = %9
store i32 0, i32* %4
br label %35
35: ; preds = %34, %29, %20
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
define i32 @already_in_sort_index(i32 %0, i32* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %17
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %9
7: ; preds = %14
%8 = icmp eq i64 %16, %6
br i1 %8, label %17, label %9
9: ; preds = %5, %7
%10 = phi i64 [ 0, %5 ], [ %16, %7 ]
%11 = getelementptr inbounds i32, i32* %1, i64 %10
%12 = load i32, i32* %11
%13 = icmp slt i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = icmp eq i32 %12, %0
%16 = add nuw nsw i64 %10, 1
br i1 %15, label %17, label %7
17: ; preds = %7, %9, %14, %3
%18 = phi i32 [ 0, %3 ], [ 1, %14 ], [ 0, %9 ], [ 0, %7 ]
ret i32 %18
}