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

	if (length == 0) return 0;

	String	 wText = text;
	Int	 wPromptPos = promptPos;

	if (Binary::IsFlagSet(GetFlags(), CF_MULTILINE))
	{
		Int	 lineStart  = promptPos;
		Int	 lineLength = 0;

		for (Int i = promptPos - 1; i >= 0;	 i--) { if (text[i] == '\n')		     break; lineStart--;  }
		for (Int i = lineStart;	    i <  length; i++) { if (text[i] == '\n' || text[i] == 0) break; lineLength++; }

		wText = text.SubString(lineStart, lineLength);
		wPromptPos = promptPos - lineStart;
	}

	return GetDisplayCursorPositionFromLogical(wText, wPromptPos);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x78(%rbp)
addq $0xf0, %rdi
callq 0x5b800
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jne 0xcf94b
movl $0x0, -0x4(%rbp)
jmp 0xcfaf7
movq -0x78(%rbp), %rsi
addq $0xf0, %rsi
leaq -0x30(%rbp), %rdi
callq 0x5b6d0
movq -0x78(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, -0x34(%rbp)
callq 0x5a120
movl %eax, -0x7c(%rbp)
jmp 0xcf973
movl -0x7c(%rbp), %edi
movl $0x1, %esi
callq 0x5ce30
movb %al, -0x7d(%rbp)
jmp 0xcf985
movb -0x7d(%rbp), %al
testb $0x1, %al
jne 0xcf991
jmp 0xcfac0
movl -0x14(%rbp), %eax
movl %eax, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x50(%rbp)
cmpl $0x0, -0x50(%rbp)
jl 0xcf9fa
movq -0x78(%rbp), %rdi
addq $0xf0, %rdi
movl -0x50(%rbp), %esi
callq 0x5c900
movl %eax, -0x84(%rbp)
jmp 0xcf9c8
movl -0x84(%rbp), %eax
cmpl $0xa, %eax
jne 0xcf9e6
jmp 0xcf9fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xcfaec
movl -0x48(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x48(%rbp)
movl -0x50(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0xcf9a7
movl -0x48(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0xcfa6a
movq -0x78(%rbp), %rdi
addq $0xf0, %rdi
movl -0x54(%rbp), %esi
callq 0x5c900
movl %eax, -0x88(%rbp)
jmp 0xcfa23
movl -0x88(%rbp), %eax
cmpl $0xa, %eax
je 0xcfa54
movq -0x78(%rbp), %rdi
addq $0xf0, %rdi
movl -0x54(%rbp), %esi
callq 0x5c900
movl %eax, -0x8c(%rbp)
jmp 0xcfa49
movl -0x8c(%rbp), %eax
cmpl $0x0, %eax
jne 0xcfa56
jmp 0xcfa6a
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0xcfa00
movq -0x78(%rbp), %rsi
addq $0xf0, %rsi
movl -0x48(%rbp), %edx
movl -0x4c(%rbp), %ecx
leaq -0x70(%rbp), %rdi
callq 0x5dc20
jmp 0xcfa86
leaq -0x30(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x59760
jmp 0xcfa95
leaq -0x70(%rbp), %rdi
callq 0x5df00
movl -0x14(%rbp), %eax
subl -0x48(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0xcfac0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x5df00
jmp 0xcfaec
movq -0x78(%rbp), %rdi
movl -0x34(%rbp), %edx
leaq -0x30(%rbp), %rsi
callq 0x592b0
movl %eax, -0x90(%rbp)
jmp 0xcfad8
movl -0x90(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x5df00
jmp 0xcfaf7
leaq -0x30(%rbp), %rdi
callq 0x5df00
jmp 0xcfb03
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x5b6b0
nopl (%rax)