// File: /workspace/github_c_makefile_star2_O0/open-mesh-mirror[P]batmand/hna.c
// Function: hna_global_del
static void _hna_global_del(struct orig_node *orig_node, struct hna_element *hna_element)
{
	struct list_head *list_pos, *list_pos_tmp, *prev_list_head;
	struct hna_global_entry *hna_global_entry;
	struct hna_orig_ptr *hna_orig_ptr = NULL;

	hna_global_entry = ((struct hna_global_entry *)hash_find(hna_global_hash, hna_element));

	if (!hna_global_entry)
		return;

	hna_global_entry->curr_orig_node = NULL;

	prev_list_head = (struct list_head *)&hna_global_entry->orig_list;
	list_for_each_safe(list_pos, list_pos_tmp, &hna_global_entry->orig_list) {
		hna_orig_ptr = list_entry(list_pos, struct hna_orig_ptr, list);

		/* delete old entry in orig list */
		if (hna_orig_ptr->orig_node == orig_node) {
			list_del(prev_list_head, list_pos, &hna_global_entry->orig_list);
			debugFree(hna_orig_ptr, 1707);
			continue;
		}

		/* find best alternative route */
		if ((!hna_global_entry->curr_orig_node) ||
			(hna_orig_ptr->orig_node->router->tq_avg > hna_global_entry->curr_orig_node->router->tq_avg))
			hna_global_entry->curr_orig_node = hna_orig_ptr->orig_node;

		prev_list_head = &hna_orig_ptr->list;
	}

	/* set new route if available */
	if (hna_global_entry->curr_orig_node) {
		/**
		 * if we delete one orig node towards the HNA but we switch to an alternative
		 * which is reachable via the same next hop no routing table changes are necessary
		 */
		if (hna_global_entry->curr_orig_node->router->addr == orig_node->router->addr)
			return;

		add_del_route(hna_element->addr, hna_element->netmask, hna_global_entry->curr_orig_node->router->addr,
					hna_global_entry->curr_orig_node->router->if_incoming->addr.sin_addr.s_addr,
					hna_global_entry->curr_orig_node->router->if_incoming->if_index,
					hna_global_entry->curr_orig_node->router->if_incoming->dev,
					BATMAN_RT_TABLE_NETWORKS, ROUTE_TYPE_UNICAST, ROUTE_ADD);
	}

	add_del_route(hna_element->addr, hna_element->netmask, orig_node->router->addr,
				orig_node->router->if_incoming->addr.sin_addr.s_addr,
				orig_node->router->if_incoming->if_index,
				orig_node->router->if_incoming->dev,
				BATMAN_RT_TABLE_NETWORKS, ROUTE_TYPE_UNICAST, ROUTE_DEL);

	/* if no alternative route is available remove the HNA entry completely */
	if (!hna_global_entry->curr_orig_node) {
		hash_remove(hna_global_hash, hna_element);
		debugFree(hna_global_entry, 1708);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x38(%rbp)
movq 0x118a9(%rip), %rdi     # 0x1b718
movq -0x10(%rbp), %rsi
callq 0x83f0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x9e88
jmp 0xa09f
movq -0x30(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x30(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
addq $0x10, %rcx
cmpq %rcx, %rax
je 0x9f66
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
cmpq -0x8(%rbp), %rax
jne 0x9f07
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rdx
addq $0x10, %rdx
callq 0x6ed0
movq -0x38(%rbp), %rdi
movl $0x6ab, %esi            # imm = 0x6AB
callq 0x7720
jmp 0x9f4e
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x9f36
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movzbl 0x19(%rax), %eax
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq 0x8(%rcx), %rcx
movzbl 0x19(%rcx), %ecx
cmpl %ecx, %eax
jle 0x9f46
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x9eb7
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xa00e
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rcx
cmpl 0x8(%rcx), %eax
jne 0x9f96
jmp 0xa09f
movq -0x10(%rbp), %rax
movl (%rax), %edi
movq -0x10(%rbp), %rax
movb 0x4(%rax), %al
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq 0x8(%rcx), %rcx
movl 0x8(%rcx), %edx
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq 0x8(%rcx), %rcx
movq 0x30(%rcx), %rcx
movl 0x34(%rcx), %ecx
movq -0x30(%rbp), %rsi
movq 0x8(%rsi), %rsi
movq 0x8(%rsi), %rsi
movq 0x30(%rsi), %rsi
movl 0x20(%rsi), %r8d
movq -0x30(%rbp), %rsi
movq 0x8(%rsi), %rsi
movq 0x8(%rsi), %rsi
movq 0x30(%rsi), %rsi
movq 0x8(%rsi), %r9
xorl %esi, %esi
movzbl %al, %esi
movl $0x41, (%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0xa420
movq -0x10(%rbp), %rax
movl (%rax), %edi
movq -0x10(%rbp), %rax
movb 0x4(%rax), %al
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rcx
movl 0x8(%rcx), %edx
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq 0x30(%rcx), %rcx
movl 0x34(%rcx), %ecx
movq -0x8(%rbp), %rsi
movq 0x8(%rsi), %rsi
movq 0x30(%rsi), %rsi
movl 0x20(%rsi), %r8d
movq -0x8(%rbp), %rsi
movq 0x8(%rsi), %rsi
movq 0x30(%rsi), %rsi
movq 0x8(%rsi), %r9
xorl %esi, %esi
movzbl %al, %esi
movl $0x41, (%rsp)
movl $0x0, 0x8(%rsp)
movl $0x1, 0x10(%rsp)
callq 0xa420
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0xa09f
movq 0x11690(%rip), %rdi     # 0x1b718
movq -0x10(%rbp), %rsi
callq 0x8520
movq -0x30(%rbp), %rdi
movl $0x6ac, %esi            # imm = 0x6AC
callq 0x7720
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)