// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x358, %rsp            # imm = 0x358
testb %al, %al
je 0x3645
movaps %xmm0, 0x60(%rsp)
movaps %xmm1, 0x70(%rsp)
movaps %xmm2, 0x80(%rsp)
movaps %xmm3, 0x90(%rsp)
movaps %xmm4, 0xa0(%rsp)
movaps %xmm5, 0xb0(%rsp)
movaps %xmm6, 0xc0(%rsp)
movaps %xmm7, 0xd0(%rsp)
movq %r9, 0x58(%rsp)
movq %r8, 0x50(%rsp)
movq %rcx, 0x48(%rsp)
movl %edi, 0x354(%rsp)
movq %rsi, 0x348(%rsp)
movq %rdx, 0x340(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x354(%rsp)
movb %al, 0x2f(%rsp)
jl 0x368a
cmpl $0x4, 0x354(%rsp)
setl %al
movb %al, 0x2f(%rsp)
movb 0x2f(%rsp), %al
xorb $-0x1, %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x36ca
xorl %edi, %edi
leaq 0x4d12(%rip), %rsi      # 0x83bc
leaq 0x4adb(%rip), %rdx      # 0x818c
leaq 0x4ce2(%rip), %rcx      # 0x839a
movl $0x32, %r8d
movb $0x0, %al
callq 0x3600
callq 0x1040
jmp 0x36cc
cmpl $0x2, 0x7a6d(%rip)      # 0xb140
jne 0x36da
jmp 0x3940
movl 0x354(%rsp), %eax
cmpl 0x79d9(%rip), %eax      # 0xb0c0
jle 0x36ee
jmp 0x3940
leaq 0x320(%rsp), %rax
leaq 0x30(%rsp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x360(%rsp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x18, (%rax)
leaq 0x110(%rsp), %rdi
movq 0x340(%rsp), %rdx
leaq 0x320(%rsp), %rcx
movl $0x200, %esi            # imm = 0x200
callq 0x1050
cmpl $0x200, %eax            # imm = 0x200
jl 0x3763
leaq 0x110(%rsp), %rdi
addq $0x1ff, %rdi            # imm = 0x1FF
movl $0xd, %esi
leaq 0x4c67(%rip), %rdx      # 0x83c3
movb $0x0, %al
callq 0x10a0
leaq 0x4ce0(%rip), %rax      # 0x844a
movq %rax, 0xe8(%rsp)
movq %rax, 0xe0(%rsp)
movl 0x79c0(%rip), %eax      # 0xb140
movl %eax, 0x28(%rsp)
testl %eax, %eax
je 0x379c
jmp 0x378a
movl 0x28(%rsp), %eax
subl $0x1, %eax
je 0x385f
jmp 0x3936
cmpl $0x0, 0x354(%rsp)
jne 0x37b7
leaq 0x4c22(%rip), %rax      # 0x83cf
movq %rax, 0xe8(%rsp)
jmp 0x37ef
cmpl $0x1, 0x354(%rsp)
jne 0x37d2
leaq 0x4c0f(%rip), %rax      # 0x83d7
movq %rax, 0xe8(%rsp)
jmp 0x37ed
cmpl $0x2, 0x354(%rsp)
jne 0x37eb
leaq 0x4bfc(%rip), %rax      # 0x83df
movq %rax, 0xe8(%rsp)
jmp 0x37ed
jmp 0x37ef
movq 0xe8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x380b
leaq 0x4be4(%rip), %rax      # 0x83e7
movq %rax, 0xe0(%rsp)
movq 0x77e6(%rip), %rax      # 0xaff8
movq (%rax), %rdi
movslq 0x354(%rsp), %rcx
leaq 0x78a4(%rip), %rax      # 0xb0c8
movsbl (%rax,%rcx), %edx
movq 0x348(%rsp), %rcx
movq 0xe8(%rsp), %r8
leaq 0x110(%rsp), %r9
movq 0xe0(%rsp), %rax
leaq 0x4b9d(%rip), %rsi      # 0x83ec
movq %rax, (%rsp)
movb $0x0, %al
callq 0x10f0
jmp 0x3938
leaq 0xf0(%rsp), %rdi
movslq 0x354(%rsp), %rcx
leaq 0x7852(%rip), %rax      # 0xb0c8
movsbl (%rax,%rcx), %ecx
movq 0x348(%rsp), %r8
movl $0x20, %esi
leaq 0x4b6e(%rip), %rdx      # 0x83fc
movb $0x0, %al
callq 0x10a0
movl 0x7829(%rip), %eax      # 0xb0c4
movl %eax, 0x1c(%rsp)
leaq 0xf0(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x1080
movl 0x1c(%rsp), %edi
movq 0x20(%rsp), %rsi
movq %rax, %rdx
callq 0x1060
cmpq $0x0, %rax
jl 0x390b
movl 0x77ee(%rip), %eax      # 0xb0c4
movl %eax, 0xc(%rsp)
leaq 0x110(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x1080
movl 0xc(%rsp), %edi
movq 0x10(%rsp), %rsi
movq %rax, %rdx
callq 0x1060
cmpq $0x0, %rax
jge 0x3934
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x39d0
movq 0x76dc(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x4ae0(%rip), %rsi      # 0x8406
movb $0x0, %al
callq 0x10f0
xorl %edi, %edi
callq 0x3590
jmp 0x3938
jmp 0x3938
leaq 0x320(%rsp), %rax
addq $0x358, %rsp            # imm = 0x358
retq
nopl (%rax,%rax)