// File: /workspace/github_c_makefile_star2_O3/enzo1982[P]smooth/classes/graphics/backends/fontbackend.cpp
// Function: smooth::GUI::FontBackend::GetTextSize(smooth::String const&, bool) const
S::GUI::Size S::GUI::FontBackend::GetTextSize(const String &text, Bool scaled) const
{
	if (text == NIL) return Size();

	/* Check for existing cache entry.
	 */
	ExtentsCacheEntry	 entry(text, fontName, fontSize, fontWeight, fontStyle);

	Float			 dpi = Surface().GetSurfaceDPI();
	Int			 crc = entry.GetCRC32();

	if (ExtentsCacheEntry *cacheEntry = extentsCache.Get(crc))
	{
		if (scaled || Math::Abs(dpi - 96.0) < 0.1) return cacheEntry->GetExtents();
		else					   return cacheEntry->GetExtents() * 96.0 / dpi;
	}

	/* Compute scaled text size.
	 */
	Size	 size = GetTextSize(text);

	entry.SetExtents(size);

	/* Save at most 2048 cache entries.
	 */
	if (extentsCache.Length() >= 2048)
	{
		for (Int i = 0; i < 1024; i++)
		{
			delete extentsCache.GetFirst();

			extentsCache.RemoveNth(0);
		}
	}

	extentsCache.Add(new ExtentsCacheEntry(entry), crc);

	/* Return computed text size.
	 */
	if (scaled || Math::Abs(dpi - 96.0) < 0.1) return size;
	else					   return size * 96.0 / dpi;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x60, %rsp
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
xorl %r12d, %r12d
movq %rsi, %rdi
xorl %esi, %esi
callq 0x55260
testb %al, %al
jne 0x60892
leaq 0x10(%r15), %rdx
movswl 0xa(%r15), %ecx
movswl 0x38(%r15), %r8d
movswl 0x3a(%r15), %r9d
leaq 0x14(%rsp), %rdi
movq %r14, %rsi
callq 0x609c6
leaq 0x58(%rsp), %rdx
movq $0x0, (%rdx)
leaq 0x8(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x57150
movq %r12, %rdi
callq 0x58930
cwtl
cvtsi2sd %eax, %xmm0
movapd %xmm0, 0x30(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x57b20
movl 0x14(%rsp), %ebp
leaq 0x10e08c(%rip), %rdi    # 0x16e718
movl %ebp, %esi
callq 0x5b778
movq (%rax), %r12
testq %r12, %r12
je 0x606db
testb %bl, %bl
jne 0x606c4
movsd 0x92e69(%rip), %xmm0    # 0xf3510
addsd 0x30(%rsp), %xmm0
callq 0x55660
movsd 0x92e5e(%rip), %xmm1    # 0xf3518
ucomisd %xmm0, %xmm1
jbe 0x607b3
movq 0x4(%r12), %rax
movq %rax, %xmm0
shrq $0x20, %rax
movd %eax, %xmm1
jmp 0x60875
movq (%r15), %rax
movq %r15, %rdi
movq %r14, %rsi
callq *0x10(%rax)
movq %rax, %xmm0
movdqa %xmm0, 0x40(%rsp)
movq %rax, 0x18(%rsp)
shrq $0x20, %rax
movd %eax, %xmm0
movdqa %xmm0, 0x20(%rsp)
cmpl $0x800, 0x10e011(%rip)  # imm = 0x800
jl 0x60742
movl $0x400, %r15d           # imm = 0x400
leaq 0x10dffa(%rip), %r14    # 0x16e718
movq %r14, %rdi
callq 0x60af6
movq (%rax), %rdi
movl $0xc, %esi
callq 0x55480
movq %r14, %rdi
xorl %esi, %esi
callq 0x5acdc
decl %r15d
jne 0x6071e
movapd 0x20(%rsp), %xmm0
unpcklpd 0x40(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
movapd %xmm0, 0x20(%rsp)
movl $0xc, %edi
callq 0x556b0
movq 0x14(%rsp), %rcx
movq %rcx, (%rax)
movl 0x1c(%rsp), %ecx
movl %ecx, 0x8(%rax)
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x10df9c(%rip), %rdi    # 0x16e718
movl %ebp, %edx
callq 0x5af42
testb %bl, %bl
jne 0x607a8
movsd 0x92d81(%rip), %xmm0    # 0xf3510
addsd 0x30(%rsp), %xmm0
callq 0x55660
movsd 0x92d76(%rip), %xmm1    # 0xf3518
ucomisd %xmm0, %xmm1
jbe 0x607d2
movdqa 0x20(%rsp), %xmm1
jmp 0x60879
cvtdq2pd 0x4(%r12), %xmm0
movapd 0x92d5e(%rip), %xmm1    # 0xf3520
shufpd $0x1, %xmm1, %xmm1      # xmm1 = xmm1[1,0]
shufpd $0x1, %xmm0, %xmm0      # xmm0 = xmm0[1,0]
mulpd %xmm1, %xmm0
jmp 0x607e5
pshufd $0xe8, 0x20(%rsp), %xmm0 # xmm0 = mem[0,2,2,3]
cvtdq2pd %xmm0, %xmm0
mulpd 0x92d3b(%rip), %xmm0    # 0xf3520
xorpd %xmm1, %xmm1
movapd %xmm0, %xmm2
cmpltpd %xmm1, %xmm2
movapd 0x92d36(%rip), %xmm3    # 0xf3530
movapd 0x92d3e(%rip), %xmm4    # 0xf3540
movapd %xmm4, %xmm5
andpd %xmm2, %xmm5
andnpd %xmm3, %xmm2
orpd %xmm5, %xmm2
addpd %xmm0, %xmm2
cvttsd2si %xmm2, %rax
movq %rax, %xmm0
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
cvttsd2si %xmm2, %rax
movq %rax, %xmm2
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
cvtdq2pd %xmm0, %xmm0
movapd 0x30(%rsp), %xmm2
unpcklpd %xmm2, %xmm2            # xmm2 = xmm2[0,0]
divpd %xmm2, %xmm0
movapd %xmm0, %xmm2
cmpltpd %xmm1, %xmm2
andpd %xmm2, %xmm4
andnpd %xmm3, %xmm2
orpd %xmm4, %xmm2
addpd %xmm0, %xmm2
cvttsd2si %xmm2, %rax
movq %rax, %xmm1
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
cvttsd2si %xmm2, %rax
movq %rax, %xmm0
punpcklqdq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0]
movq %xmm1, %rax
shlq $0x20, %rax
xorpd %xmm0, %xmm0
punpckhdq %xmm0, %xmm1    # xmm1 = xmm1[2],xmm0[2],xmm1[3],xmm0[3]
movq %xmm1, %r12
orq %rax, %r12
movq %r12, %rax
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x57b20
movq %rbx, %rdi
callq 0x57090
nop