// File: /workspace/github_c_makefile_star2_O0/open-mesh-mirror[P]batmand/batman.c
// Function: count_real_packets
static uint8_t count_real_packets(struct bat_packet *in, uint32_t neigh, struct batman_if *if_incoming)
{
	struct list_head *list_pos;
	struct orig_node *orig_node;
	struct neigh_node *tmp_neigh_node;
	uint8_t is_duplicate = 0;


	orig_node = get_orig_node( in->orig );

	/*char orig_str[ADDR_STR_LEN], neigh_str[ADDR_STR_LEN];

	addr_to_string( in->orig, orig_str, ADDR_STR_LEN );
	addr_to_string( neigh, neigh_str, ADDR_STR_LEN );

	debug_output( 3, "count_real_packets: orig = %s, neigh = %s, seq = %i, last seq = %i\n", orig_str, neigh_str, in->seqno, orig_node->last_real_seqno );*/

	list_for_each( list_pos, &orig_node->neigh_list ) {

		tmp_neigh_node = list_entry( list_pos, struct neigh_node, list );

		if ( !is_duplicate )
			is_duplicate = get_bit_status( tmp_neigh_node->real_bits, orig_node->last_real_seqno, in->seqno );

		if ( ( tmp_neigh_node->addr == neigh ) && ( tmp_neigh_node->if_incoming == if_incoming ) ) {

			bit_get_packet( tmp_neigh_node->real_bits, in->seqno - orig_node->last_real_seqno, 1 );
			/*debug_output( 3, "count_real_packets (yes): neigh = %s, is_new = %s, seq = %i, last seq = %i\n", neigh_str, ( is_new_seqno ? "YES" : "NO" ), in->seqno, orig_node->last_real_seqno );*/

		} else {

			bit_get_packet( tmp_neigh_node->real_bits, in->seqno - orig_node->last_real_seqno, 0 );
			/*debug_output( 3, "count_real_packets (no): neigh = %s, is_new = %s, seq = %i, last seq = %i\n", neigh_str, ( is_new_seqno ? "YES" : "NO" ), in->seqno, orig_node->last_real_seqno );*/

		}

		tmp_neigh_node->real_packet_count = bit_packet_count( tmp_neigh_node->real_bits );

	}

	if ( !is_duplicate ) {

		debug_output( 4, "updating last_seqno: old %d, new %d \n", orig_node->last_real_seqno, in->seqno );
		orig_node->last_real_seqno = in->seqno;

	}

	return is_duplicate;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movb $0x0, -0x31(%rbp)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x4c50
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
addq $0x48, %rcx
cmpq %rcx, %rax
je 0x4426
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpb $0x0, -0x31(%rbp)
jne 0x4399
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x28(%rbp), %rax
movw 0x42(%rax), %cx
movq -0x8(%rbp), %rax
movzwl %cx, %esi
movzwl 0x4(%rax), %edx
callq 0x7a70
movb %al, -0x31(%rbp)
movq -0x30(%rbp), %rax
movl 0x8(%rax), %eax
cmpl -0xc(%rbp), %eax
jne 0x43dc
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
cmpq -0x18(%rbp), %rax
jne 0x43dc
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x8(%rbp), %rax
movzwl 0x4(%rax), %eax
movq -0x28(%rbp), %rcx
movzwl 0x42(%rcx), %ecx
subl %ecx, %eax
movl $0x1, %edx
movswl %ax, %esi
callq 0x7c70
jmp 0x4400
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x8(%rbp), %rax
movzwl 0x4(%rax), %eax
movq -0x28(%rbp), %rcx
movzwl 0x42(%rcx), %ecx
subl %ecx, %eax
xorl %edx, %edx
movswl %ax, %esi
callq 0x7c70
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x7dc0
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0xc(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x4353
cmpb $0x0, -0x31(%rbp)
jne 0x445f
movq -0x28(%rbp), %rax
movzwl 0x42(%rax), %edx
movq -0x8(%rbp), %rax
movzwl 0x4(%rax), %ecx
movl $0x4, %edi
leaq 0x10b0b(%rip), %rsi     # 0x14f53
movb $0x0, %al
callq 0x123f0
movq -0x8(%rbp), %rax
movw 0x4(%rax), %cx
movq -0x28(%rbp), %rax
movw %cx, 0x42(%rax)
movb -0x31(%rbp), %al
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)