// File: /workspace/github_c_makefile_star2_O3/MikeGray-APH[P]LibLouisAPH/source/log.c
// Function: log_message
void log_message(const enum log_level level, const char *format, ...)
{
	va_list args;
	char message[LOG_MESSAGE_MAX], *arg_string;
	size_t fcrs, mcrs, len;
	unichar *arg_uchars, arg_uchar;
	unsigned int arg_unt;
	int arg_int;

	if(!log_callback)
		return;

	memset(message, 0, LOG_MESSAGE_MAX);
	va_start(args, format);
	for(fcrs = mcrs = 0; fcrs < strlen(format) - 1; fcrs++)
	{
		if(format[fcrs] != '%')
			message[mcrs++] = format[fcrs];
		else switch(format[++fcrs])
		{
		case 'd':

			arg_int = va_arg(args, int);
			len = snprintf(&message[mcrs], LOG_MESSAGE_MAX - mcrs, "%d", arg_int);
			mcrs += len;
			break;

		case 'u':

			arg_unt = va_arg(args, int);
			len = snprintf(&message[mcrs], LOG_MESSAGE_MAX - mcrs, "%u", arg_unt);
			mcrs += len;
			break;

		case 'x':

			arg_unt = va_arg(args, int);
			len = snprintf(&message[mcrs], LOG_MESSAGE_MAX - mcrs, "%x", arg_unt);
			mcrs += len;
			break;

		case 'o':

			arg_unt = va_arg(args, int);
			len = snprintf(&message[mcrs], LOG_MESSAGE_MAX - mcrs, "%o", arg_unt);
			mcrs += len;
			break;

		case 'b':

			arg_unt = va_arg(args, int);
			len = convert_number(&message[mcrs], LOG_MESSAGE_MAX - mcrs, arg_unt, 2);
			mcrs += len;
			break;

		case 'c':

			arg_int = va_arg(args, int);
			len = snprintf(&message[mcrs], LOG_MESSAGE_MAX - mcrs, "%c", arg_int);
			mcrs += len;
			break;

		case 's':

			arg_string = va_arg(args, char*);
			len = snprintf(&message[mcrs], LOG_MESSAGE_MAX - mcrs, "%s", arg_string);
			mcrs += len;
			break;

		case 'C':

			arg_uchar = (unichar)va_arg(args, int);
			len = utf16_convert_to_utf8(&message[mcrs], LOG_MESSAGE_MAX - mcrs, &arg_uchar, 1, NULL);
			mcrs += len;
			break;

		case 'S':

			arg_uchars = (unichar*)va_arg(args, unichar*);
			len = 0;
			while(arg_uchars[len])
				len++;
			len = utf16_convert_to_utf8(&message[mcrs], LOG_MESSAGE_MAX - mcrs, arg_uchars, len, NULL);
			mcrs += len;
			break;

		case '#':

			fcrs++;
			if(fcrs >= strlen(format))
			{
				/*   copy last chars to message   */
				message[mcrs++] = format[fcrs - 2];
				message[mcrs++] = format[fcrs - 1];
				break;
			}
			if(format[fcrs] == 'S')
			{
				arg_uchars = (unichar*)va_arg(args, unichar*);
				arg_int = va_arg(args, int);
				len = utf16_convert_to_utf8(&message[mcrs], LOG_MESSAGE_MAX - mcrs, arg_uchars, arg_int, NULL);
				mcrs += len;
			}
			else
			{
				snprintf(&message[mcrs], LOG_MESSAGE_MAX - mcrs, ":  ERROR:  unknown specifier %%#%c", format[fcrs]);
				message[LOG_MESSAGE_MAX - 1] = 0;
				goto return_message;
			}
			break;

		default:

			snprintf(&message[mcrs], LOG_MESSAGE_MAX - mcrs, ":  ERROR:  unknown specifier %%%c", format[fcrs]);
			message[LOG_MESSAGE_MAX - 1] = 0;
			goto return_message;
		}

		if(mcrs >= LOG_MESSAGE_MAX - 1)
		{
			mcrs = LOG_MESSAGE_MAX - 1;
			message[mcrs] = 0;
			goto return_message;
		}
	}
	va_end(args);

	/*   copy last char to message   */
	if(fcrs < strlen(format))
	if(mcrs < LOG_MESSAGE_MAX - 1)
		message[mcrs++] = format[fcrs];
	else
		mcrs = LOG_MESSAGE_MAX - 1;
	message[mcrs] = 0;

	return_message:
	OUTPUT_TO_FILE(level, message)
	log_callback(level, message);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1128, %rsp           # imm = 0x1128
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
testb %al, %al
je 0xa2d8
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)
cmpq $0x0, 0xff98(%rip)      # 0x1a278
je 0xa86f
movq %rsi, %r14
movl %edi, %ebx
leaq 0x120(%rsp), %rdi
xorl %ebp, %ebp
movl $0x1000, %edx           # imm = 0x1000
xorl %esi, %esi
callq 0x1110
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rsp)
leaq 0x1160(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %r14, %rdi
callq 0x10b0
cmpq $0x1, %rax
jne 0xa362
xorl %r12d, %r12d
movq %r14, %rdi
callq 0x10b0
cmpq %rax, %rbp
jae 0xa353
movb (%r14,%rbp), %al
movb %al, 0x120(%rsp,%r12)
incq %r12
leaq (%rsp,%r12), %rax
addq $0x120, %rax            # imm = 0x120
jmp 0xa85c
leaq 0xd0(%rsp), %r13
xorl %r12d, %r12d
xorl %r15d, %r15d
movb (%r14,%r15), %cl
cmpb $0x25, %cl
jne 0xa3bf
leaq 0x1(%r15), %rbp
movzbl 0x1(%r14,%r15), %ecx
cmpl $0x62, %ecx
jg 0xa3d2
cmpl $0x52, %ecx
jg 0xa40a
cmpl $0x23, %ecx
je 0xa46e
cmpl $0x43, %ecx
jne 0xa814
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0xa5ab
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0xa5b9
movb %cl, 0x120(%rsp,%r12)
incq %r12
movq %r15, %rbp
jmp 0xa79f
leal -0x6f(%rcx), %eax
cmpl $0x9, %eax
ja 0xa43c
leaq 0x97ef(%rip), %rdx      # 0x13bd0
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0xa6e2
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0xa6f0
cmpl $0x53, %ecx
je 0xa4c2
cmpl $0x62, %ecx
jne 0xa814
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0xa5eb
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0xa5f9
cmpl $0x63, %ecx
je 0xa542
cmpl $0x64, %ecx
jne 0xa814
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0xa769
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0xa777
addq $0x2, %r15
cmpq %rax, %r15
jae 0xa562
movsbl (%r14,%r15), %ecx
cmpl $0x53, %ecx
jne 0xa833
movl (%rsp), %ecx
cmpq $0x29, %rcx
jae 0xa7ce
movq 0x10(%rsp), %rdx
movq %rcx, %rax
addq $0x8, %rax
movl %eax, (%rsp)
movq (%rdx,%rcx), %rdx
cmpl $0x20, %ecx
ja 0xa7df
addq 0x10(%rsp), %rax
addl $0x10, %ecx
movl %ecx, (%rsp)
jmp 0xa7ed
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0xa576
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0xa584
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0xa67c
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0xa68a
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0xa6ab
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0xa6b9
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0xa711
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0xa71f
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0xa73d
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0xa74b
movw $0x2325, 0x120(%rsp,%r12) # imm = 0x2325
addq $0x2, %r12
jmp 0xa3ca
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rdx
xorl %ecx, %ecx
cmpw $0x0, (%rdx,%rcx,2)
leaq 0x1(%rcx), %rcx
jne 0xa589
leaq (%rsp,%r12), %rdi
addq $0x120, %rdi            # imm = 0x120
movl $0x1000, %esi           # imm = 0x1000
subl %r12d, %esi
decl %ecx
jmp 0xa5de
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movzwl (%rax), %eax
movw %ax, 0x1e(%rsp)
leaq (%rsp,%r12), %rdi
addq $0x120, %rdi            # imm = 0x120
movl $0x1000, %esi           # imm = 0x1000
subl %r12d, %esi
leaq 0x1e(%rsp), %rdx
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0x170a
jmp 0xa79a
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movl (%rax), %esi
leaq (%rsp,%r12), %rcx
addq $0x120, %rcx            # imm = 0x120
movq %r12, %rax
leaq 0xcf(%rsp), %r8
movl %esi, %edi
movq %r8, %rdx
incq %r8
movl %esi, %r9d
andb $0x1, %r9b
orb $0x30, %r9b
movb %r9b, 0x1(%rdx)
shrl %edi
incq %rax
cmpl $0x1, %esi
movl %edi, %esi
ja 0xa613
cmpl $0xffe, %r12d           # imm = 0xFFE
ja 0xa66d
movl $0xfff, %esi            # imm = 0xFFF
subl %r12d, %esi
movl $0xfff, %edi            # imm = 0xFFF
andl %edi, %esi
xorl %edi, %edi
movb 0x1(%rdx), %r8b
movb %r8b, (%rcx,%rdi)
cmpq %r13, %rdx
jb 0xa669
incq %rdi
decq %rdx
cmpq %rdi, %rsi
jne 0xa64e
movq %rsi, %rdi
movl %edi, %edx
jmp 0xa66f
xorl %edx, %edx
movb $0x0, 0x1(%rcx,%rdx)
movq %rax, %r12
jmp 0xa79f
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movl (%rax), %ecx
leaq (%rsp,%r12), %rdi
addq $0x120, %rdi            # imm = 0x120
movl $0x1000, %esi           # imm = 0x1000
subq %r12, %rsi
leaq 0x9555(%rip), %rdx      # 0x13bfb
jmp 0xa793
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rcx
leaq (%rsp,%r12), %rdi
addq $0x120, %rdi            # imm = 0x120
movl $0x1000, %esi           # imm = 0x1000
subq %r12, %rsi
leaq 0x948c(%rip), %rdx      # 0x13b62
xorl %eax, %eax
callq 0x10e0
jmp 0xa79a
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movl (%rax), %ecx
leaq (%rsp,%r12), %rdi
addq $0x120, %rdi            # imm = 0x120
movl $0x1000, %esi           # imm = 0x1000
subq %r12, %rsi
leaq 0x94f2(%rip), %rdx      # 0x13bfe
jmp 0xa793
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movl (%rax), %ecx
leaq (%rsp,%r12), %rdi
addq $0x120, %rdi            # imm = 0x120
movl $0x1000, %esi           # imm = 0x1000
subq %r12, %rsi
leaq 0x94bd(%rip), %rdx      # 0x13bf8
jmp 0xa793
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movl (%rax), %ecx
leaq (%rsp,%r12), %rdi
addq $0x120, %rdi            # imm = 0x120
movl $0x1000, %esi           # imm = 0x1000
subq %r12, %rsi
leaq 0x94ba(%rip), %rdx      # 0x13c21
jmp 0xa793
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movl (%rax), %ecx
leaq (%rsp,%r12), %rdi
addq $0x120, %rdi            # imm = 0x120
movl $0x1000, %esi           # imm = 0x1000
subq %r12, %rsi
leaq 0x9abb(%rip), %rdx      # 0x1424e
xorl %eax, %eax
callq 0x10e0
cltq
addq %rax, %r12
cmpq $0xfff, %r12            # imm = 0xFFF
jae 0xa854
incq %rbp
movq %r14, %rdi
callq 0x10b0
movq %rax, %rcx
decq %rcx
movq %rbp, %r15
cmpq %rcx, %rbp
jb 0xa370
jmp 0xa337
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rdx
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movl (%rax), %ecx
leaq (%rsp,%r12), %rdi
addq $0x120, %rdi            # imm = 0x120
movl $0x1000, %esi           # imm = 0x1000
subl %r12d, %esi
xorl %r8d, %r8d
callq 0x170a
cltq
addq %rax, %r12
jmp 0xa3ca
movsbl %cl, %ecx
leaq (%rsp,%r12), %rdi
addq $0x120, %rdi            # imm = 0x120
movl $0x1000, %esi           # imm = 0x1000
subq %r12, %rsi
leaq 0x93f3(%rip), %rdx      # 0x13c24
jmp 0xa84d
leaq (%rsp,%r12), %rdi
addq $0x120, %rdi            # imm = 0x120
movl $0x1000, %esi           # imm = 0x1000
subq %r12, %rsi
leaq 0x93b4(%rip), %rdx      # 0x13c01
xorl %eax, %eax
callq 0x10e0
leaq 0x111f(%rsp), %rax
movb $0x0, (%rax)
leaq 0x120(%rsp), %rsi
movl %ebx, %edi
callq *0xfa09(%rip)           # 0x1a278
addq $0x1128, %rsp           # imm = 0x1128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)