#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__ uint32_t;
struct cl_rhash_table {
  int dummy;
};

/* Variables and functions */
scalar_t__ cl_rhash_table_cost(struct cl_rhash_table *, scalar_t__);
int /*<<< orphan*/ cl_rhash_table_entry_exists(struct cl_rhash_table *,
                                               void **);
scalar_t__ cl_rhash_table_hash(struct cl_rhash_table *, void **);
scalar_t__ cl_rhash_table_key_equals(struct cl_rhash_table *, void **, void **);
void **cl_rhash_table_ptr(struct cl_rhash_table *, scalar_t__);
scalar_t__ cl_rhash_table_size(struct cl_rhash_table *);
scalar_t__ cl_rhash_table_slot(struct cl_rhash_table *, scalar_t__, scalar_t__);
void **cl_rhash_table_entry(struct cl_rhash_table *tbl, void **key) {
  uint32_t n_size = cl_rhash_table_size(tbl);
  uint32_t hcode = cl_rhash_table_hash(tbl, key);
  for (uint32_t pr = 0; pr < n_size; pr++) {
    uint32_t slot = cl_rhash_table_slot(tbl, hcode, pr);
    void **e = cl_rhash_table_ptr(tbl, slot);
    if (!cl_rhash_table_entry_exists(tbl, e))
      break;
    if (cl_rhash_table_key_equals(tbl, key, e))
      return e;
    if (pr > cl_rhash_table_cost(tbl, slot))
      break;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<cl_rhash_table_entry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <cl_rhash_table_size@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <cl_rhash_table_hash@plt>
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    125d <cl_rhash_table_entry+0xed>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1090 <cl_rhash_table_slot@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1070 <cl_rhash_table_ptr@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1060 <cl_rhash_table_entry_exists@plt>
cmp    $0x0,%eax
jne    11f5 <cl_rhash_table_entry+0x85>
jmp    125d <cl_rhash_table_entry+0xed>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x40(%rbp),%rdx
call   1050 <cl_rhash_table_key_equals@plt>
cmp    $0x0,%rax
je     121d <cl_rhash_table_entry+0xad>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1265 <cl_rhash_table_entry+0xf5>
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1080 <cl_rhash_table_cost@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cmp    %rcx,%rax
jle    1247 <cl_rhash_table_entry+0xd7>
jmp    125d <cl_rhash_table_entry+0xed>
jmp    124c <cl_rhash_table_entry+0xdc>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11a6 <cl_rhash_table_entry+0x36>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cl_rhash_table_entry>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r13
call   1040 <cl_rhash_table_size@plt>
mov    %rax,%rbp
mov    %r13,%rdi
mov    %rbx,0x10(%rsp)
mov    %rbx,%rsi
call   1030 <cl_rhash_table_hash@plt>
mov    %rbp,0x8(%rsp)
test   %rbp,%rbp
jle    121c <cl_rhash_table_entry+0xac>
mov    %rax,%r12
mov    $0x1,%r15d
nop
lea    -0x1(%r15),%rbx
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1090 <cl_rhash_table_slot@plt>
mov    %rax,%r14
mov    %r13,%rdi
mov    %rax,%rsi
call   1070 <cl_rhash_table_ptr@plt>
mov    %rax,%rbp
mov    %r13,%rdi
mov    %rax,%rsi
call   1060 <cl_rhash_table_entry_exists@plt>
test   %eax,%eax
je     121c <cl_rhash_table_entry+0xac>
mov    %r13,%rdi
mov    0x10(%rsp),%rsi
mov    %rbp,%rdx
call   1050 <cl_rhash_table_key_equals@plt>
test   %rax,%rax
jne    121e <cl_rhash_table_entry+0xae>
mov    %r13,%rdi
mov    %r14,%rsi
call   1080 <cl_rhash_table_cost@plt>
cmp    %rax,%rbx
jg     121c <cl_rhash_table_entry+0xac>
lea    0x1(%r15),%rax
mov    $0x0,%ebp
cmp    0x8(%rsp),%r15
mov    %rax,%r15
jl     11b0 <cl_rhash_table_entry+0x40>
jmp    121e <cl_rhash_table_entry+0xae>
xor    %ebp,%ebp
mov    %rbp,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.cl_rhash_table = type { i32 }
define i8** @cl_rhash_table_entry(%struct.cl_rhash_table* %0, i8** %1) {
%3 = alloca i8**
%4 = alloca %struct.cl_rhash_table*
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i8**
store %struct.cl_rhash_table* %0, %struct.cl_rhash_table** %4
store i8** %1, i8*** %5
%11 = load %struct.cl_rhash_table*, %struct.cl_rhash_table** %4
%12 = call i64 @cl_rhash_table_size(%struct.cl_rhash_table* %11)
store i64 %12, i64* %6
%13 = load %struct.cl_rhash_table*, %struct.cl_rhash_table** %4
%14 = load i8**, i8*** %5
%15 = call i64 @cl_rhash_table_hash(%struct.cl_rhash_table* %13, i8** %14)
store i64 %15, i64* %7
store i64 0, i64* %8
br label %16
16: ; preds = %49, %2
%17 = load i64, i64* %8
%18 = load i64, i64* %6
%19 = icmp slt i64 %17, %18
br i1 %19, label %20, label %52
20: ; preds = %16
%21 = load %struct.cl_rhash_table*, %struct.cl_rhash_table** %4
%22 = load i64, i64* %7
%23 = load i64, i64* %8
%24 = call i64 @cl_rhash_table_slot(%struct.cl_rhash_table* %21, i64 %22, i64 %23)
store i64 %24, i64* %9
%25 = load %struct.cl_rhash_table*, %struct.cl_rhash_table** %4
%26 = load i64, i64* %9
%27 = call i8** @cl_rhash_table_ptr(%struct.cl_rhash_table* %25, i64 %26)
store i8** %27, i8*** %10
%28 = load %struct.cl_rhash_table*, %struct.cl_rhash_table** %4
%29 = load i8**, i8*** %10
%30 = call i32 @cl_rhash_table_entry_exists(%struct.cl_rhash_table* %28, i8** %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %20
br label %52
33: ; preds = %20
%34 = load %struct.cl_rhash_table*, %struct.cl_rhash_table** %4
%35 = load i8**, i8*** %5
%36 = load i8**, i8*** %10
%37 = call i64 @cl_rhash_table_key_equals(%struct.cl_rhash_table* %34, i8** %35, i8** %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %33
%40 = load i8**, i8*** %10
store i8** %40, i8*** %3
br label %53
41: ; preds = %33
%42 = load i64, i64* %8
%43 = load %struct.cl_rhash_table*, %struct.cl_rhash_table** %4
%44 = load i64, i64* %9
%45 = call i64 @cl_rhash_table_cost(%struct.cl_rhash_table* %43, i64 %44)
%46 = icmp sgt i64 %42, %45
br i1 %46, label %47, label %48
47: ; preds = %41
br label %52
48: ; preds = %41
br label %49
49: ; preds = %48
%50 = load i64, i64* %8
%51 = add nsw i64 %50, 1
store i64 %51, i64* %8
br label %16
52: ; preds = %47, %32, %16
store i8** null, i8*** %3
br label %53
53: ; preds = %52, %39
%54 = load i8**, i8*** %3
ret i8** %54
}

LLVM IR (-O2):
%struct.cl_rhash_table = type { i32 }
define i8** @cl_rhash_table_entry(%struct.cl_rhash_table* %0, i8** %1) {
%3 = tail call i64 @cl_rhash_table_size(%struct.cl_rhash_table* %0)
%4 = tail call i64 @cl_rhash_table_hash(%struct.cl_rhash_table* %0, i8** %1)
%5 = icmp sgt i64 %3, 0
br i1 %5, label %6, label %21
6: ; preds = %2, %15
%7 = phi i64 [ %18, %15 ], [ 0, %2 ]
%8 = tail call i64 @cl_rhash_table_slot(%struct.cl_rhash_table* %0, i64 %4, i64 %7)
%9 = tail call i8** @cl_rhash_table_ptr(%struct.cl_rhash_table* %0, i64 %8)
%10 = tail call i32 @cl_rhash_table_entry_exists(%struct.cl_rhash_table* %0, i8** %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %21, label %12
12: ; preds = %6
%13 = tail call i64 @cl_rhash_table_key_equals(%struct.cl_rhash_table* %0, i8** %1, i8** %9)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = tail call i64 @cl_rhash_table_cost(%struct.cl_rhash_table* %0, i64 %8)
%17 = icmp sle i64 %7, %16
%18 = add nuw nsw i64 %7, 1
%19 = icmp slt i64 %18, %3
%20 = select i1 %17, i1 %19, i1 false
br i1 %20, label %6, label %21
21: ; preds = %12, %6, %15, %2
%22 = phi i8** [ null, %2 ], [ null, %15 ], [ null, %6 ], [ %9, %12 ]
ret i8** %22
}