#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 */
struct cl_rhash_iterator {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ cl_rhash_iterator_check(struct cl_rhash_iterator *);
int /*<<< orphan*/ cl_rhash_iterator_done(struct cl_rhash_iterator *);
void **cl_rhash_iterator_entry(struct cl_rhash_iterator *);
int /*<<< orphan*/ cl_rhash_iterator_next_slot(struct cl_rhash_iterator *);
const void *cl_rhash_iterator_next(struct cl_rhash_iterator *it) {
  cl_rhash_iterator_check(it);
  while (!cl_rhash_iterator_done(it)) {
    cl_rhash_iterator_next_slot(it);
    void **ent = cl_rhash_iterator_entry(it);
    if (ent)
      return *ent;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<cl_rhash_iterator_next>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <cl_rhash_iterator_check@plt>
mov    -0x10(%rbp),%rdi
call   1040 <cl_rhash_iterator_done@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1173 <cl_rhash_iterator_next+0x33>
jmp    11a9 <cl_rhash_iterator_next+0x69>
mov    -0x10(%rbp),%rdi
call   1050 <cl_rhash_iterator_next_slot@plt>
mov    -0x10(%rbp),%rdi
call   1030 <cl_rhash_iterator_entry@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a4 <cl_rhash_iterator_next+0x64>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    11b1 <cl_rhash_iterator_next+0x71>
jmp    1155 <cl_rhash_iterator_next+0x15>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cl_rhash_iterator_next>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1060 <cl_rhash_iterator_check@plt>
xor    %r14d,%r14d
nop
mov    %rbx,%rdi
call   1040 <cl_rhash_iterator_done@plt>
test   %eax,%eax
jne    1174 <cl_rhash_iterator_next+0x34>
mov    %rbx,%rdi
call   1050 <cl_rhash_iterator_next_slot@plt>
mov    %rbx,%rdi
call   1030 <cl_rhash_iterator_entry@plt>
test   %rax,%rax
je     1150 <cl_rhash_iterator_next+0x10>
mov    (%rax),%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.cl_rhash_iterator = type { i32 }
define i8* @cl_rhash_iterator_next(%struct.cl_rhash_iterator* %0) {
%2 = alloca i8*
%3 = alloca %struct.cl_rhash_iterator*
%4 = alloca i8**
store %struct.cl_rhash_iterator* %0, %struct.cl_rhash_iterator** %3
%5 = load %struct.cl_rhash_iterator*, %struct.cl_rhash_iterator** %3
%6 = call i32 @cl_rhash_iterator_check(%struct.cl_rhash_iterator* %5)
br label %7
7: ; preds = %22, %1
%8 = load %struct.cl_rhash_iterator*, %struct.cl_rhash_iterator** %3
%9 = call i32 @cl_rhash_iterator_done(%struct.cl_rhash_iterator* %8)
%10 = icmp ne i32 %9, 0
%11 = xor i1 %10, true
br i1 %11, label %12, label %23
12: ; preds = %7
%13 = load %struct.cl_rhash_iterator*, %struct.cl_rhash_iterator** %3
%14 = call i32 @cl_rhash_iterator_next_slot(%struct.cl_rhash_iterator* %13)
%15 = load %struct.cl_rhash_iterator*, %struct.cl_rhash_iterator** %3
%16 = call i8** @cl_rhash_iterator_entry(%struct.cl_rhash_iterator* %15)
store i8** %16, i8*** %4
%17 = load i8**, i8*** %4
%18 = icmp ne i8** %17, null
br i1 %18, label %19, label %22
19: ; preds = %12
%20 = load i8**, i8*** %4
%21 = load i8*, i8** %20
store i8* %21, i8** %2
br label %24
22: ; preds = %12
br label %7
23: ; preds = %7
store i8* null, i8** %2
br label %24
24: ; preds = %23, %19
%25 = load i8*, i8** %2
ret i8* %25
}

LLVM IR (-O2):
%struct.cl_rhash_iterator = type { i32 }
define i8* @cl_rhash_iterator_next(%struct.cl_rhash_iterator* %0) {
%2 = tail call i32 @cl_rhash_iterator_check(%struct.cl_rhash_iterator* %0)
br label %3
3: ; preds = %6, %1
%4 = tail call i32 @cl_rhash_iterator_done(%struct.cl_rhash_iterator* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = tail call i32 @cl_rhash_iterator_next_slot(%struct.cl_rhash_iterator* %0)
%8 = tail call i8** @cl_rhash_iterator_entry(%struct.cl_rhash_iterator* %0)
%9 = icmp eq i8** %8, null
br i1 %9, label %3, label %10
10: ; preds = %6
%11 = load i8*, i8** %8
br label %12
12: ; preds = %3, %10
%13 = phi i8* [ %11, %10 ], [ null, %3 ]
ret i8* %13
}