#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 */
size_t hash_with_scan(int, int);
int hash_open_search(int table[], int value) {
  int i = 0;
  while (i < 10 && table[hash_with_scan(value, i)] != -2 &&
         table[hash_with_scan(value, i)] != value &&
         table[hash_with_scan(value, i)] != value)
    i += 1;
  if (i == 10 || table[hash_with_scan(value, i)] == -2 ||
      table[hash_with_scan(value, i)] == -1)
    return -1;
  else
    return i;
}


x86 assembly (clang, -O0):
<hash_open_search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0xa,-0x18(%rbp)
mov    %al,-0x19(%rbp)
jge    11af <hash_open_search+0x9f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <hash_with_scan@plt>
mov    -0x28(%rbp),%rcx
mov    %rax,%rdx
xor    %eax,%eax
cmpl   $0xfffffffe,(%rcx,%rdx,4)
mov    %al,-0x19(%rbp)
je     11af <hash_open_search+0x9f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <hash_with_scan@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    (%rax,%rcx,4),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x19(%rbp)
je     11af <hash_open_search+0x9f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <hash_with_scan@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
mov    (%rax,%rcx,4),%eax
cmp    -0x14(%rbp),%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11bf <hash_open_search+0xaf>
jmp    11cd <hash_open_search+0xbd>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1126 <hash_open_search+0x16>
cmpl   $0xa,-0x18(%rbp)
je     121f <hash_open_search+0x10f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <hash_with_scan@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmpl   $0xfffffffe,(%rax,%rcx,4)
je     121f <hash_open_search+0x10f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <hash_with_scan@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cmpl   $0xffffffff,(%rax,%rcx,4)
jne    122b <hash_open_search+0x11b>
movl   $0xffffffff,-0x4(%rbp)
jmp    1231 <hash_open_search+0x121>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash_open_search>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <hash_with_scan@plt>
cmpl   $0xfffffffe,(%r14,%rax,4)
je     115d <hash_open_search+0x4d>
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <hash_with_scan@plt>
cmp    %ebp,(%r14,%rax,4)
je     115d <hash_open_search+0x4d>
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <hash_with_scan@plt>
cmp    %ebp,(%r14,%rax,4)
je     115d <hash_open_search+0x4d>
add    $0x1,%ebx
cmp    $0xa,%ebx
jne    1120 <hash_open_search+0x10>
mov    $0xffffffff,%eax
jmp    118a <hash_open_search+0x7a>
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <hash_with_scan@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
cmpl   $0xfffffffe,(%r14,%rcx,4)
je     118a <hash_open_search+0x7a>
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <hash_with_scan@plt>
mov    (%r14,%rax,4),%eax
cmp    $0xffffffff,%eax
cmove  %eax,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @hash_open_search(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 0, i32* %6
br label %7
7: ; preds = %38, %2
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %36
10: ; preds = %7
%11 = load i32*, i32** %4
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = call i64 @hash_with_scan(i32 %12, i32 %13)
%15 = getelementptr inbounds i32, i32* %11, i64 %14
%16 = load i32, i32* %15
%17 = icmp ne i32 %16, -2
br i1 %17, label %18, label %36
18: ; preds = %10
%19 = load i32*, i32** %4
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = call i64 @hash_with_scan(i32 %20, i32 %21)
%23 = getelementptr inbounds i32, i32* %19, i64 %22
%24 = load i32, i32* %23
%25 = load i32, i32* %5
%26 = icmp ne i32 %24, %25
br i1 %26, label %27, label %36
27: ; preds = %18
%28 = load i32*, i32** %4
%29 = load i32, i32* %5
%30 = load i32, i32* %6
%31 = call i64 @hash_with_scan(i32 %29, i32 %30)
%32 = getelementptr inbounds i32, i32* %28, i64 %31
%33 = load i32, i32* %32
%34 = load i32, i32* %5
%35 = icmp ne i32 %33, %34
br label %36
36: ; preds = %27, %18, %10, %7
%37 = phi i1 [ false, %18 ], [ false, %10 ], [ false, %7 ], [ %35, %27 ]
br i1 %37, label %38, label %41
38: ; preds = %36
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %7
41: ; preds = %36
%42 = load i32, i32* %6
%43 = icmp eq i32 %42, 10
br i1 %43, label %60, label %44
44: ; preds = %41
%45 = load i32*, i32** %4
%46 = load i32, i32* %5
%47 = load i32, i32* %6
%48 = call i64 @hash_with_scan(i32 %46, i32 %47)
%49 = getelementptr inbounds i32, i32* %45, i64 %48
%50 = load i32, i32* %49
%51 = icmp eq i32 %50, -2
br i1 %51, label %60, label %52
52: ; preds = %44
%53 = load i32*, i32** %4
%54 = load i32, i32* %5
%55 = load i32, i32* %6
%56 = call i64 @hash_with_scan(i32 %54, i32 %55)
%57 = getelementptr inbounds i32, i32* %53, i64 %56
%58 = load i32, i32* %57
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %61
60: ; preds = %52, %44, %41
store i32 -1, i32* %3
br label %63
61: ; preds = %52
%62 = load i32, i32* %6
store i32 %62, i32* %3
br label %63
63: ; preds = %61, %60
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
define i32 @hash_open_search(i32* nocapture %0, i32 %1) {
br label %3
3: ; preds = %2, %19
%4 = phi i32 [ 0, %2 ], [ %20, %19 ]
%5 = tail call i64 @hash_with_scan(i32 %1, i32 %4)
%6 = getelementptr inbounds i32, i32* %0, i64 %5
%7 = load i32, i32* %6
%8 = icmp eq i32 %7, -2
br i1 %8, label %22, label %9
9: ; preds = %3
%10 = tail call i64 @hash_with_scan(i32 %1, i32 %4)
%11 = getelementptr inbounds i32, i32* %0, i64 %10
%12 = load i32, i32* %11
%13 = icmp eq i32 %12, %1
br i1 %13, label %22, label %14
14: ; preds = %9
%15 = tail call i64 @hash_with_scan(i32 %1, i32 %4)
%16 = getelementptr inbounds i32, i32* %0, i64 %15
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, %1
br i1 %18, label %22, label %19
19: ; preds = %14
%20 = add nuw nsw i32 %4, 1
%21 = icmp eq i32 %20, 10
br i1 %21, label %33, label %3
22: ; preds = %14, %9, %3
%23 = tail call i64 @hash_with_scan(i32 %1, i32 %4)
%24 = getelementptr inbounds i32, i32* %0, i64 %23
%25 = load i32, i32* %24
%26 = icmp eq i32 %25, -2
br i1 %26, label %33, label %27
27: ; preds = %22
%28 = tail call i64 @hash_with_scan(i32 %1, i32 %4)
%29 = getelementptr inbounds i32, i32* %0, i64 %28
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, -1
%32 = select i1 %31, i32 -1, i32 %4
br label %33
33: ; preds = %19, %27, %22
%34 = phi i32 [ -1, %22 ], [ %32, %27 ], [ -1, %19 ]
ret i32 %34
}