// File: /workspace/github_c_makefile_star2_O3/open-mesh-mirror[P]batmand/originator.c
// Function: debug_orig
void debug_orig(void) {

	struct hash_it_t *hashit = NULL;
	struct list_head *forw_pos, *orig_pos, *neigh_pos;
	struct forw_node *forw_node;
	struct orig_node *orig_node;
	struct neigh_node *neigh_node;
	struct gw_node *gw_node;
	uint16_t batman_count = 0;
	uint64_t uptime_sec;
	int download_speed, upload_speed, debug_out_size;
	char str[ADDR_STR_LEN], str2[ADDR_STR_LEN], orig_str[ADDR_STR_LEN], debug_out_str[1001];


	if ( debug_clients.clients_num[1] > 0 ) {

		addr_to_string( ((struct batman_if *)if_list.next)->addr.sin_addr.s_addr, orig_str, sizeof(orig_str) );
		uptime_sec = (uint64_t)(get_time_msec64() / 1000);

		debug_output(2, "BOD\n");
		debug_output(2, "%12s     (%s/%i) %15s [%10s], gw_class ... [B.A.T.M.A.N. %s, MainIF/IP: %s/%s, UT: %id%2ih%2im] \n", "Gateway", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF", SOURCE_VERSION, ((struct batman_if *)if_list.next)->dev, orig_str, (uint32_t)(uptime_sec/86400), (uint32_t)((uptime_sec%86400)/3600), (uint32_t)((uptime_sec%3600)/60));

		if ( list_empty( &gw_list ) ) {

			debug_output( 2, "No gateways in range ... \n" );

		} else {

			list_for_each( orig_pos, &gw_list ) {

				gw_node = list_entry( orig_pos, struct gw_node, list );

				if ( gw_node->deleted )
					continue;

				if (gw_node->orig_node->router == NULL)
					continue;

				addr_to_string( gw_node->orig_node->orig, str, sizeof (str) );
				addr_to_string( gw_node->orig_node->router->addr, str2, sizeof (str2) );

				get_gw_speeds( gw_node->orig_node->gwflags, &download_speed, &upload_speed );

				debug_output(2, "%s %-15s (%3i) %15s [%10s], gw_class %3i - %i%s/%i%s, gateway failures: %i \n", ( curr_gateway == gw_node ? "=>" : "  " ), str, gw_node->orig_node->router->tq_avg, str2, gw_node->orig_node->router->if_incoming->dev, gw_node->orig_node->gwflags, (download_speed > 2048 ? download_speed / 1024 : download_speed), (download_speed > 2048 ? "MBit" : "KBit"), (upload_speed > 2048 ? upload_speed / 1024 : upload_speed), (upload_speed > 2048 ? "MBit" : "KBit"), gw_node->gw_failure);

				batman_count++;

			}

			if ( batman_count == 0 )
				debug_output( 2, "No gateways in range ... \n" );

		}

		debug_output( 2, "EOD\n" );

	}

	if ( ( debug_clients.clients_num[0] > 0 ) || ( debug_clients.clients_num[3] > 0 ) ) {

		addr_to_string( ((struct batman_if *)if_list.next)->addr.sin_addr.s_addr, orig_str, sizeof(orig_str) );
		uptime_sec = (uint64_t)(get_time_msec64() / 1000);

		debug_output(1, "BOD \n");
		debug_output(1, "  %-11s (%s/%i) %15s [%10s]: %20s ... [B.A.T.M.A.N. %s, MainIF/IP: %s/%s, UT: %id%2ih%2im] \n", "Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF", "Potential nexthops", SOURCE_VERSION, ((struct batman_if *)if_list.next)->dev, orig_str, (uint32_t)(uptime_sec/86400), (uint32_t)((uptime_sec%86400)/3600), (uint32_t)((uptime_sec%3600)/60));

		if ( debug_clients.clients_num[3] > 0 ) {

			debug_output( 4, "------------------ DEBUG ------------------ \n" );
			debug_output( 4, "Forward list \n" );

			list_for_each( forw_pos, &forw_list ) {
				forw_node = list_entry( forw_pos, struct forw_node, list );
				addr_to_string( ((struct bat_packet *)forw_node->pack_buff)->orig, str, sizeof(str) );
				debug_output( 4, "    %s at %u \n", str, forw_node->send_time );
			}

			debug_output( 4, "Originator list \n" );
			debug_output( 4, "  %-11s (%s/%i) %15s [%10s]: %20s\n", "Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF", "Potential nexthops" );

		}

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

			orig_node = hashit->bucket->data;

			if ( orig_node->router == NULL )
				continue;

			batman_count++;

			addr_to_string( orig_node->orig, str, sizeof (str) );
			addr_to_string( orig_node->router->addr, str2, sizeof (str2) );

			debug_output( 1, "%-15s (%3i) %15s [%10s]:", str, orig_node->router->tq_avg, str2, orig_node->router->if_incoming->dev );
			debug_output( 4, "%15s (%3i) %15s [%10s], last_valid: %u: \n", str, orig_node->router->tq_avg, str2, orig_node->router->if_incoming->dev, orig_node->last_valid );

			debug_out_size = 0;

			list_for_each( neigh_pos, &orig_node->neigh_list ) {

				neigh_node = list_entry( neigh_pos, struct neigh_node, list );

				addr_to_string( neigh_node->addr, str, sizeof (str) );

				debug_out_size = debug_out_size + snprintf( ( debug_out_str + debug_out_size ), ( sizeof(debug_out_str) - 1 - debug_out_size ), " %15s (%3i)", str, neigh_node->tq_avg);

				if ( (unsigned int)(debug_out_size + 30) > sizeof(debug_out_str) - 1 ) {

					debug_output( 1, "%s \n", debug_out_str );
					debug_output( 4, "%s \n", debug_out_str );

					debug_out_size = 0;

				}

			}

			if (debug_out_size > 0) {
				debug_output( 1, "%s \n", debug_out_str );
				debug_output( 4, "%s \n", debug_out_str );
			}

		}

		if ( batman_count == 0 ) {

			debug_output( 1, "No batman nodes in range ... \n" );
			debug_output( 4, "No batman nodes in range ... \n" );

		}

		debug_output( 1, "EOD\n" );
		debug_output( 4, "---------------------------------------------- END DEBUG \n" );

	}

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x448, %rsp            # imm = 0x448
leaq 0x1272d(%rip), %rax     # 0x17348
movq 0x8(%rax), %rax
cmpw $0x0, 0x2(%rax)
movabsq $0x20c49ba5e353f7cf, %r14 # imm = 0x20C49BA5E353F7CF
movabsq $0x31b5d43afe99ef, %rdx # imm = 0x31B5D43AFE99EF
movabsq $0x308b91419ca253, %rcx # imm = 0x308B91419CA253
movabsq $0x91a2b3c4d5e6f9, %r13 # imm = 0x91A2B3C4D5E6F9
jle 0x4f0a
leaq 0x126b7(%rip), %r12     # 0x17310
movq (%r12), %rax
movl 0x34(%rax), %edi
leaq 0x20(%rsp), %rsi
movq %rdx, %rbx
movl $0x10, %edx
movq %rcx, %rbp
callq 0xbbac
callq 0xb46c
movq %rax, %r15
shrq $0x3, %rax
mulq %r14
movq %rdx, %r14
shrq $0x4, %r14
leaq 0xb56c(%rip), %rsi      # 0x101fe
movl $0x2, %edi
xorl %eax, %eax
callq 0xd88c
movq (%r12), %r11
shrq $0xa, %r15
movq %r15, %rax
mulq %rbx
movq %rdx, %r10
shrq $0x6, %r10
movq %r14, %rax
mulq %rbp
shrq $0x6, %rdx
imulq $0x15180, %rdx, %rax    # imm = 0x15180
movq %r14, %rcx
subq %rax, %rcx
imulq $0x123457, %rcx, %r15   # imm = 0x123457
shrq $0x20, %r15
movq %r14, %rax
mulq %r13
shrl $0x3, %edx
imull $0xe10, %edx, %eax      # imm = 0xE10
subl %eax, %r14d
imull $0x889, %r14d, %r14d    # imm = 0x889
shrl $0x11, %r14d
subq $0x8, %rsp
leaq 0xb585(%rip), %r12      # 0x10282
leaq 0xb573(%rip), %r13      # 0x10277
leaq 0xb4f8(%rip), %rsi      # 0x10203
leaq 0xb553(%rip), %rdx      # 0x10265
leaq 0xb554(%rip), %rcx      # 0x1026d
leaq 0xb54f(%rip), %r9       # 0x1026f
movl $0x2, %edi
movl $0xff, %r8d
movl $0x0, %eax
pushq %r14
pushq %r15
pushq %r10
leaq 0x40(%rsp), %r10
pushq %r10
pushq 0x8(%r11)
pushq %r12
pushq %r13
callq 0xd88c
addq $0x40, %rsp
leaq 0x125cb(%rip), %r14     # 0x17320
movq %r14, %rdi
callq 0x5bfb
testl %eax, %eax
setne %al
movq (%r14), %r12
cmpq %r14, %r12
sete %cl
orb %al, %cl
jne 0x4ead
xorl %ebx, %ebx
cmpl $0x0, 0x18(%r12)
jne 0x4e9b
movq 0x8(%r12), %rax
cmpq $0x0, 0x8(%rax)
je 0x4e9b
movl (%rax), %edi
leaq 0x10(%rsp), %rsi
movl $0x10, %edx
callq 0xbbac
movq 0x8(%r12), %rax
movq 0x8(%rax), %rax
movl 0x8(%rax), %edi
leaq 0x40(%rsp), %rsi
movl $0x10, %edx
callq 0xbbac
movq 0x8(%r12), %rax
movzbl 0x34(%rax), %edi
leaq 0xc(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x3006
leaq 0x124e4(%rip), %rax     # 0x172c0
cmpq %r12, (%rax)
leaq 0xd662(%rip), %rdx      # 0x12448
leaq 0xb50f(%rip), %rax      # 0x102fc
cmoveq %rax, %rdx
movq 0x8(%r12), %rax
movq 0x8(%rax), %rcx
movzbl 0x19(%rcx), %r8d
movq 0x30(%rcx), %rcx
movq %rcx, (%rsp)
movzbl 0x34(%rax), %eax
movq %rax, 0x38(%rsp)
movl 0xc(%rsp), %eax
movl %eax, %r15d
shrl $0xa, %r15d
movl $0x801, %ecx            # imm = 0x801
cmpl %ecx, %eax
cmovll %eax, %r15d
movl %ebx, %r10d
movq %r14, %r11
leaq 0xad50(%rip), %r13      # 0xfb83
movq %r13, %r14
leaq 0xad41(%rip), %rsi      # 0xfb7e
cmovgeq %rsi, %r14
movl 0x8(%rsp), %eax
movl %eax, %ebp
shrl $0xa, %ebp
cmpl %ecx, %eax
cmovll %eax, %ebp
cmovgeq %rsi, %r13
movzwl 0x12(%r12), %ebx
subq $0x8, %rsp
movl $0x2, %edi
leaq 0xb446(%rip), %rsi      # 0x102af
leaq 0x18(%rsp), %rcx
leaq 0x48(%rsp), %r9
xorl %eax, %eax
pushq %rbx
pushq %r13
pushq %rbp
pushq %r14
movq %r11, %r14
movl %r10d, %ebx
pushq %r15
pushq 0x68(%rsp)
movq 0x38(%rsp), %r10
pushq 0x8(%r10)
callq 0xd88c
addq $0x40, %rsp
incl %ebx
movq (%r12), %r12
cmpq %r14, %r12
jne 0x4d75
testw %bx, %bx
jne 0x4ec2
leaq 0xb3e0(%rip), %rsi      # 0x10294
xorl %ebx, %ebx
movl $0x2, %edi
xorl %eax, %eax
callq 0xd88c
leaq 0xe352(%rip), %rsi      # 0x1321b
movl $0x2, %edi
xorl %eax, %eax
callq 0xd88c
leaq 0x1246c(%rip), %rax     # 0x17348
movq 0x8(%rax), %rax
movabsq $0x91a2b3c4d5e6f9, %r13 # imm = 0x91A2B3C4D5E6F9
movabsq $0x308b91419ca253, %rcx # imm = 0x308B91419CA253
movabsq $0x31b5d43afe99ef, %rdx # imm = 0x31B5D43AFE99EF
movabsq $0x20c49ba5e353f7cf, %r14 # imm = 0x20C49BA5E353F7CF
jmp 0x4f0c
xorl %ebx, %ebx
cmpw $0x0, (%rax)
jg 0x4f1d
cmpw $0x0, 0x6(%rax)
jle 0x5324
movl %ebx, (%rsp)
leaq 0x123e9(%rip), %r12     # 0x17310
movq (%r12), %rax
movl 0x34(%rax), %edi
leaq 0x20(%rsp), %rsi
movq %rdx, %rbx
movl $0x10, %edx
movq %rcx, %rbp
callq 0xbbac
callq 0xb46c
movq %rax, %r15
shrq $0x3, %rax
mulq %r14
movq %rdx, %r14
shrq $0x4, %r14
leaq 0xb39f(%rip), %rsi      # 0x102ff
movl $0x1, %edi
xorl %eax, %eax
callq 0xd88c
movq (%r12), %r11
shrq $0xa, %r15
movq %r15, %rax
mulq %rbx
movq %rdx, %r10
shrq $0x6, %r10
movq %r14, %rax
mulq %rbp
shrq $0x6, %rdx
imulq $0x15180, %rdx, %rax    # imm = 0x15180
movq %r14, %rcx
subq %rax, %rcx
movq %r13, %rdx
imulq $0x123457, %rcx, %r13   # imm = 0x123457
shrq $0x20, %r13
movq %r14, %rax
mulq %rdx
shrl $0x3, %edx
imull $0xe10, %edx, %eax      # imm = 0xE10
subl %eax, %r14d
imull $0x889, %r14d, %r14d    # imm = 0x889
shrl $0x11, %r14d
leaq 0xb2b8(%rip), %rbp      # 0x10282
leaq 0xb39c(%rip), %r12      # 0x1036d
leaq 0xb29f(%rip), %r15      # 0x10277
leaq 0xb326(%rip), %rsi      # 0x10305
leaq 0xb37c(%rip), %rdx      # 0x10362
leaq 0xb280(%rip), %rcx      # 0x1026d
leaq 0xb27b(%rip), %r9       # 0x1026f
movl $0x1, %edi
movl $0xff, %r8d
movl $0x0, %eax
pushq %r14
pushq %r13
pushq %r10
leaq 0x38(%rsp), %r10
pushq %r10
pushq 0x8(%r11)
pushq %rbp
pushq %r12
pushq %r15
callq 0xd88c
addq $0x40, %rsp
leaq 0x1231e(%rip), %rax     # 0x17348
movq 0x8(%rax), %rax
cmpw $0x0, 0x6(%rax)
jle 0x50f6
leaq 0xb340(%rip), %rsi      # 0x10380
movl $0x4, %edi
xorl %eax, %eax
callq 0xd88c
leaq 0xb35b(%rip), %rsi      # 0x103ae
movl $0x4, %edi
xorl %eax, %eax
callq 0xd88c
leaq 0x122d2(%rip), %r13     # 0x17338
movq (%r13), %rbp
cmpq %r13, %rbp
je 0x50ad
leaq 0x10(%rsp), %rbx
leaq 0xb342(%rip), %r14      # 0x103bd
movq 0x10(%rbp), %rax
movl 0x8(%rax), %edi
movq %rbx, %rsi
movl $0x10, %edx
callq 0xbbac
movl 0x8(%rbp), %ecx
movl $0x4, %edi
movq %r14, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0xd88c
movq (%rbp), %rbp
cmpq %r13, %rbp
jne 0x507b
leaq 0xb318(%rip), %rsi      # 0x103cc
movl $0x4, %edi
xorl %eax, %eax
callq 0xd88c
leaq 0xb317(%rip), %rsi      # 0x103de
leaq 0xb294(%rip), %rdx      # 0x10362
leaq 0xb198(%rip), %rcx      # 0x1026d
leaq 0xb193(%rip), %r9       # 0x1026f
movl $0x4, %edi
movl $0xff, %r8d
xorl %eax, %eax
pushq %r12
pushq %r15
callq 0xd88c
addq $0x10, %rsp
leaq 0x12233(%rip), %r15     # 0x17330
leaq 0x10(%rsp), %rbx
xorl %r12d, %r12d
movl (%rsp), %r14d
movq (%r15), %rdi
movq %r12, %rsi
callq 0x6741
testq %rax, %rax
je 0x52d3
movq %rax, %r12
movq 0x8(%rax), %rax
movq (%rax), %r13
cmpq $0x0, 0x8(%r13)
je 0x5109
incl %r14d
movl (%r13), %edi
movq %rbx, %rsi
movl $0x10, %edx
callq 0xbbac
movq 0x8(%r13), %rax
movl 0x8(%rax), %edi
leaq 0x40(%rsp), %rbp
movq %rbp, %rsi
movl $0x10, %edx
callq 0xbbac
movq 0x8(%r13), %rax
movzbl 0x19(%rax), %ecx
movq 0x30(%rax), %rax
movq 0x8(%rax), %r9
movl $0x1, %edi
leaq 0xb28a(%rip), %rsi      # 0x10401
movq %rbx, %rdx
movq %rbp, %r8
xorl %eax, %eax
callq 0xd88c
movq 0x8(%r13), %rax
movzbl 0x19(%rax), %ecx
movq 0x30(%rax), %rax
movq 0x8(%rax), %r9
movl 0x30(%r13), %r10d
subq $0x8, %rsp
movl $0x4, %edi
leaq 0xb272(%rip), %rsi      # 0x1041a
movq %rbx, %rdx
movq %rbp, %r8
xorl %eax, %eax
pushq %r10
callq 0xd88c
addq $0x10, %rsp
movq 0x48(%r13), %rbp
addq $0x48, %r13
cmpq %r13, %rbp
je 0x5109
movl %r14d, (%rsp)
xorl %r15d, %r15d
movl 0x8(%rbp), %edi
movq %rbx, %rsi
movl $0x10, %edx
callq 0xbbac
movslq %r15d, %r14
leaq (%rsp,%r14), %rdi
addq $0x50, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
subq %r14, %rsi
movzbl 0x19(%rbp), %r8d
leaq 0xb242(%rip), %rdx      # 0x10444
movq %rbx, %rcx
xorl %eax, %eax
callq 0x21a0
leal (%rax,%r14), %ecx
addl $0xfffffc35, %ecx       # imm = 0xFFFFFC35
cmpl $0xfffffc17, %ecx       # imm = 0xFFFFFC17
jae 0x5265
xorl %r15d, %r15d
movl $0x1, %edi
leaq 0xd0c1(%rip), %r14      # 0x122ee
movq %r14, %rsi
leaq 0x50(%rsp), %rbx
movq %rbx, %rdx
xorl %eax, %eax
callq 0xd88c
movl $0x4, %edi
movq %r14, %rsi
movq %rbx, %rdx
leaq 0x10(%rsp), %rbx
xorl %eax, %eax
callq 0xd88c
movq (%rbp), %rbp
cmpq %r13, %rbp
jne 0x51d3
jmp 0x52c3
addl %eax, %r15d
movq (%rbp), %rbp
cmpq %r13, %rbp
jne 0x51d3
testl %r15d, %r15d
movl (%rsp), %r14d
leaq 0x120ad(%rip), %r15     # 0x17330
jle 0x5109
movl $0x1, %edi
leaq 0xd059(%rip), %r13      # 0x122ee
movq %r13, %rsi
leaq 0x50(%rsp), %rbx
movq %rbx, %rdx
xorl %eax, %eax
callq 0xd88c
movl $0x4, %edi
movq %r13, %rsi
movq %rbx, %rdx
leaq 0x10(%rsp), %rbx
xorl %eax, %eax
callq 0xd88c
jmp 0x5109
movl (%rsp), %r14d
leaq 0x12062(%rip), %r15     # 0x17330
jmp 0x5109
testw %r14w, %r14w
jne 0x52fe
leaq 0xb170(%rip), %rbx      # 0x10450
movl $0x1, %edi
movq %rbx, %rsi
xorl %eax, %eax
callq 0xd88c
movl $0x4, %edi
movq %rbx, %rsi
xorl %eax, %eax
callq 0xd88c
leaq 0xdf16(%rip), %rsi      # 0x1321b
movl $0x1, %edi
xorl %eax, %eax
callq 0xd88c
leaq 0xb157(%rip), %rsi      # 0x1046f
movl $0x4, %edi
xorl %eax, %eax
callq 0xd88c
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop