// File: /workspace/github_c_makefile_star2_O1/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 0x12745(%rip), %r8      # 0x17348
movq 0x8(%r8), %rax
cmpw $0x0, 0x2(%rax)
movabsq $0x20c49ba5e353f7cf, %r14 # imm = 0x20C49BA5E353F7CF
movabsq $0x31b5d43afe99ef, %rdi # imm = 0x31B5D43AFE99EF
movabsq $0x308b91419ca253, %r12 # imm = 0x308B91419CA253
movabsq $0x123456789abce0, %rbx # imm = 0x123456789ABCE0
movabsq $0x444444444444445, %r13 # imm = 0x444444444444445
jle 0x4d84
leaq 0x126c5(%rip), %r12     # 0x17310
movq (%r12), %rax
movq %rdi, %r13
movl 0x34(%rax), %edi
leaq 0x30(%rsp), %rsi
movl $0x10, %edx
callq 0xb8b8
callq 0xb178
movq %rax, %r15
shrq $0x3, %rax
mulq %r14
movq %rdx, %r14
shrq $0x4, %r14
leaq 0xb57d(%rip), %rsi      # 0x101fe
xorl %ebp, %ebp
movl $0x2, %edi
xorl %eax, %eax
callq 0xd5b0
movq (%r12), %r12
shrq $0xa, %r15
movq %r15, %rax
mulq %r13
movq %rdx, %r10
shrq $0x6, %r10
movq %r14, %rax
movabsq $0x308b91419ca253, %rcx # imm = 0x308B91419CA253
mulq %rcx
shrq $0x6, %rdx
imulq $0x15180, %rdx, %rcx    # imm = 0x15180
movq %r14, %rax
subq %rcx, %rax
mulq %rbx
movq %rdx, %r11
movq %r14, %rax
movabsq $0x91a2b3c4d5e6f9, %rcx # imm = 0x91A2B3C4D5E6F9
mulq %rcx
shrq $0x3, %rdx
imulq $0xe10, %rdx, %rax      # imm = 0xE10
subq %rax, %r14
movq %r14, %rax
movabsq $0x444444444444445, %rcx # imm = 0x444444444444445
mulq %rcx
movq %rdx, %r14
subq $0x8, %rsp
leaq 0xb57b(%rip), %r15      # 0x10282
leaq 0xb569(%rip), %r13      # 0x10277
leaq 0xb4ee(%rip), %rsi      # 0x10203
leaq 0xb549(%rip), %rdx      # 0x10265
leaq 0xb54a(%rip), %rcx      # 0x1026d
leaq 0xb545(%rip), %r9       # 0x1026f
movl $0x2, %edi
movl $0xff, %r8d
movl $0x0, %eax
pushq %r14
pushq %r11
pushq %r10
leaq 0x50(%rsp), %r10
pushq %r10
pushq 0x8(%r12)
pushq %r15
pushq %r13
callq 0xd5b0
addq $0x40, %rsp
leaq 0x125c0(%rip), %rbx     # 0x17320
movq %rbx, %rdi
callq 0x5be7
testl %eax, %eax
je 0x4d8b
leaq 0xb521(%rip), %rsi      # 0x10294
movl $0x2, %edi
xorl %eax, %eax
callq 0xd5b0
jmp 0x4ecc
xorl %ebp, %ebp
jmp 0x4f18
movq (%rbx), %r13
xorl %ebp, %ebp
cmpq %rbx, %r13
je 0x4ec3
cmpl $0x0, 0x18(%r13)
jne 0x4eba
movq 0x8(%r13), %rax
cmpq $0x0, 0x8(%rax)
je 0x4eba
movl (%rax), %edi
leaq 0x20(%rsp), %rsi
movl $0x10, %edx
callq 0xb8b8
movq 0x8(%r13), %rax
movq 0x8(%rax), %rax
movl 0x8(%rax), %edi
leaq 0x40(%rsp), %rsi
movl $0x10, %edx
callq 0xb8b8
movq 0x8(%r13), %rax
movzbl 0x34(%rax), %edi
leaq 0x1c(%rsp), %rsi
leaq 0x18(%rsp), %rdx
callq 0x2ffe
leaq 0x124c4(%rip), %rax     # 0x172c0
cmpq %r13, (%rax)
leaq 0xd59e(%rip), %rdx      # 0x123a4
leaq 0xb4ef(%rip), %rax      # 0x102fc
cmoveq %rax, %rdx
movq 0x8(%r13), %rax
movq 0x8(%rax), %rcx
movzbl 0x19(%rcx), %r8d
movq 0x30(%rcx), %rcx
movq %rcx, 0x8(%rsp)
movzbl 0x34(%rax), %eax
movq %rax, 0x10(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, %r15d
shrl $0xa, %r15d
movl $0x801, %ecx            # imm = 0x801
cmpl %ecx, %eax
cmovll %eax, %r15d
leaq 0xad36(%rip), %r12      # 0xfb83
movq %r12, %r14
leaq 0xad27(%rip), %rsi      # 0xfb7e
cmovgeq %rsi, %r14
movl 0x18(%rsp), %eax
movl %ebp, %r10d
movl %eax, %ebp
shrl $0xa, %ebp
cmpl %ecx, %eax
cmovll %eax, %ebp
cmovgeq %rsi, %r12
movq %rbx, %r11
movzwl 0x12(%r13), %ebx
subq $0x8, %rsp
movl $0x2, %edi
leaq 0xb427(%rip), %rsi      # 0x102af
leaq 0x28(%rsp), %rcx
leaq 0x48(%rsp), %r9
xorl %eax, %eax
pushq %rbx
movq %r11, %rbx
pushq %r12
pushq %rbp
movl %r10d, %ebp
pushq %r14
pushq %r15
pushq 0x40(%rsp)
movq 0x40(%rsp), %r10
pushq 0x8(%r10)
callq 0xd5b0
addq $0x40, %rsp
incl %ebp
movq (%r13), %r13
jmp 0x4d90
testw %bp, %bp
je 0x4d6c
leaq 0xe288(%rip), %rsi      # 0x1315b
movl $0x2, %edi
xorl %eax, %eax
callq 0xd5b0
leaq 0x12462(%rip), %r8      # 0x17348
movabsq $0x444444444444445, %r13 # imm = 0x444444444444445
movabsq $0x123456789abce0, %rbx # imm = 0x123456789ABCE0
movabsq $0x308b91419ca253, %r12 # imm = 0x308B91419CA253
movabsq $0x31b5d43afe99ef, %rdi # imm = 0x31B5D43AFE99EF
movabsq $0x20c49ba5e353f7cf, %r14 # imm = 0x20C49BA5E353F7CF
movq 0x8(%r8), %rax
cmpw $0x0, (%rax)
jg 0x4f2d
cmpw $0x0, 0x6(%rax)
jle 0x5328
movl %ebp, 0x8(%rsp)
leaq 0x123d8(%rip), %rax     # 0x17310
movq (%rax), %rax
movq %rdi, %rbp
movl 0x34(%rax), %edi
leaq 0x30(%rsp), %rsi
movl $0x10, %edx
callq 0xb8b8
callq 0xb178
movq %rax, %r15
shrq $0x3, %rax
mulq %r14
movq %rdx, %r14
shrq $0x4, %r14
leaq 0xb392(%rip), %rsi      # 0x102ff
movl $0x1, %edi
xorl %eax, %eax
callq 0xd5b0
leaq 0x12390(%rip), %rax     # 0x17310
movq (%rax), %rax
movq %rax, 0x10(%rsp)
shrq $0xa, %r15
movq %r15, %rax
mulq %rbp
movq %rdx, %r10
shrq $0x6, %r10
movq %r14, %rax
mulq %r12
shrq $0x6, %rdx
imulq $0x15180, %rdx, %rcx    # imm = 0x15180
movq %r14, %rax
subq %rcx, %rax
mulq %rbx
movq %rdx, %r11
movq %r14, %rax
movabsq $0x91a2b3c4d5e6f9, %rcx # imm = 0x91A2B3C4D5E6F9
mulq %rcx
shrq $0x3, %rdx
imulq $0xe10, %rdx, %rax      # imm = 0xE10
subq %rax, %r14
movq %r14, %rax
mulq %r13
movq %rdx, %r14
leaq 0xb29e(%rip), %rbp      # 0x10282
leaq 0xb382(%rip), %r15      # 0x1036d
leaq 0xb285(%rip), %r13      # 0x10277
leaq 0xb30c(%rip), %rsi      # 0x10305
leaq 0xb362(%rip), %rdx      # 0x10362
leaq 0xb266(%rip), %rcx      # 0x1026d
leaq 0xb261(%rip), %r9       # 0x1026f
movl $0x1, %edi
movl $0xff, %r8d
movl $0x0, %eax
pushq %r14
pushq %r11
pushq %r10
leaq 0x48(%rsp), %r10
pushq %r10
movq 0x30(%rsp), %r10
pushq 0x8(%r10)
pushq %rbp
pushq %r15
pushq %r13
callq 0xd5b0
addq $0x40, %rsp
leaq 0x122ff(%rip), %rax     # 0x17348
movq 0x8(%rax), %rax
cmpw $0x0, 0x6(%rax)
jle 0x5115
leaq 0xb321(%rip), %rsi      # 0x10380
movl $0x4, %edi
xorl %eax, %eax
callq 0xd5b0
leaq 0xb33c(%rip), %rsi      # 0x103ae
movl $0x4, %edi
xorl %eax, %eax
callq 0xd5b0
leaq 0x122b3(%rip), %r12     # 0x17338
movq (%r12), %rbp
cmpq %r12, %rbp
je 0x50cc
leaq 0x20(%rsp), %rbx
leaq 0xb323(%rip), %r14      # 0x103bd
movq 0x10(%rbp), %rax
movl 0x8(%rax), %edi
movq %rbx, %rsi
movl $0x10, %edx
callq 0xb8b8
movl 0x8(%rbp), %ecx
movl $0x4, %edi
movq %r14, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0xd5b0
movq (%rbp), %rbp
cmpq %r12, %rbp
jne 0x509a
leaq 0xb2f9(%rip), %rsi      # 0x103cc
movl $0x4, %edi
xorl %eax, %eax
callq 0xd5b0
leaq 0xb2f8(%rip), %rsi      # 0x103de
leaq 0xb275(%rip), %rdx      # 0x10362
leaq 0xb179(%rip), %rcx      # 0x1026d
leaq 0xb174(%rip), %r9       # 0x1026f
movl $0x4, %edi
movl $0xff, %r8d
xorl %eax, %eax
pushq %r15
pushq %r13
callq 0xd5b0
addq $0x10, %rsp
leaq 0x12214(%rip), %r14     # 0x17330
leaq 0x20(%rsp), %rbx
leaq 0x40(%rsp), %r15
xorl %r12d, %r12d
movl 0x8(%rsp), %ebp
movq (%r14), %rdi
movq %r12, %rsi
callq 0x6416
testq %rax, %rax
je 0x52d8
movq %rax, %r12
movq 0x8(%rax), %rax
movq (%rax), %r13
cmpq $0x0, 0x8(%r13)
je 0x512d
incl %ebp
movl %ebp, 0x8(%rsp)
movl (%r13), %edi
movq %rbx, %rsi
movl $0x10, %edx
callq 0xb8b8
movq 0x8(%r13), %rax
movl 0x8(%rax), %edi
movq %r15, %rsi
movl $0x10, %edx
callq 0xb8b8
movq 0x8(%r13), %rax
movzbl 0x19(%rax), %ecx
movq 0x30(%rax), %rax
movq 0x8(%rax), %r9
movl $0x1, %edi
leaq 0xb268(%rip), %rsi      # 0x10401
movq %rbx, %rdx
movq %r15, %r8
xorl %eax, %eax
callq 0xd5b0
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 0xb250(%rip), %rsi      # 0x1041a
movq %rbx, %rdx
movq %r15, %r8
xorl %eax, %eax
pushq %r10
callq 0xd5b0
addq $0x10, %rsp
movq 0x48(%r13), %rbp
addq $0x48, %r13
cmpq %r13, %rbp
je 0x5129
xorl %r15d, %r15d
movl 0x8(%rbp), %edi
movq %rbx, %rsi
movl $0x10, %edx
callq 0xb8b8
movslq %r15d, %r14
leaq (%rsp,%r14), %rdi
addq $0x50, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
subq %r14, %rsi
movzbl 0x19(%rbp), %r8d
leaq 0xb224(%rip), %rdx      # 0x10444
movq %rbx, %rcx
xorl %eax, %eax
callq 0x21a0
leal (%rax,%r14), %ecx
addl $0xfffffc35, %ecx       # imm = 0xFFFFFC35
cmpl $0xfffffc16, %ecx       # imm = 0xFFFFFC16
ja 0x5276
xorl %r15d, %r15d
movl $0x1, %edi
leaq 0xcfff(%rip), %r14      # 0x1224a
movq %r14, %rsi
leaq 0x50(%rsp), %rbx
movq %rbx, %rdx
xorl %eax, %eax
callq 0xd5b0
movl $0x4, %edi
movq %r14, %rsi
movq %rbx, %rdx
leaq 0x20(%rsp), %rbx
xorl %eax, %eax
callq 0xd5b0
jmp 0x527c
addl %r15d, %eax
movl %eax, %r15d
movq (%rbp), %rbp
cmpq %r13, %rbp
jne 0x51f1
testl %r15d, %r15d
leaq 0x1209d(%rip), %r14     # 0x17330
leaq 0x40(%rsp), %r15
jle 0x5129
movl $0x1, %edi
leaq 0xcfa0(%rip), %r13      # 0x1224a
movq %r13, %rsi
leaq 0x50(%rsp), %rbx
movq %rbx, %rdx
xorl %eax, %eax
callq 0xd5b0
movl $0x4, %edi
movq %r13, %rsi
movq %rbx, %rdx
leaq 0x20(%rsp), %rbx
xorl %eax, %eax
callq 0xd5b0
jmp 0x5129
testw %bp, %bp
jne 0x5302
leaq 0xb16c(%rip), %rbx      # 0x10450
movl $0x1, %edi
movq %rbx, %rsi
xorl %eax, %eax
callq 0xd5b0
movl $0x4, %edi
movq %rbx, %rsi
xorl %eax, %eax
callq 0xd5b0
leaq 0xde52(%rip), %rsi      # 0x1315b
movl $0x1, %edi
xorl %eax, %eax
callq 0xd5b0
leaq 0xb153(%rip), %rsi      # 0x1046f
movl $0x4, %edi
xorl %eax, %eax
callq 0xd5b0
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop