// File: /workspace/github_c_makefile_star2_O0/open-mesh-mirror[P]batmand/schedule.c
// Function: schedule_own_packet
void schedule_own_packet(struct batman_if *batman_if)
{
	struct forw_node *forw_node_new, *forw_packet_tmp = NULL;
	struct list_head *list_pos, *prev_list_head;
	struct hash_it_t *hashit = NULL;
	struct orig_node *orig_node;


	debug_output(4, "schedule_own_packet(): %s \n", batman_if->dev);

	forw_node_new = debugMalloc(sizeof(struct forw_node), 501);

	INIT_LIST_HEAD(&forw_node_new->list);

	forw_node_new->send_time = get_time_msec() + originator_interval - JITTER + rand_num(2 * JITTER);
	forw_node_new->if_incoming = batman_if;
	forw_node_new->own = 1;
	forw_node_new->num_packets = 0;
	forw_node_new->direct_link_flags = 0;

	/* non-primary interfaces do not send hna information */
	if ((num_hna_local > 0) && (batman_if->if_num == 0)) {

		forw_node_new->pack_buff = debugMalloc(MAX_AGGREGATION_BYTES, 502);
		memcpy(forw_node_new->pack_buff, (unsigned char *)&batman_if->out, sizeof(struct bat_packet));
		memcpy(forw_node_new->pack_buff + sizeof(struct bat_packet), hna_buff_local, num_hna_local * 5);
		forw_node_new->pack_buff_len = sizeof(struct bat_packet) + num_hna_local * 5;
		((struct bat_packet *)forw_node_new->pack_buff)->hna_len = num_hna_local;

	} else {

		forw_node_new->pack_buff = debugMalloc(MAX_AGGREGATION_BYTES, 503);
		memcpy(forw_node_new->pack_buff, &batman_if->out, sizeof(struct bat_packet));
		forw_node_new->pack_buff_len = sizeof(struct bat_packet);
		((struct bat_packet *)forw_node_new->pack_buff)->hna_len = 0;

	}

	/* change sequence number to network order */
	((struct bat_packet *)forw_node_new->pack_buff)->seqno = htons(((struct bat_packet *)forw_node_new->pack_buff)->seqno);

	prev_list_head = (struct list_head *)&forw_list;

	list_for_each(list_pos, &forw_list) {

		forw_packet_tmp = list_entry(list_pos, struct forw_node, list);

		if ((int)(forw_packet_tmp->send_time - forw_node_new->send_time) >= 0) {

			list_add_before(prev_list_head, list_pos, &forw_node_new->list);
			break;

		}

		prev_list_head = &forw_packet_tmp->list;
		forw_packet_tmp = NULL;

	}

	if (forw_packet_tmp == NULL)
		list_add_tail(&forw_node_new->list, &forw_list);

	batman_if->out.seqno++;


	while ( NULL != ( hashit = hash_iterate( orig_hash, hashit ) ) ) {

		orig_node = hashit->bucket->data;

		debug_output( 4, "count own bcast (schedule_own_packet): old = %i, ", orig_node->bcast_own_sum[batman_if->if_num] );
		bit_get_packet( (TYPE_OF_WORD *)&(orig_node->bcast_own[batman_if->if_num * num_words]), 1, 0 );
		orig_node->bcast_own_sum[batman_if->if_num] = bit_packet_count( (TYPE_OF_WORD *)&(orig_node->bcast_own[batman_if->if_num * num_words]) );
		debug_output( 4, "new = %i \n", orig_node->bcast_own_sum[batman_if->if_num] );

	}

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdx
movl $0x4, %edi
leaq 0xf3bb(%rip), %rsi      # 0x154ab
movb $0x0, %al
callq 0x123f0
movl $0x30, %edi
movl $0x1f5, %esi            # imm = 0x1F5
callq 0x7220
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
callq 0xf260
leaq 0x15181(%rip), %rcx     # 0x1b2a2
movswl (%rcx), %ecx
addl %ecx, %eax
subl $0x64, %eax
movl %eax, -0x3c(%rbp)
movl $0xc8, %edi
callq 0xfac0
movl -0x3c(%rbp), %ecx
addl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0xc(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x20(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x1c(%rax)
leaq 0x15558(%rip), %rax     # 0x1b6c8
movzbl (%rax), %eax
cmpl $0x0, %eax
jle 0x6229
movq -0x8(%rbp), %rax
movzbl 0x1c(%rax), %eax
cmpl $0x0, %eax
jne 0x6229
movl $0x200, %edi            # imm = 0x200
movl $0x1f6, %esi            # imm = 0x1F6
callq 0x7220
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x56(%rcx), %rdx
movq %rdx, (%rax)
movq 0x5e(%rcx), %rdx
movq %rdx, 0x8(%rax)
movw 0x66(%rcx), %cx
movw %cx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
addq $0x12, %rdi
leaq 0x154e3(%rip), %rax     # 0x1b6c0
movq (%rax), %rsi
leaq 0x154e1(%rip), %rax     # 0x1b6c8
movzbl (%rax), %eax
imull $0x5, %eax, %eax
movslq %eax, %rdx
callq 0x22c0
leaq 0x154cc(%rip), %rax     # 0x1b6c8
movzbl (%rax), %eax
imull $0x5, %eax, %eax
cltq
addq $0x12, %rax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x18(%rax)
leaq 0x154ae(%rip), %rax     # 0x1b6c8
movb (%rax), %cl
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movb %cl, 0x11(%rax)
jmp 0x627c
movl $0x200, %edi            # imm = 0x200
movl $0x1f7, %esi            # imm = 0x1F7
callq 0x7220
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x56(%rcx), %rdx
movq %rdx, (%rax)
movq 0x5e(%rcx), %rdx
movq %rdx, 0x8(%rax)
movw 0x66(%rcx), %cx
movw %cx, 0x10(%rax)
movq -0x10(%rbp), %rax
movw $0x12, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movb $0x0, 0x11(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movzwl 0x4(%rax), %edi
callq 0x2170
movw %ax, %cx
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movw %cx, 0x4(%rax)
leaq 0x15135(%rip), %rax     # 0x1b3d8
movq %rax, -0x28(%rbp)
leaq 0x1512a(%rip), %rax     # 0x1b3d8
movq (%rax), %rax
movq %rax, -0x20(%rbp)
leaq 0x1511c(%rip), %rax     # 0x1b3d8
cmpq %rax, -0x20(%rbp)
je 0x630d
movq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
subl 0x8(%rcx), %eax
cmpl $0x0, %eax
jl 0x62f0
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x6ea0
jmp 0x630d
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x62b5
cmpq $0x0, -0x18(%rbp)
jne 0x6324
movq -0x10(%rbp), %rdi
leaq 0x150b9(%rip), %rsi     # 0x1b3d8
callq 0x6e60
movq -0x8(%rbp), %rax
movw 0x5a(%rax), %cx
addw $0x1, %cx
movw %cx, 0x5a(%rax)
leaq 0x15095(%rip), %rax     # 0x1b3d0
movq (%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x7fb0
movq %rax, %rcx
movq %rcx, -0x30(%rbp)
xorl %eax, %eax
cmpq %rcx, %rax
je 0x642d
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x8(%rbp), %rcx
movzbl 0x1c(%rcx), %ecx
movzbl (%rax,%rcx), %edx
movl $0x4, %edi
leaq 0xf13f(%rip), %rsi      # 0x154c7
movb $0x0, %al
callq 0x123f0
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x8(%rbp), %rax
movzbl 0x1c(%rax), %eax
leaq 0x14f0a(%rip), %rcx     # 0x1b2b0
movzbl (%rcx), %ecx
imull %ecx, %eax
cltq
shlq $0x3, %rax
addq %rax, %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x7c70
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x8(%rbp), %rax
movzbl 0x1c(%rax), %eax
leaq 0x14ed8(%rip), %rcx     # 0x1b2b0
movzbl (%rcx), %ecx
imull %ecx, %eax
cltq
shlq $0x3, %rax
addq %rax, %rdi
callq 0x7dc0
movb %al, %dl
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x8(%rbp), %rcx
movzbl 0x1c(%rcx), %ecx
movb %dl, (%rax,%rcx)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x8(%rbp), %rcx
movzbl 0x1c(%rcx), %ecx
movzbl (%rax,%rcx), %edx
movl $0x4, %edi
leaq 0xe96d(%rip), %rsi      # 0x14d8e
movb $0x0, %al
callq 0x123f0
jmp 0x6334
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)