// File: /workspace/github_c_makefile_star2_O3/open-mesh-mirror[P]batmand/posix/unix_socket.c
// Function: debug_output
void debug_output(int8_t debug_prio, const char *format, ...) {

	struct list_head *debug_pos;
	struct debug_level_info *debug_level_info;
	int8_t debug_prio_intern;
	va_list args;


	if (!log_facility_active) {
		va_start(args, format);
		vprintf(format, args);
		va_end(args);
		return;
	}

	if (debug_prio == 0) {

		if (debug_level == 0) {

			va_start(args, format);
			vsyslog(LOG_ERR, format, args);
			va_end(args);

		} else if ((debug_level == 3) || (debug_level == 4)) {

			if (debug_level == 4)
				printf("[%10u] ", get_time_msec());

			va_start(args, format);
			vprintf(format, args);
			va_end(args);

		}

		debug_prio_intern = 3;

	} else {

		debug_prio_intern = debug_prio - 1;

	}

	if (debug_clients.clients_num[debug_prio_intern] < 1)
		return;

	if (pthread_mutex_trylock((pthread_mutex_t *)debug_clients.mutex[debug_prio_intern] ) != 0) {
		debug_output(0, "Warning - could not trylock mutex (debug_output): %s \n", strerror(EBUSY));
		return;
	}

	va_start(args, format);

	list_for_each(debug_pos, (struct list_head *)debug_clients.fd_list[debug_prio_intern]) {

		debug_level_info = list_entry(debug_pos, struct debug_level_info, list);

		/* batman debug gets milliseconds prepended for better debugging */
		if (debug_prio_intern == 3)
			dprintf(debug_level_info->fd, "[%10u] ", get_time_msec());

		if (((debug_level == 1) || (debug_level == 2)) && (debug_level_info->fd == 1) && (strncmp(format, "BOD", 3) == 0))
			/* clear screen, set cursor back to 0,0 */
			printf("\033[2J\033[0;0f");

		if (((debug_level != 1) && (debug_level != 2)) || (debug_level_info->fd != 1) || (strncmp(format, "EOD", 3) != 0))
			vdprintf(debug_level_info->fd, format, args);

	}

	va_end(args);

	if (pthread_mutex_unlock((pthread_mutex_t *)debug_clients.mutex[debug_prio_intern]) < 0)
		debug_output(0, "Error - could not unlock mutex (debug_output): %s \n", strerror(errno));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %rbx
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
testb %al, %al
je 0xd8ef
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
leaq 0x99f7(%rip), %rax      # 0x172ed
cmpb $0x0, (%rax)
je 0xd954
movl %edi, %ebp
testb %bpl, %bpl
je 0xd993
decb %bpl
leaq 0x9a38(%rip), %r15      # 0x17348
movq 0x8(%r15), %rax
movsbq %bpl, %r14
cmpw $0x0, (%rax,%r14,2)
jle 0xd981
movq 0x10(%r15), %rax
movq (%rax,%r14,8), %rdi
callq 0x2220
testl %eax, %eax
je 0xd9fe
movl $0x10, %edi
callq 0x2480
leaq 0x540a(%rip), %rsi      # 0x12d50
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0xd88c
jmp 0xd981
leaq 0x20(%rsp), %rax
movq %rsp, %rsi
movq %rax, 0x10(%rsi)
leaq 0x110(%rsp), %rax
movq %rax, 0x8(%rsi)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rsi)
movq %rbx, %rdi
callq 0x2330
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x991e(%rip), %rax      # 0x172b8
movb (%rax), %al
testb %al, %al
je 0xdb28
leal -0x3(%rax), %ecx
movb $0x3, %bpl
cmpb $0x1, %cl
ja 0xd909
cmpb $0x4, %al
jne 0xd9cc
callq 0xb3f0
leaq 0x5385(%rip), %rdi      # 0x12d48
movl %eax, %esi
xorl %eax, %eax
callq 0x2190
leaq 0x20(%rsp), %rax
movq %rsp, %rsi
movq %rax, 0x10(%rsi)
leaq 0x110(%rsp), %rax
movq %rax, 0x8(%rsi)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rsi)
movq %rbx, %rdi
callq 0x2330
jmp 0xd909
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x110(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rsp)
movq (%r15), %rax
movq (%rax,%r14,8), %rax
movq (%rax), %r12
cmpq %rax, %r12
je 0xdafb
leaq 0x987b(%rip), %r13      # 0x172b8
movq %rbx, 0x18(%rsp)
cmpb $0x3, %bpl
jne 0xda82
movq %r14, %rbx
movl %ebp, %r14d
movq %r15, %rbp
movq %r13, %r15
movl 0x8(%r12), %r13d
callq 0xb3f0
movl %r13d, %edi
movq %r15, %r13
movq %rbp, %r15
movl %r14d, %ebp
movq %rbx, %r14
movq 0x18(%rsp), %rbx
leaq 0x52cf(%rip), %rsi      # 0x12d48
movl %eax, %edx
xorl %eax, %eax
callq 0x2200
movb (%r13), %al
leal -0x1(%rax), %ecx
cmpb $0x1, %cl
ja 0xdab9
cmpl $0x1, 0x8(%r12)
jne 0xdab9
cmpb $0x42, (%rbx)
jne 0xdab9
cmpb $0x4f, 0x1(%rbx)
jne 0xdab9
cmpb $0x44, 0x2(%rbx)
jne 0xdab9
leaq 0x450f(%rip), %rdi      # 0x11fbd
xorl %eax, %eax
callq 0x2190
movb (%r13), %al
decb %al
movl 0x8(%r12), %edi
cmpb $0x1, %al
ja 0xdadf
cmpl $0x1, %edi
jne 0xdadf
movl $0x1, %edi
cmpb $0x45, (%rbx)
jne 0xdadf
cmpb $0x4f, 0x1(%rbx)
jne 0xdadf
cmpb $0x44, 0x2(%rbx)
je 0xdaea
movq %rbx, %rsi
movq %rsp, %rdx
callq 0x23c0
movq (%r12), %r12
movq (%r15), %rax
cmpq (%rax,%r14,8), %r12
jne 0xda42
movq 0x10(%r15), %rax
movq (%rax,%r14,8), %rdi
callq 0x22d0
testl %eax, %eax
jns 0xd981
callq 0x2070
movl (%rax), %edi
callq 0x2480
leaq 0x5264(%rip), %rsi      # 0x12d87
jmp 0xd946
leaq 0x20(%rsp), %rax
movq %rsp, %rdx
movq %rax, 0x10(%rdx)
leaq 0x110(%rsp), %rax
movq %rax, 0x8(%rdx)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rdx)
movl $0x3, %edi
movq %rbx, %rsi
callq 0x2410
movb $0x3, %bpl
jmp 0xd909