// File: /workspace/github_c_makefile_star2_O0/open-mesh-mirror[P]batmand/batman.c
// Function: generate_vis_packet
static void generate_vis_packet(void)
{
	struct hash_it_t *hashit = NULL;
	struct orig_node *orig_node;
	struct vis_data *vis_data;
	struct list_head *list_pos;
	struct batman_if *batman_if;

	if (vis_packet != NULL) {
		debugFree(vis_packet, 1102);
		vis_packet = NULL;
		vis_packet_size = 0;
	}

	vis_packet_size = sizeof(struct vis_packet);
	vis_packet = debugMalloc(vis_packet_size, 104);

	memcpy(&((struct vis_packet *)vis_packet)->sender_ip, (unsigned char *)&(((struct batman_if *)if_list.next)->addr.sin_addr.s_addr), 4);

	((struct vis_packet *)vis_packet)->version = VIS_COMPAT_VERSION;
	((struct vis_packet *)vis_packet)->gw_class = gateway_class;
	((struct vis_packet *)vis_packet)->tq_max = TQ_MAX_VALUE;

	/* neighbor list */
	while (NULL != (hashit = hash_iterate(orig_hash, hashit))) {

		orig_node = hashit->bucket->data;

		/* we interested in 1 hop neighbours only */
		if ((orig_node->router != NULL) && (orig_node->orig == orig_node->router->addr) &&
		    (orig_node->router->tq_avg > 0)) {

			vis_packet_size += sizeof(struct vis_data);

			vis_packet = debugRealloc(vis_packet, vis_packet_size, 105);

			vis_data = (struct vis_data *)(vis_packet + vis_packet_size - sizeof(struct vis_data));

			memcpy(&vis_data->ip, (unsigned char *)&orig_node->orig, 4);

			vis_data->data = orig_node->router->tq_avg;
			vis_data->type = DATA_TYPE_NEIGH;

		}

	}

	/* secondary interfaces */
	if (found_ifs > 1) {
		list_for_each(list_pos, &if_list) {
			batman_if = list_entry(list_pos, struct batman_if, list);

			if (((struct vis_packet *)vis_packet)->sender_ip == batman_if->addr.sin_addr.s_addr)
				continue;

			vis_packet_size += sizeof(struct vis_data);

			vis_packet = debugRealloc(vis_packet, vis_packet_size, 106);

			vis_data = (struct vis_data *)(vis_packet + vis_packet_size - sizeof(struct vis_data));

			memcpy(&vis_data->ip, (unsigned char *)&batman_if->addr.sin_addr.s_addr, 4);

			vis_data->data = 0;
			vis_data->type = DATA_TYPE_SEC_IF;
		}
	}

	/* hna announcements */
	vis_packet = hna_local_update_vis_packet(vis_packet, &vis_packet_size);

	if (vis_packet_size == sizeof(struct vis_packet)) {
		debugFree(vis_packet, 1107);
		vis_packet = NULL;
		vis_packet_size = 0;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq $0x0, -0x8(%rbp)
cmpq $0x0, 0x16ba8(%rip)     # 0x1b390
je 0x480f
movq 0x16b9f(%rip), %rdi     # 0x1b390
movl $0x44e, %esi            # imm = 0x44E
callq 0x7720
movq $0x0, 0x16b8a(%rip) # 0x1b390
movw $0x0, 0x16b89(%rip)     # 0x1b398
movw $0x7, 0x16b80(%rip)     # 0x1b398
movzwl 0x16b79(%rip), %edi     # 0x1b398
movl $0x68, %esi
callq 0x7220
movq %rax, 0x16b60(%rip)     # 0x1b390
movq 0x16b59(%rip), %rax     # 0x1b390
movq 0x16b72(%rip), %rcx     # 0x1b3b0
movl 0x34(%rcx), %ecx
movl %ecx, (%rax)
movq 0x16b46(%rip), %rax     # 0x1b390
movb $0x17, 0x4(%rax)
movb 0x16b05(%rip), %cl      # 0x1b359
movq 0x16b35(%rip), %rax     # 0x1b390
movb %cl, 0x5(%rax)
movq 0x16b2b(%rip), %rax     # 0x1b390
movb $-0x1, 0x6(%rax)
movq 0x16b60(%rip), %rdi     # 0x1b3d0
movq -0x8(%rbp), %rsi
callq 0x7fb0
movq %rax, %rcx
movq %rcx, -0x8(%rbp)
xorl %eax, %eax
cmpq %rcx, %rax
je 0x4949
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x4944
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
cmpl 0x8(%rcx), %eax
jne 0x4944
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movzbl 0x19(%rax), %eax
cmpl $0x0, %eax
jle 0x4944
movzwl 0x16ac0(%rip), %eax     # 0x1b398
addq $0x6, %rax
movw %ax, 0x16ab5(%rip)      # 0x1b398
movq 0x16aa6(%rip), %rdi     # 0x1b390
movzwl 0x16aa7(%rip), %esi     # 0x1b398
movl $0x69, %edx
callq 0x74c0
movq %rax, 0x16a8e(%rip)     # 0x1b390
movq 0x16a87(%rip), %rax     # 0x1b390
movzwl 0x16a88(%rip), %ecx     # 0x1b398
movslq %ecx, %rcx
addq %rcx, %rax
addq $-0x6, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, 0x2(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movb 0x19(%rax), %cl
movq -0x18(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x18(%rbp), %rax
movb $0x1, (%rax)
jmp 0x4869
movzbl 0x16a34(%rip), %eax     # 0x1b384
cmpl $0x1, %eax
jle 0x4a0d
movq 0x16a50(%rip), %rax     # 0x1b3b0
movq %rax, -0x20(%rbp)
leaq 0x16a45(%rip), %rax     # 0x1b3b0
cmpq %rax, -0x20(%rbp)
je 0x4a0b
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq 0x16a0c(%rip), %rax     # 0x1b390
movl (%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x34(%rcx), %eax
jne 0x4991
jmp 0x49fb
movzwl 0x16a00(%rip), %eax     # 0x1b398
addq $0x6, %rax
movw %ax, 0x169f5(%rip)      # 0x1b398
movq 0x169e6(%rip), %rdi     # 0x1b390
movzwl 0x169e7(%rip), %esi     # 0x1b398
movl $0x6a, %edx
callq 0x74c0
movq %rax, 0x169ce(%rip)     # 0x1b390
movq 0x169c7(%rip), %rax     # 0x1b390
movzwl 0x169c8(%rip), %ecx     # 0x1b398
movslq %ecx, %rcx
addq %rcx, %rax
addq $-0x6, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x28(%rbp), %rcx
movl 0x34(%rcx), %ecx
movl %ecx, 0x2(%rax)
movq -0x18(%rbp), %rax
movb $0x0, 0x1(%rax)
movq -0x18(%rbp), %rax
movb $0x2, (%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x4964
jmp 0x4a0d
movq 0x1697c(%rip), %rdi     # 0x1b390
leaq 0x1697d(%rip), %rsi     # 0x1b398
callq 0x93a0
movq %rax, 0x16969(%rip)     # 0x1b390
movzwl 0x1696a(%rip), %eax     # 0x1b398
cmpq $0x7, %rax
jne 0x4a59
movq 0x16955(%rip), %rdi     # 0x1b390
movl $0x453, %esi            # imm = 0x453
callq 0x7720
movq $0x0, 0x16940(%rip) # 0x1b390
movw $0x0, 0x1693f(%rip)     # 0x1b398
addq $0x30, %rsp
popq %rbp
retq
nop