// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x520, %rsp            # imm = 0x520
testb %al, %al
je 0x5aa7
movaps %xmm0, -0x4d0(%rbp)
movaps %xmm1, -0x4c0(%rbp)
movaps %xmm2, -0x4b0(%rbp)
movaps %xmm3, -0x4a0(%rbp)
movaps %xmm4, -0x490(%rbp)
movaps %xmm5, -0x480(%rbp)
movaps %xmm6, -0x470(%rbp)
movaps %xmm7, -0x460(%rbp)
movq %r9, -0x4d8(%rbp)
movq %r8, -0x4e0(%rbp)
movq %rcx, -0x4e8(%rbp)
movq %rdx, -0x4f0(%rbp)
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq 0x342f(%rip), %rax      # 0x8f00
movq %rax, -0x3e0(%rbp)
movq 0x3429(%rip), %rax      # 0x8f08
movq %rax, -0x3d8(%rbp)
movq 0x3423(%rip), %rax      # 0x8f10
movq %rax, -0x3f0(%rbp)
movq 0x341d(%rip), %rax      # 0x8f18
movq %rax, -0x3e8(%rbp)
movq 0x3417(%rip), %rax      # 0x8f20
movq %rax, -0x400(%rbp)
movq 0x3411(%rip), %rax      # 0x8f28
movq %rax, -0x3f8(%rbp)
movq 0x340b(%rip), %rax      # 0x8f30
movq %rax, -0x410(%rbp)
movq 0x3405(%rip), %rax      # 0x8f38
movq %rax, -0x408(%rbp)
movq 0x33ff(%rip), %rax      # 0x8f40
movq %rax, -0x420(%rbp)
movq 0x33f9(%rip), %rax      # 0x8f48
movq %rax, -0x418(%rbp)
movq 0x33e3(%rip), %rax      # 0x8f40
movq %rax, -0x430(%rbp)
movq 0x33dd(%rip), %rax      # 0x8f48
movq %rax, -0x428(%rbp)
leaq -0x43f(%rbp), %rdi
xorl %esi, %esi
movl $0xf, %edx
callq 0x1110
cmpl $0x3, -0x4(%rbp)
jne 0x5b9e
movq 0x5466(%rip), %rax      # 0xaff8
movq (%rax), %rax
movq %rax, -0x3c8(%rbp)
jmp 0x5baf
movq 0x5433(%rip), %rax      # 0xafd8
movq (%rax), %rax
movq %rax, -0x3c8(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x450(%rbp), %rdi
movq %rdi, -0x510(%rbp)
callq 0x10f0
movq -0x510(%rbp), %rdi
callq 0x1040
movq %rax, %rcx
leaq 0x3374(%rip), %rdx      # 0x8f50
leaq -0x80(%rbp), %rdi
movl $0x64, %esi
callq 0x11d0
movl -0x4(%rbp), %eax
movq %rax, -0x508(%rbp)
subq $0x5, %rax
ja 0x5d54
movq -0x508(%rbp), %rax
leaq 0x32d0(%rip), %rcx      # 0x8edc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x43f(%rbp), %rdi
leaq -0x3e0(%rbp), %rdx
movl $0xf, %esi
movl $0x1b, %r9d
movl $0x22, %r8d
xorl %eax, %eax
movl %r9d, %ecx
movl $0x0, (%rsp)
movb $0x0, %al
callq 0x10e0
jmp 0x5d54
leaq -0x43f(%rbp), %rdi
leaq -0x3f0(%rbp), %rdx
movl $0xf, %esi
movl $0x1b, %r9d
movl $0x5b, %r8d
xorl %eax, %eax
movl %r9d, %ecx
movl $0x0, (%rsp)
movb $0x0, %al
callq 0x10e0
jmp 0x5d54
leaq -0x43f(%rbp), %rdi
leaq -0x400(%rbp), %rdx
movl $0xf, %esi
movl $0x1b, %r9d
movl $0x21, %r8d
xorl %eax, %eax
movl %r9d, %ecx
movl $0x0, (%rsp)
movb $0x0, %al
callq 0x10e0
jmp 0x5d54
leaq -0x43f(%rbp), %rdi
leaq -0x410(%rbp), %rdx
movl $0xf, %esi
movl $0x1b, %r9d
movl $0x1f, %r8d
xorl %eax, %eax
movl %r9d, %ecx
movl $0x0, (%rsp)
movb $0x0, %al
callq 0x10e0
jmp 0x5d54
leaq -0x43f(%rbp), %rdi
leaq -0x420(%rbp), %rdx
movl $0xf, %esi
movl $0x1b, %r9d
movl $0x24, %r8d
xorl %eax, %eax
movl %r9d, %ecx
movl $0x0, (%rsp)
movb $0x0, %al
callq 0x10e0
jmp 0x5d54
leaq -0x43f(%rbp), %rdi
leaq -0x430(%rbp), %rdx
movl $0xf, %esi
movl $0x1b, %r9d
movl $0x23, %r8d
xorl %eax, %eax
movl %r9d, %ecx
movl $0x0, (%rsp)
movb $0x0, %al
callq 0x10e0
leaq -0x500(%rbp), %rax
movq %rax, -0x3b0(%rbp)
leaq 0x10(%rbp), %rax
movq %rax, -0x3b8(%rbp)
movl $0x30, -0x3bc(%rbp)
movl $0x10, -0x3c0(%rbp)
movq -0x10(%rbp), %rdx
leaq -0x3a0(%rbp), %rdi
movq %rdi, -0x518(%rbp)
movl $0x320, %esi            # imm = 0x320
leaq -0x3c0(%rbp), %rcx
callq 0x1080
movq -0x518(%rbp), %r8
movq -0x3c8(%rbp), %rdi
leaq 0x31a6(%rip), %rsi      # 0x8f5f
xorl %eax, %eax
leaq -0x80(%rbp), %rdx
leaq -0x43f(%rbp), %rcx
callq 0x1170
movq -0x3c8(%rbp), %rdi
callq 0x11a0
addq $0x520, %rsp            # imm = 0x520
popq %rbp
retq