// File: /workspace/github_c_makefile_star2_O2/cyb70289[P]tt/src/common/log.c
// Function: tt_log
void tt_log(int level, const char *func, const char *format, ...)
{
	tt_assert(level >= 0 && level < TT_LOG_MAX);

	if (__target == TT_LOG_TARGET_NULL)
		return;
	if (level > __level)
		return;

	va_list ap;
	va_start(ap, format);

	char msg[512+12];
	if (vsnprintf(msg, 512, format, ap) >= 512)
		snprintf(msg+511, 13, "<Truncated>");

	char meta[32];
	const char *prefix = "", *suffix = "";

	switch (__target) {
	case TT_LOG_TARGET_STDERR:
		if (level == TT_LOG_ERROR)
			prefix = "\x1B[1;31m";	/* Red bold */
		else if (level == TT_LOG_WARN)
			prefix = "\x1B[1;33m";	/* Yellow bold */
		else if (level == TT_LOG_INFO)
			prefix = "\x1B[1;37m";  /* White bold */
		if (prefix[0])
			suffix = "\x1B[0m";
		fprintf(stderr, "[%c]%s: %s%s%s\n", level2char[level], func,
				prefix, msg, suffix);
		break;

	case TT_LOG_TARGET_FD:
		snprintf(meta, 32, "\n[%c]%s: ", level2char[level], func);
		if (write(__fd, meta, strlen(meta)) < 0 ||
				write(__fd, msg, strlen(msg)) < 0) {
			tt_log_set_fd(-1);
			fprintf(stderr, "Error writing logs to file descriptor,"
					" redirect messges to console.\n");
			tt_log_set_target(TT_LOG_TARGET_STDERR);
		}
		break;

	default:
		break;
	}

	va_end(ap);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x310, %rsp            # imm = 0x310
movq %rcx, 0x68(%rsp)
movq %r8, 0x70(%rsp)
movq %r9, 0x78(%rsp)
testb %al, %al
je 0x25ea
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)
cmpl $0x4, %edi
jae 0x278d
cmpl $0x2, 0x5b26(%rip)      # 0x8120
je 0x2754
movl %edi, %ebp
cmpl %edi, 0x5ac0(%rip)      # 0x80c8
jl 0x2754
movq %rsi, %rbx
leaq 0x50(%rsp), %rax
leaq 0x10(%rsp), %rcx
movq %rax, 0x10(%rcx)
leaq 0x330(%rsp), %rax
movq %rax, 0x8(%rcx)
movabsq $0x3000000018, %rax     # imm = 0x3000000018
movq %rax, (%rcx)
leaq 0x100(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x1060
cmpl $0x200, %eax            # imm = 0x200
jl 0x266e
movabsq $0x7461636e7572543c, %rax # imm = 0x7461636E7572543C
movq %rax, 0x2ff(%rsp)
movl $0x3e6465, 0x307(%rsp) # imm = 0x3E6465
movl 0x5aac(%rip), %eax      # 0x8120
cmpl $0x1, %eax
je 0x26e3
testl %eax, %eax
jne 0x2754
leaq 0x2df6(%rip), %rcx      # 0x547e
movl %ebp, %eax
movq %rcx, %r8
cmpl $0x3, %ebp
je 0x26a0
leaq 0x2cd7(%rip), %rdx      # 0x5370
movslq (%rdx,%rax,4), %r8
addq %rdx, %r8
cmpb $0x0, (%r8)
leaq 0x2d70(%rip), %rsi      # 0x541b
cmoveq %rcx, %rsi
movq 0x5942(%rip), %rcx      # 0x7ff8
movq (%rcx), %rdi
leaq 0x30e5(%rip), %rcx      # 0x57a5
movsbl (%rax,%rcx), %edx
movq %rsi, (%rsp)
leaq 0x2d51(%rip), %rsi      # 0x5420
leaq 0x100(%rsp), %r9
movq %rbx, %rcx
xorl %eax, %eax
callq 0x10f0
jmp 0x2754
movl %ebp, %eax
leaq 0x30b9(%rip), %rcx      # 0x57a5
movsbl (%rax,%rcx), %ecx
leaq 0x2d39(%rip), %rdx      # 0x5430
leaq 0x30(%rsp), %r14
pushq $0x20
popq %rsi
movq %r14, %rdi
movq %rbx, %r8
xorl %eax, %eax
callq 0x10b0
movl 0x59ba(%rip), %ebx      # 0x80cc
movq %r14, %rdi
callq 0x1090
movl %ebx, %edi
movq %r14, %rsi
movq %rax, %rdx
callq 0x1070
testq %rax, %rax
js 0x2760
movl 0x599a(%rip), %ebx      # 0x80cc
leaq 0x100(%rsp), %r14
movq %r14, %rdi
callq 0x1090
movl %ebx, %edi
movq %r14, %rsi
movq %rax, %rdx
callq 0x1070
testq %rax, %rax
js 0x2760
addq $0x310, %rsp            # imm = 0x310
popq %rbx
popq %r14
popq %rbp
retq
pushq $-0x1
popq %rdi
callq 0x27ee
movq 0x5889(%rip), %rax      # 0x7ff8
movq (%rax), %rcx
leaq 0x2cc1(%rip), %rdi      # 0x543a
pushq $0x44
popq %rsi
pushq $0x1
popq %rdx
callq 0x1150
andl $0x0, 0x5995(%rip)      # 0x8120
jmp 0x2754
leaq 0x2c5c(%rip), %rsi      # 0x53f0
leaq 0x29f1(%rip), %rdx      # 0x518c
leaq 0x2c2c(%rip), %rcx      # 0x53ce
pushq $0x32
popq %r8
xorl %edi, %edi
xorl %eax, %eax
callq 0x258c
callq 0x1050