// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/classes/gui/widgets/special/cursor.cpp
// Function: smooth::GUI::Cursor::GetDisplayCursorPositionFromVisual(smooth::String const&, int) const
S::Int S::GUI::Cursor::GetDisplayCursorPositionFromVisual(const String &line, Int promptPos) const
{
	FriBidiStrIndex	 length = line.Length();

	if (length == 0) return 0;

	Int		 position = 0;

	if (!Binary::IsFlagSet(container->GetFlags(), EDB_ASTERISK))
	{
		String	 string = line;

		if (Setup::useIconv && ContainsRTLCharacters(line))
		{
			FriBidiChar	*visual = new FriBidiChar [length + 1];
			FriBidiParType	 type = (IsRightToLeft() ? FRIBIDI_PAR_RTL : FRIBIDI_PAR_LTR);

			fribidi_log2vis((FriBidiChar *) string.ConvertTo("UCS-4LE"), length, &type, visual, NIL, NIL, NIL);

			visual[length] = 0;

			string.ImportFrom("UCS-4LE", (char *) visual);

			delete [] visual;
		}

		/* Convert tabs.
		 */
		Int	 offset = 0;

		for (Int i = 0; i < length; i++)
		{
			if (string[i] != '\t') continue;

			Int	 spaces = tabSize - i % tabSize;

			string  = string.Head(i).Append(String().FillN(' ', spaces)).Append(string.Tail(length - i - 1));
			length += spaces - 1;

			if (i < promptPos + offset) offset += spaces - 1;
		}

		if (!IsRightToLeft()) position += font.GetScaledTextSizeX(string.Head(	       promptPos + offset)) - visibleOffset;
		else		      position += font.GetScaledTextSizeX(string.Tail(length - promptPos - offset)) - visibleOffset;
	}
	else
	{
		position += font.GetScaledTextSizeX(String().FillN('*', promptPos)) - visibleOffset;
	}

	return position;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5b800
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jne 0xcf18f
movl $0x0, -0x4(%rbp)
jmp 0xcf6b2
movq -0x100(%rbp), %rax
movl $0x0, -0x24(%rbp)
movq 0x190(%rax), %rdi
callq 0x5a120
movl %eax, %edi
movl $0x2, %esi
callq 0x5ce30
testb $0x1, %al
jne 0xcf60a
movq -0x18(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x5b6d0
movq 0x13915f(%rip), %rax    # 0x208330
testb $0x1, (%rax)
je 0xcf2f8
movq -0x18(%rbp), %rdi
callq 0x5bb50
movb %al, -0x101(%rbp)
jmp 0xcf1eb
movb -0x101(%rbp), %al
testb $0x1, %al
jne 0xcf1fa
jmp 0xcf2f8
movl -0x20(%rbp), %eax
incl %eax
cltq
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x5ab20
movq %rax, -0x110(%rbp)
jmp 0xcf225
movq -0x100(%rbp), %rdi
movq -0x110(%rbp), %rax
movq %rax, -0x58(%rbp)
movq (%rdi), %rax
movq 0x160(%rax), %rax
callq *%rax
movb %al, -0x111(%rbp)
jmp 0xcf24b
movb -0x111(%rbp), %al
movzbl %al, %eax
andl $0x1, %eax
orl $0x110, %eax            # imm = 0x110
movl %eax, -0x5c(%rbp)
leaq 0xbba33(%rip), %rsi     # 0x18ac99
leaq -0x40(%rbp), %rdi
callq 0x5c120
movq %rax, -0x120(%rbp)
jmp 0xcf278
movq -0x120(%rbp), %rdi
movl -0x20(%rbp), %esi
movq -0x58(%rbp), %rcx
movq %rsp, %rax
movq $0x0, (%rax)
xorl %eax, %eax
movl %eax, %r9d
leaq -0x5c(%rbp), %rdx
movq %r9, %r8
callq 0x5a370
jmp 0xcf2a3
movq -0x58(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movq -0x58(%rbp), %rdx
leaq 0xbb9dc(%rip), %rsi     # 0x18ac99
leaq -0x40(%rbp), %rdi
callq 0x5ae70
jmp 0xcf2c8
movq -0x58(%rbp), %rax
movq %rax, -0x128(%rbp)
cmpq $0x0, %rax
je 0xcf2e5
movq -0x128(%rbp), %rdi
callq 0x5a5e0
jmp 0xcf2f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xcf5fc
movl $0x0, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0xcf4a4
movl -0x64(%rbp), %esi
leaq -0x40(%rbp), %rdi
callq 0x5d4e0
movq %rax, -0x130(%rbp)
jmp 0xcf327
movq -0x130(%rbp), %rax
cmpl $0x9, (%rax)
je 0xcf338
jmp 0xcf496
movq -0x100(%rbp), %rax
movl 0x5e4(%rax), %ecx
movl %ecx, -0x134(%rbp)
movl -0x64(%rbp), %eax
cltd
idivl %ecx
movl -0x134(%rbp), %eax
subl %edx, %eax
movl %eax, -0x68(%rbp)
movl -0x64(%rbp), %edx
leaq -0x80(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x5d6b0
jmp 0xcf36e
leaq -0x98(%rbp), %rdi
xorl %esi, %esi
callq 0x5da90
jmp 0xcf37e
movl -0x68(%rbp), %edx
leaq -0x98(%rbp), %rdi
movl $0x20, %esi
callq 0x5c480
movq %rax, -0x140(%rbp)
jmp 0xcf39b
movq -0x140(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x5a710
movq %rax, -0x148(%rbp)
jmp 0xcf3b4
movl -0x20(%rbp), %eax
movl -0x64(%rbp), %edx
notl %edx
addl %eax, %edx
leaq -0xb0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x5c8a0
jmp 0xcf3d0
movq -0x148(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x5a710
movq %rax, -0x150(%rbp)
jmp 0xcf3ec
movq -0x150(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x59760
jmp 0xcf3fe
leaq -0xb0(%rbp), %rdi
callq 0x5df00
leaq -0x98(%rbp), %rdi
callq 0x5df00
leaq -0x80(%rbp), %rdi
callq 0x5df00
movl -0x68(%rbp), %eax
subl $0x1, %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x64(%rbp), %eax
movl -0x1c(%rbp), %ecx
addl -0x60(%rbp), %ecx
cmpl %ecx, %eax
jge 0xcf494
movl -0x68(%rbp), %eax
subl $0x1, %eax
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
jmp 0xcf494
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xcf486
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xcf47a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x5df00
leaq -0x98(%rbp), %rdi
callq 0x5df00
leaq -0x80(%rbp), %rdi
callq 0x5df00
jmp 0xcf5fc
jmp 0xcf496
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0xcf306
movq -0x100(%rbp), %rdi
movq (%rdi), %rax
movq 0x160(%rax), %rax
callq *%rax
movb %al, -0x151(%rbp)
jmp 0xcf4bf
movb -0x151(%rbp), %al
testb $0x1, %al
jne 0xcf55f
jmp 0xcf4cf
movq -0x100(%rbp), %rax
addq $0x140, %rax            # imm = 0x140
movq %rax, -0x160(%rbp)
movl -0x1c(%rbp), %edx
movl -0x60(%rbp), %eax
addl %eax, %edx
leaq -0xc8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x5d6b0
jmp 0xcf4fd
movq -0x160(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x5ac00
movl %eax, -0x164(%rbp)
jmp 0xcf518
movq -0x100(%rbp), %rcx
movl -0x164(%rbp), %eax
subl 0x5d0(%rcx), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x5df00
jmp 0xcf5ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x5df00
jmp 0xcf5fc
movq -0x100(%rbp), %rax
addq $0x140, %rax            # imm = 0x140
movq %rax, -0x170(%rbp)
movl -0x20(%rbp), %edx
movl -0x1c(%rbp), %eax
subl %eax, %edx
movl -0x60(%rbp), %eax
subl %eax, %edx
leaq -0xe0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x5c8a0
jmp 0xcf592
movq -0x170(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x5ac00
movl %eax, -0x174(%rbp)
jmp 0xcf5ad
movq -0x100(%rbp), %rcx
movl -0x174(%rbp), %eax
subl 0x5d0(%rcx), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x5df00
jmp 0xcf5ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x5df00
jmp 0xcf5fc
leaq -0x40(%rbp), %rdi
callq 0x5df00
jmp 0xcf6ac
leaq -0x40(%rbp), %rdi
callq 0x5df00
jmp 0xcf6be
movq -0x100(%rbp), %rax
addq $0x140, %rax            # imm = 0x140
movq %rax, -0x190(%rbp)
leaq -0xf8(%rbp), %rdi
movq %rdi, -0x188(%rbp)
xorl %esi, %esi
callq 0x5da90
movq -0x188(%rbp), %rdi
movl -0x1c(%rbp), %edx
movl $0x2a, %esi
callq 0x5c480
movq %rax, -0x180(%rbp)
jmp 0xcf650
movq -0x180(%rbp), %rsi
movq -0x190(%rbp), %rdi
callq 0x5ac00
movl %eax, -0x194(%rbp)
jmp 0xcf66b
movq -0x100(%rbp), %rcx
movl -0x194(%rbp), %eax
subl 0x5d0(%rcx), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x5df00
jmp 0xcf6ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x5df00
jmp 0xcf6be
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x5b6b0
nopw (%rax,%rax)