// File: /workspace/github_c_makefile_star2_O0/open-mesh-mirror[P]batmand/hna.c
// Function: hna_global_add
void hna_global_add(struct orig_node *orig_node, unsigned char *new_hna, int16_t new_hna_len)
{
	struct hna_element *e, *buff;
	int i, num_elements;
	char hna_str[ADDR_STR_LEN];

	if ((new_hna == NULL) || (new_hna_len == 0)) {
		orig_node->hna_buff = NULL;
		orig_node->hna_buff_len = 0;
		return;
	}

	orig_node->hna_buff = debugMalloc(new_hna_len, 705);
	orig_node->hna_buff_len = new_hna_len;
	memcpy(orig_node->hna_buff, new_hna, new_hna_len);

	/* add new routes */
	num_elements = orig_node->hna_buff_len / sizeof(struct hna_element);
	buff = (struct hna_element *)orig_node->hna_buff;

	debug_output(4, "HNA information received (%i HNA network%s): \n", num_elements, (num_elements > 1 ? "s": ""));

	for (i = 0; i < num_elements; i++) {
		e = &buff[i];
		addr_to_string(e->addr, hna_str, sizeof(hna_str));

		if ((e->netmask > 0 ) && (e->netmask < 33))
			debug_output(4, "hna: %s/%i\n", hna_str, e->netmask);
		else
			debug_output(4, "hna: %s/%i -> ignoring (invalid netmask) \n", hna_str, e->netmask);

		if ((e->netmask > 0) && (e->netmask <= 32))
			_hna_global_add(orig_node, e);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movw %dx, %ax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movw %ax, -0x12(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x9497
movswl -0x12(%rbp), %eax
cmpl $0x0, %eax
jne 0x94b2
movq -0x8(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x8(%rbp), %rax
movw $0x0, 0x40(%rax)
jmp 0x9608
movswl -0x12(%rbp), %edi
movl $0x2c1, %esi            # imm = 0x2C1
callq 0x7220
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x38(%rax)
movw -0x12(%rbp), %cx
movq -0x8(%rbp), %rax
movw %cx, 0x40(%rax)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x10(%rbp), %rsi
movswq -0x12(%rbp), %rdx
callq 0x22c0
movq -0x8(%rbp), %rax
movswq 0x40(%rax), %rax
movl $0x5, %ecx
xorl %edx, %edx
divq %rcx
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x28(%rbp)
movl -0x30(%rbp), %edx
movl -0x30(%rbp), %esi
leaq 0xd6e4(%rip), %rcx      # 0x16c00
leaq 0xebf1(%rip), %rax      # 0x18114
cmpl $0x1, %esi
cmovgq %rax, %rcx
movl $0x4, %edi
leaq 0xc853(%rip), %rsi      # 0x15d89
movb $0x0, %al
callq 0x123f0
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x9608
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x5, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %edi
leaq -0x40(%rbp), %rsi
movl $0x10, %edx
callq 0xfa90
movq -0x20(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x0, %eax
jle 0x95b2
movq -0x20(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x21, %eax
jge 0x95b2
leaq -0x40(%rbp), %rdx
movq -0x20(%rbp), %rax
movzbl 0x4(%rax), %ecx
movl $0x4, %edi
leaq 0xc80f(%rip), %rsi      # 0x15db8
movb $0x0, %al
callq 0x123f0
jmp 0x95d1
leaq -0x40(%rbp), %rdx
movq -0x20(%rbp), %rax
movzbl 0x4(%rax), %ecx
movl $0x4, %edi
leaq 0xc7fa(%rip), %rsi      # 0x15dc4
movb $0x0, %al
callq 0x123f0
movq -0x20(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x0, %eax
jle 0x95f8
movq -0x20(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x20, %eax
jg 0x95f8
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x9610
jmp 0x95fa
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x9544
addq $0x40, %rsp
popq %rbp
retq
nop