// File: /workspace/github_c_makefile_star2_O2/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, %rbx
movq %rdi, %r15
movq 0x1053c(%rip), %rdi     # 0x17678
callq 0x61eb
testq %rax, %rax
je 0x7236
movq %rax, %r14
movq %rbx, (%rsp)
andq $0x0, 0x8(%rax)
movq %rax, %r12
addq $0x10, %r12
movq 0x10(%rax), %rbx
movq %r12, %rbp
movq %rbx, %r13
cmpq %r12, %rbx
je 0x71bb
movq (%r13), %rbx
movq 0x8(%r13), %rax
cmpq %r15, %rax
jne 0x7196
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x5763
movq %r13, %rdi
movl $0x6ab, %esi            # imm = 0x6AB
callq 0x5b1a
jmp 0x7164
movq 0x8(%r14), %rcx
testq %rcx, %rcx
je 0x71b2
movq 0x8(%rax), %rdx
movb 0x19(%rdx), %dl
movq 0x8(%rcx), %rcx
movq %r13, %rbp
cmpb 0x19(%rcx), %dl
jbe 0x7164
movq %rax, 0x8(%r14)
movq %r13, %rbp
jmp 0x7164
movq 0x8(%r14), %rax
testq %rax, %rax
movq (%rsp), %rbx
je 0x7200
movq 0x8(%rax), %rax
movl 0x8(%rax), %edx
movq 0x8(%r15), %rcx
cmpl 0x8(%rcx), %edx
je 0x7236
movl (%rbx), %edi
movzbl 0x4(%rbx), %esi
movq 0x30(%rax), %rax
movl 0x34(%rax), %ecx
movl 0x20(%rax), %r8d
movq 0x8(%rax), %r9
subq $0x8, %rsp
pushq $0x0
pushq $0x0
pushq $0x41
callq 0x745c
addq $0x20, %rsp
movl (%rbx), %edi
movzbl 0x4(%rbx), %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 0x745c
addq $0x20, %rsp
cmpq $0x0, 0x8(%r14)
je 0x7245
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1042c(%rip), %rdi     # 0x17678
movq %rbx, %rsi
callq 0x628e
movq %r14, %rdi
movl $0x6ac, %esi            # imm = 0x6AC
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5b1a