// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r13
movq %rdi, %r15
movq 0xfce3(%rip), %rdi      # 0x17678
callq 0x69d3
testq %rax, %rax
je 0x7a9e
movq %rax, %r14
movq $0x0, 0x8(%rax)
movq %rax, %r12
addq $0x10, %r12
movq 0x10(%rax), %rbx
cmpq %r12, %rbx
je 0x7a65
movq %r13, (%rsp)
movq %r12, %rbp
movq %rbx, %r13
movq (%rbx), %rbx
movq 0x8(%r13), %rax
cmpq %r15, %rax
je 0x79f7
movq 0x8(%r14), %rcx
testq %rcx, %rcx
je 0x79f1
movq 0x8(%rax), %rdx
movb 0x19(%rdx), %dl
movq 0x8(%rcx), %rcx
cmpb 0x19(%rcx), %dl
jbe 0x7a15
movq %rax, 0x8(%r14)
jmp 0x7a15
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x5be3
movq %r13, %rdi
movl $0x6ab, %esi            # imm = 0x6AB
callq 0x628b
movq %rbp, %r13
movq %r13, %rbp
cmpq %r12, %rbx
jne 0x79c9
movq 0x8(%r14), %rax
testq %rax, %rax
movq (%rsp), %r13
je 0x7a65
movq 0x8(%rax), %rax
movl 0x8(%rax), %edx
movq 0x8(%r15), %rcx
cmpl 0x8(%rcx), %edx
je 0x7a9e
movl (%r13), %edi
movzbl 0x4(%r13), %esi
movq 0x30(%rax), %rax
movl 0x34(%rax), %ecx
movl 0x20(%rax), %r8d
movq 0x8(%rax), %r9
subq $0x8, %rsp
xorl %eax, %eax
pushq %rax
pushq %rax
pushq $0x41
callq 0x7cd4
addq $0x20, %rsp
movl (%r13), %edi
movzbl 0x4(%r13), %esi
movq 0x8(%r15), %rax
movl 0x8(%rax), %edx
movq 0x30(%rax), %rax
movl 0x34(%rax), %ecx
movl 0x20(%rax), %r8d
movq 0x8(%rax), %r9
subq $0x8, %rsp
pushq $0x1
pushq $0x0
pushq $0x41
callq 0x7cd4
addq $0x20, %rsp
cmpq $0x0, 0x8(%r14)
je 0x7aad
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xfbc4(%rip), %rdi      # 0x17678
movq %r13, %rsi
callq 0x6a72
movq %r14, %rdi
movl $0x6ac, %esi            # imm = 0x6AC
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x628b