// File: /workspace/github_c_makefile_star2_O1/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 0xd613
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 0x9cd3(%rip), %rax      # 0x172ed
cmpb $0x0, (%rax)
je 0xd678
movl %edi, %ebp
testb %bpl, %bpl
je 0xd6b7
decb %bpl
leaq 0x9d14(%rip), %r15      # 0x17348
movq 0x8(%r15), %rax
movsbq %bpl, %r14
cmpw $0x0, (%rax,%r14,2)
jle 0xd6a5
movq 0x10(%r15), %rax
movq (%rax,%r14,8), %rdi
callq 0x2220
testl %eax, %eax
je 0xd722
movl $0x10, %edi
callq 0x2480
leaq 0x5626(%rip), %rsi      # 0x12c90
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0xd5b0
jmp 0xd6a5
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 0x9bfa(%rip), %rax      # 0x172b8
movb (%rax), %al
testb %al, %al
je 0xd852
leal -0x3(%rax), %ecx
movb $0x3, %bpl
cmpb $0x1, %cl
ja 0xd62d
cmpb $0x4, %al
jne 0xd6f0
callq 0xb0fc
leaq 0x55a1(%rip), %rdi      # 0x12c88
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 0xd62d
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), %r13
cmpq %rax, %r13
je 0xd825
leaq 0x9b57(%rip), %r12      # 0x172b8
movq %r14, 0x18(%rsp)
cmpb $0x3, %bpl
jne 0xd7a5
movl %ebp, %r14d
movq %r12, %rbp
movq %rbx, %r12
movq %r15, %rbx
movl 0x8(%r13), %r15d
callq 0xb0fc
movl %r15d, %edi
movq %rbx, %r15
movq %r12, %rbx
movq %rbp, %r12
movl %r14d, %ebp
movq 0x18(%rsp), %r14
leaq 0x54ec(%rip), %rsi      # 0x12c88
movl %eax, %edx
xorl %eax, %eax
callq 0x2200
movb (%r12), %al
decb %al
cmpb $0x1, %al
ja 0xd7dc
cmpl $0x1, 0x8(%r13)
jne 0xd7dc
movl $0x3, %edx
movq %rbx, %rdi
leaq 0x4750(%rip), %rsi      # 0x11f15
callq 0x20a0
testl %eax, %eax
jne 0xd7dc
leaq 0x4744(%rip), %rdi      # 0x11f19
xorl %eax, %eax
callq 0x2190
movb (%r12), %al
addb $-0x3, %al
cmpb $-0x2, %al
jb 0xd805
cmpl $0x1, 0x8(%r13)
jne 0xd805
movl $0x3, %edx
movq %rbx, %rdi
leaq 0x4715(%rip), %rsi      # 0x11f11
callq 0x20a0
testl %eax, %eax
je 0xd814
movl 0x8(%r13), %edi
movq %rbx, %rsi
movq %rsp, %rdx
callq 0x23c0
movq (%r13), %r13
movq (%r15), %rax
cmpq (%rax,%r14,8), %r13
jne 0xd766
movq 0x10(%r15), %rax
movq (%rax,%r14,8), %rdi
callq 0x22d0
testl %eax, %eax
jns 0xd6a5
callq 0x2070
movl (%rax), %edi
callq 0x2480
leaq 0x547a(%rip), %rsi      # 0x12cc7
jmp 0xd66a
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 0xd62d