// File: /workspace/github_c_makefile_star2_O3/open-mesh-mirror[P]batmand/hash.c
// Function: hash_iterate
struct hash_it_t *hash_iterate(struct hashtable_t *hash,
			       struct hash_it_t *iter_in)
{
	struct hash_it_t *iter;

	if (iter_in == NULL) {
		iter = debugMalloc(sizeof(struct hash_it_t), 301);
		iter->index =  -1;
		iter->bucket = NULL;
		iter->prev_bucket = NULL;
	} else {
		iter = iter_in;
	}

	/* sanity checks first (if our bucket got deleted in the last
	 * iteration): */
	if (iter->bucket != NULL) {
		if (iter->first_bucket != NULL) {

			/* we're on the first element and it got removed after
			 * the last iteration. */
			if ((*iter->first_bucket) != iter->bucket) {

				/* there are still other elements in the list */
				if ((*iter->first_bucket) != NULL) {
					iter->prev_bucket = NULL;
					iter->bucket = (*iter->first_bucket);
					iter->first_bucket = &hash->table[iter->index];
					return iter;
				} else {
					iter->bucket = NULL;
				}

			}

		} else if (iter->prev_bucket != NULL) {

			/* we're not on the first element, and the bucket got
			 * removed after the last iteration. The last bucket's
			 * next pointer is not pointing to our actual bucket
			 * anymore. Select the next. */
			if (iter->prev_bucket->next != iter->bucket)
				iter->bucket = iter->prev_bucket;

		}

	}

	/* now as we are sane, select the next one if there is some */
	if (iter->bucket != NULL) {
		if (iter->bucket->next != NULL) {
			iter->prev_bucket = iter->bucket;
			iter->bucket = iter->bucket->next;
			iter->first_bucket = NULL;
			return iter;
		}
	}
	/* if not returned yet, we've reached the last one on the index and
	 * have to search forward */

	iter->index++;
	/* go through the entries of the hash table */
	while (iter->index < hash->size) {

		if ((hash->table[iter->index]) == NULL) {
			iter->index++;
			continue;
		}

		iter->prev_bucket = NULL;
		iter->bucket = hash->table[iter->index];
		iter->first_bucket = &hash->table[iter->index];
		return iter;	/* if this table entry is not null, return it */
	}

	/* nothing to iterate over anymore */
	hash_iterate_free(iter);
	return NULL;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
testq %rsi, %rsi
je 0x679e
movq %rsi, %rax
leaq 0x8(%rsi), %rcx
movq 0x8(%rsi), %rdx
testq %rdx, %rdx
je 0x67c1
movq 0x18(%rax), %rsi
testq %rsi, %rsi
je 0x681f
movq (%rsi), %rdi
cmpq %rdx, %rdi
je 0x6839
testq %rdi, %rdi
je 0x6858
movq $0x0, 0x10(%rax)
movq (%rsi), %rcx
movq %rcx, 0x8(%rax)
movslq (%rax), %rcx
shlq $0x3, %rcx
addq (%rbx), %rcx
movq %rcx, 0x18(%rax)
jmp 0x6856
movl $0x20, %edi
movl $0x12d, %esi            # imm = 0x12D
callq 0x5d52
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movq %rax, %rcx
addq $0x8, %rcx
movslq (%rax), %rdx
movslq 0xc(%rbx), %rdi
leaq 0x1(%rdx), %r8
movq %rdx, %rsi
shlq $0x3, %rsi
cmpq %rdi, %r8
jge 0x680a
movq (%rbx), %r9
incl %edx
leaq 0x1(%r8), %r10
addq $0x8, %rsi
cmpq $0x0, (%r9,%r8,8)
movq %r10, %r8
je 0x67d3
addq %r9, %rsi
movl %edx, (%rax)
movq $0x0, 0x10(%rax)
movq -0x8(%r9,%r10,8), %rdx
movq %rdx, (%rcx)
movq %rsi, 0x18(%rax)
jmp 0x6856
incl %edx
movl %edx, (%rax)
movq %rax, %rdi
movl $0x518, %esi            # imm = 0x518
callq 0x628b
xorl %eax, %eax
jmp 0x6856
movq 0x10(%rax), %rdi
testq %rdi, %rdi
je 0x6839
movq 0x8(%rdi), %rsi
cmpq %rdx, %rsi
je 0x6839
movq %rdi, (%rcx)
movq %rdi, %rdx
jmp 0x683d
movq 0x8(%rdx), %rsi
testq %rsi, %rsi
je 0x67c1
movq %rdx, 0x10(%rax)
movq %rsi, 0x8(%rax)
movq $0x0, 0x18(%rax)
popq %rbx
retq
movq $0x0, (%rcx)
jmp 0x67c1