// File: /workspace/github_c_makefile_star2_O2/qpfiffer[P]38-Moths/src/logging.c
// Function: m38_log_msg
void m38_log_msg(log_level level, const char *fmsg, ...) {
	char buffer[100];
	char msg[800];
	va_list ap;
	FILE *fd;

	const char inf[] = "[%c[%dm-%c[%dm]"; /* Blue   [-] */
	const char dbg[] = "[%c[%dm^%c[%dm]"; /* Orange [^] */
	const char wrn[] = "[%c[%dm!%c[%dm]"; /* Yellow [!] */
	const char err[] = "[%c[%dmx%c[%dm]"; /* Red    [x] */
	const char fun[] = "[%c[%dm~%c[%dm]"; /* Teal   [~] */
	const char dbc[] = "[%c[%dm~%c[%dm]"; /* Purple [&] */
	char sym_buf[15] = {0};


	if (level == LOG_ERR) {
		fd = stderr;
	} else {
		fd = stdout;
	}

	/* Time stuff */
	struct timeval timest;
	gettimeofday(&timest, NULL);
	strftime(buffer, sizeof(buffer), "%b %d %H:%M:%S",
			localtime(&timest.tv_sec));

	switch (level) {
		case LOG_INFO:
			snprintf(sym_buf, strlen(inf), inf, 0x1B, 34, 0x1B, 0);
			break;
		case LOG_DEBUG:
			snprintf(sym_buf, strlen(dbg), dbg, 0x1B, 91, 0x1B, 0);
			break;
		case LOG_WARN:
			snprintf(sym_buf, strlen(wrn), wrn, 0x1B, 33, 0x1B, 0);
			break;
		case LOG_ERR:
			snprintf(sym_buf, strlen(err), err, 0x1B, 31, 0x1B, 0);
			break;
		case LOG_FUN:
			snprintf(sym_buf, strlen(fun), fun, 0x1B, 36, 0x1B, 0);
			break;
		case LOG_DB:
			snprintf(sym_buf, strlen(dbc), dbc, 0x1B, 35, 0x1B, 0);
			break;
	}

	/* Format msg */
	va_start(ap, fmsg);
	vsnprintf(msg, sizeof(msg), fmsg, ap);
	va_end(ap);

	fprintf(fd, "%s %s %s\n", buffer, sym_buf, msg);

	fflush(fd);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x490, %rsp            # imm = 0x490
movq %rsi, %r14
movq %rdx, 0x60(%rsp)
movq %rcx, 0x68(%rsp)
movq %r8, 0x70(%rsp)
movq %r9, 0x78(%rsp)
testb %al, %al
je 0x4206
movaps %xmm0, 0x80(%rsp)
movaps %xmm1, 0x90(%rsp)
movaps %xmm2, 0xa0(%rsp)
movaps %xmm3, 0xb0(%rsp)
movaps %xmm4, 0xc0(%rsp)
movaps %xmm5, 0xd0(%rsp)
movaps %xmm6, 0xe0(%rsp)
movaps %xmm7, 0xf0(%rsp)
andq $0x0, 0x17(%rsp)
movl %edi, %ebp
andq $0x0, 0x10(%rsp)
movq 0x4ddd(%rip), %rax      # 0x8ff8
movq (%rax), %r12
movq 0x4db3(%rip), %rax      # 0x8fd8
movq (%rax), %rbx
leaq 0x20(%rsp), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x1100
movq %r15, %rdi
callq 0x1040
leaq 0x2cca(%rip), %rdx      # 0x6f10
leaq 0x100(%rsp), %rdi
pushq $0x64
popq %rsi
movq %rax, %rcx
callq 0x11e0
cmpl $0x5, %ebp
ja 0x430b
movl %ebp, %eax
leaq 0x2c31(%rip), %rcx      # 0x6e9c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
andl $0x0, (%rsp)
leaq 0x2c41(%rip), %rdx      # 0x6ec0
leaq 0x10(%rsp), %rdi
pushq $0xf
popq %rsi
pushq $0x22
jmp 0x42fc
andl $0x0, (%rsp)
leaq 0x2c6a(%rip), %rdx      # 0x6f00
leaq 0x10(%rsp), %rdi
pushq $0xf
popq %rsi
pushq $0x24
jmp 0x42fc
andl $0x0, (%rsp)
leaq 0x2c33(%rip), %rdx      # 0x6ee0
leaq 0x10(%rsp), %rdi
pushq $0xf
popq %rsi
pushq $0x21
jmp 0x42fc
andl $0x0, (%rsp)
leaq 0x2c2c(%rip), %rdx      # 0x6ef0
leaq 0x10(%rsp), %rdi
pushq $0xf
popq %rsi
pushq $0x1f
jmp 0x42fc
andl $0x0, (%rsp)
leaq 0x2bf5(%rip), %rdx      # 0x6ed0
leaq 0x10(%rsp), %rdi
pushq $0xf
popq %rsi
pushq $0x5b
jmp 0x42fc
andl $0x0, (%rsp)
leaq 0x2c0e(%rip), %rdx      # 0x6f00
leaq 0x10(%rsp), %rdi
pushq $0xf
popq %rsi
pushq $0x23
popq %r8
pushq $0x1b
popq %rcx
movl %ecx, %r9d
xorl %eax, %eax
callq 0x10f0
cmpl $0x3, %ebp
cmoveq %r12, %rbx
leaq 0x50(%rsp), %rax
leaq 0x30(%rsp), %rcx
movq %rax, 0x10(%rcx)
leaq 0x4c0(%rsp), %rax
movq %rax, 0x8(%rcx)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rcx)
leaq 0x170(%rsp), %r15
movl $0x320, %esi            # imm = 0x320
movq %r15, %rdi
movq %r14, %rdx
callq 0x1090
leaq 0x2bc7(%rip), %rsi      # 0x6f1f
leaq 0x100(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movq %rbx, %rdi
movq %r15, %r8
xorl %eax, %eax
callq 0x1180
movq %rbx, %rdi
callq 0x11b0
addq $0x490, %rsp            # imm = 0x490
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop