// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/classes/gui/window/backends/xlib/windowxlib.cpp
// Function: smooth::GUI::WindowXLib::OnXIMPreeditDraw(X11::_XIMPreeditDrawCallbackStruct*)
S::Void S::GUI::WindowXLib::OnXIMPreeditDraw(XIMPreeditDrawCallbackStruct *data)
{
	if (activeCursor == NIL) return;

	/* Get preedit string if any.
	 */
	String	 string;

	if (data->text != NIL)
	{
		if (data->text->encoding_is_wchar) string = data->text->string.wide_char;
		else				   string.ImportFrom("UTF-8", data->text->string.multi_byte);
	}

	/* Draw string at cursor position.
	 */
	Rect	 rect = Rect::OverlapRect(Rect(activeCursorPos - Point(1, 1), activeCursor->GetRealSize()), Rect(activeCursor->GetRealPosition(), activeCursor->GetRealSize()));

	activeCursor->SetIMECursor(True);

	drawSurface->StartPaint(rect);
	drawSurface->Box(rect, activeCursor->GetBackgroundColor(), Rect::Filled);

	if (data->text != NIL)
	{
		for (Int i = 0; i < data->text->length; i++)
		{
			Font	 font = activeCursor->GetFont();

			if (data->text->feedback != NIL)
			{
				if (data->text->feedback[i] & XIMUnderline) font.SetStyle(Font::Underline);
			}

			drawSurface->SetText(string.SubString(i, 1), rect + Point(font.GetScaledTextSizeX(string.Head(i)), 0), font);
		}
	}

	drawSurface->EndPaint();

	activeCursor->SetIMEAdvance(activeCursor->GetFont().GetScaledTextSizeX(string.Head(data->caret)));
	activeCursor->SetIMECursor(False);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdi, 0x8(%rsp)
cmpq $0x0, 0xb0fb0(%rip)     # 0x16cdc8
je 0xbc0db
movq %rsi, %r15
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x5a180
movq 0x10(%r15), %rax
testq %rax, %rax
je 0xbbe60
cmpl $0x0, 0x10(%rax)
movq 0x18(%rax), %rdx
je 0xbbe4f
leaq 0x30(%rsp), %rdi
movq %rdx, %rsi
callq 0x5a270
jmp 0xbbe60
leaq 0x46370(%rip), %rsi     # 0x1021c6
leaq 0x30(%rsp), %rdi
callq 0x57ab0
movl 0xb0f69(%rip), %r14d    # 0x16cdd0
movl 0xb0f67(%rip), %ebx     # 0x16cdd4
movq 0xb0f54(%rip), %rdi     # 0x16cdc8
movq (%rdi), %rax
callq *0x50(%rax)
leal -0x1(%r14), %ecx
leal -0x1(%rbx), %edx
movq %rax, %rsi
shrq $0x20, %rsi
movl %ecx, 0x70(%rsp)
movl %edx, 0x74(%rsp)
addl %r14d, %eax
decl %eax
movl %eax, 0x78(%rsp)
leal -0x1(%rbx,%rsi), %eax
movl %eax, 0x7c(%rsp)
movq 0xb0f20(%rip), %rdi     # 0x16cdc8
movq (%rdi), %rax
callq *0x48(%rax)
movq %rax, %rbx
movq 0xb0f10(%rip), %rdi     # 0x16cdc8
movq (%rdi), %rax
callq *0x50(%rax)
movq %rbx, %rcx
shrq $0x20, %rcx
movq %rax, %rdx
shrq $0x20, %rdx
leaq 0x48(%rsp), %rsi
movl %ebx, (%rsi)
movl %ecx, 0x4(%rsi)
addl %ebx, %eax
movl %eax, 0x8(%rsi)
addl %ecx, %edx
movl %edx, 0xc(%rsi)
leaq 0x70(%rsp), %rdi
callq 0x59e30
movq %rax, 0x20(%rsp)
movq %rdx, 0x28(%rsp)
movq 0xb0ecd(%rip), %rdi     # 0x16cdc8
pushq $0x1
popq %rsi
callq 0x58ec0
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x20(%rsp), %rsi
callq 0x56160
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rbx
movq 0xb0ea2(%rip), %rdi     # 0x16cdc8
movq (%rdi), %rax
callq *0x140(%rax)
movq 0xa6072(%rip), %rcx     # 0x161fa8
movl (%rcx), %ecx
leaq 0x70(%rsp), %r8
andq $0x0, (%r8)
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0x58b80
movq %r15, 0x10(%rsp)
movq 0x10(%r15), %rax
testq %rax, %rax
je 0xbc067
xorl %r15d, %r15d
leaq 0x70(%rsp), %r12
leaq 0x30(%rsp), %rbp
leaq 0xb0(%rsp), %r13
movzwl (%rax), %eax
cmpq %rax, %r15
jae 0xbc067
movq 0xb0e3d(%rip), %rdi     # 0x16cdc8
movq (%rdi), %rax
callq *0xe8(%rax)
movq %r12, %rdi
movq %rax, %rsi
callq 0x56bf0
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
je 0xbbfca
testb $0x2, (%rax,%r15,8)
je 0xbbfca
movq 0xa59d9(%rip), %rax     # 0x161998
movswl (%rax), %esi
movq %r12, %rdi
callq 0x56580
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rbx
leaq 0x48(%rsp), %rdi
movq %rbp, %r14
movq %rbp, %rsi
movl %r15d, %edx
pushq $0x1
popq %rcx
callq 0x5a2c0
movq %r13, %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x59e40
movq %r12, %rdi
movq %r13, %rsi
callq 0x57870
movl %eax, 0x18(%rsp)
andl $0x0, 0x1c(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x58930
movq %rax, 0x60(%rsp)
movq %rdx, 0x68(%rsp)
movq %rbx, %rdi
leaq 0x48(%rsp), %rsi
leaq 0x60(%rsp), %rdx
movq %r12, %rcx
xorl %r8d, %r8d
callq 0x58df0
movq %r13, %rdi
callq 0x5a588
leaq 0x48(%rsp), %rdi
callq 0x5a588
movq %r12, %rdi
callq 0x57860
incq %r15
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rax
jmp 0xbbf78
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x59a80
movq 0x10(%rsp), %rbp
movq 0xb0d47(%rip), %rbx     # 0x16cdc8
movq (%rbx), %rax
movq %rbx, %rdi
callq *0xe8(%rax)
movq %rax, %r14
movl (%rbp), %edx
leaq 0x70(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x59e40
leaq 0x70(%rsp), %rsi
movq %r14, %rdi
callq 0x57870
movq %rbx, %rdi
movl %eax, %esi
callq 0x56f70
leaq 0x70(%rsp), %rdi
callq 0x5a588
movq 0xb0cfe(%rip), %rdi     # 0x16cdc8
xorl %esi, %esi
callq 0x58ec0
leaq 0x30(%rsp), %rdi
callq 0x5a588
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xbc116
jmp 0xbc116
jmp 0xbc116
jmp 0xbc116
jmp 0xbc116
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x5a588
jmp 0xbc13f
jmp 0xbc116
jmp 0xbc116
jmp 0xbc111
movq %rax, %rbx
jmp 0xbc12b
movq %rax, %rbx
jmp 0xbc135
movq %rax, %rbx
jmp 0xbc13f
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x5a588
leaq 0x48(%rsp), %rdi
callq 0x5a588
leaq 0x70(%rsp), %rdi
callq 0x57860
leaq 0x30(%rsp), %rdi
callq 0x5a588
movq %rbx, %rdi
callq 0x58260
nop