// File: /workspace/github_c_makefile_star2_O2/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 0xcb7f
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 0xa767(%rip), %rax      # 0x172ed
cmpb $0x0, (%rax)
je 0xcbec
movl %edi, %ebp
movabsq $0x3000000010, %r14     # imm = 0x3000000010
testb %bpl, %bpl
je 0xcc2b
decb %bpl
leaq 0xa79e(%rip), %r13      # 0x17348
movq 0x8(%r13), %rax
movsbq %bpl, %r12
cmpw $0x0, (%rax,%r12,2)
jle 0xcc19
movq 0x10(%r13), %rax
movq (%rax,%r12,8), %rdi
callq 0x2220
testl %eax, %eax
je 0xcc8c
pushq $0x10
popq %rdi
callq 0x2480
leaq 0x5152(%rip), %rsi      # 0x11d30
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
jmp 0xcc19
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 0xa686(%rip), %rax      # 0x172b8
movb (%rax), %al
testb %al, %al
je 0xcd82
leal -0x3(%rax), %ecx
movb $0x3, %bpl
cmpb $0x1, %cl
ja 0xcba3
cmpb $0x4, %al
jne 0xcc64
callq 0xa9e4
leaq 0x50cd(%rip), %rdi      # 0x11d28
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)
movq %r14, (%rsi)
movq %rbx, %rdi
callq 0x2330
jmp 0xcba3
leaq 0x20(%rsp), %rax
movq %rsp, %rcx
movq %rax, 0x10(%rcx)
leaq 0x110(%rsp), %rax
movq %rax, 0x8(%rcx)
movq %r14, (%rcx)
movq (%r13), %rax
movq (%rax,%r12,8), %rax
leaq 0xa602(%rip), %r15      # 0x172b8
movq %rax, %r14
movq (%r14), %r14
cmpq %rax, %r14
je 0xcd55
cmpb $0x3, %r12b
jne 0xcce6
movl 0x8(%r14), %ebp
callq 0xa9e4
movl %ebp, %edi
leaq 0x504b(%rip), %rsi      # 0x11d28
movl %eax, %edx
xorl %eax, %eax
callq 0x2200
movb (%r15), %al
leal -0x1(%rax), %ecx
cmpb $0x1, %cl
ja 0xcd1a
cmpl $0x1, 0x8(%r14)
jne 0xcd1a
cmpb $0x42, (%rbx)
jne 0xcd1a
cmpb $0x4f, 0x1(%rbx)
jne 0xcd1a
cmpb $0x44, 0x2(%rbx)
jne 0xcd1a
leaq 0x428d(%rip), %rdi      # 0x10f9d
xorl %eax, %eax
callq 0x2190
movb (%r15), %al
decb %al
movl 0x8(%r14), %edi
cmpb $0x1, %al
ja 0xcd3d
cmpl $0x1, %edi
jne 0xcd3d
cmpb $0x45, (%rbx)
pushq $0x1
popq %rdi
jne 0xcd3d
cmpb $0x4f, 0x1(%rbx)
jne 0xcd3d
cmpb $0x44, 0x2(%rbx)
je 0xcd48
movq %rbx, %rsi
movq %rsp, %rdx
callq 0x23c0
movq (%r13), %rax
movq (%rax,%r12,8), %rax
jmp 0xccb9
movq 0x10(%r13), %rax
movq (%rax,%r12,8), %rdi
callq 0x22d0
testl %eax, %eax
jns 0xcc19
callq 0x2070
movl (%rax), %edi
callq 0x2480
leaq 0x4fea(%rip), %rsi      # 0x11d67
jmp 0xcbde
leaq 0x20(%rsp), %rax
movq %rsp, %rdx
movq %rax, 0x10(%rdx)
leaq 0x110(%rsp), %rax
movq %rax, 0x8(%rdx)
movq %r14, (%rdx)
pushq $0x3
popq %rdi
movq %rbx, %rsi
callq 0x2410
movb $0x3, %bpl
jmp 0xcba3