// File: /workspace/github_c_makefile_star2_O2/khuedoan[P]st/x.c
// Function: xdrawcursor
void
xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
{
	Color drawcol;

	/* remove the old cursor */
	if (selected(ox, oy))
		og.mode ^= ATTR_REVERSE;
	xdrawglyph(og, ox, oy);

	if (IS_SET(MODE_HIDE))
		return;

	/*
	 * Select the right color for the right mode.
	 */
	g.mode &= ATTR_BOLD|ATTR_ITALIC|ATTR_UNDERLINE|ATTR_STRUCK|ATTR_WIDE;

	if (IS_SET(MODE_REVERSE)) {
		g.mode |= ATTR_REVERSE;
		g.bg = defaultfg;
		if (selected(cx, cy)) {
			drawcol = dc.col[defaultcs];
			g.fg = defaultrcs;
		} else {
			drawcol = dc.col[defaultrcs];
			g.fg = defaultcs;
		}
	} else {
		if (selected(cx, cy)) {
			g.fg = defaultfg;
			g.bg = defaultrcs;
		} else {
			g.fg = defaultbg;
			g.bg = defaultcs;
		}
		drawcol = dc.col[g.bg];
	}

	/* draw the new one */
	if (IS_SET(MODE_FOCUSED)) {
		switch (win.cursor) {
		case 0: /* Blinking block */
		case 1: /* Blinking block (default) */
			if (IS_SET(MODE_BLINK))
				break;
			/* FALLTHROUGH */
		case 2: /* Steady block */
			xdrawglyph(g, cx, cy);
			break;
		case 3: /* Blinking underline */
			if (IS_SET(MODE_BLINK))
				break;
			/* FALLTHROUGH */
		case 4: /* Steady underline */
			XftDrawRect(xw.draw, &drawcol,
					borderpx + cx * win.cw,
					borderpx + (cy + 1) * win.ch - \
						cursorthickness,
					win.cw, cursorthickness);
			break;
		case 5: /* Blinking bar */
			if (IS_SET(MODE_BLINK))
				break;
			/* FALLTHROUGH */
		case 6: /* Steady bar */
			XftDrawRect(xw.draw, &drawcol,
					borderpx + cx * win.cw,
					borderpx + cy * win.ch,
					cursorthickness, win.ch);
			break;
		case 7: /* Blinking st cursor */
			if (IS_SET(MODE_BLINK))
				break;
			/* FALLTHROUGH */
		case 8: /* Steady st cursor */
			g.u = stcursor;
			xdrawglyph(g, cx, cy);
			break;
		}
	} else {
		XftDrawRect(xw.draw, &drawcol,
				borderpx + cx * win.cw,
				borderpx + cy * win.ch,
				win.cw - 1, 1);
		XftDrawRect(xw.draw, &drawcol,
				borderpx + cx * win.cw,
				borderpx + cy * win.ch,
				1, win.ch - 1);
		XftDrawRect(xw.draw, &drawcol,
				borderpx + (cx + 1) * win.cw - 1,
				borderpx + cy * win.ch,
				1, win.ch - 1);
		XftDrawRect(xw.draw, &drawcol,
				borderpx + cx * win.cw,
				borderpx + (cy + 1) * win.ch - 1,
				win.cw, 1);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r9d, %ebp
movl %r8d, %r12d
movq %rdx, %r15
movl %esi, %ebx
movl %edi, %r14d
leaq 0x50(%rsp), %r13
movl %r8d, %edi
movl %r9d, %esi
callq 0x5edf
testl %eax, %eax
je 0x9f28
xorb $0x20, 0x4(%r13)
movq (%r13), %rdi
movq 0x8(%r13), %rsi
movl %r12d, %edx
movl %ebp, %ecx
callq 0xa1b1
movl 0x11da0(%rip), %eax     # 0x1bce0
testb %al, %al
js 0xa15d
movq %r15, %r13
shrq $0x20, %r13
andl $0x28d, %r13d           # imm = 0x28D
testb $0x20, %al
jne 0x9f9f
movl %r14d, %edi
movl %ebx, %esi
callq 0x5edf
xorl %r12d, %r12d
testl %eax, %eax
leaq 0xb580(%rip), %rax      # 0x154f0
leaq 0xb575(%rip), %rcx      # 0x154ec
cmoveq %rax, %rcx
sete %r12b
xorl $0x101, %r12d           # imm = 0x101
movq 0x11b43(%rip), %rax     # 0x1bad0
movl %r12d, %edx
shll $0x4, %edx
movups (%rax,%rdx), %xmm0
movl (%rcx), %eax
movaps %xmm0, (%rsp)
jmp 0x9fe5
movzwl %r13w, %r13d
orl $0x20, %r13d
movl 0xb53e(%rip), %r12d     # 0x154ec
movl %r14d, %edi
movl %ebx, %esi
callq 0x5edf
movq 0x11b11(%rip), %rcx     # 0x1bad0
testl %eax, %eax
je 0x9fd5
movups 0x1000(%rcx), %xmm0
movaps %xmm0, (%rsp)
movl $0x101, %eax            # imm = 0x101
jmp 0x9fe5
movups 0x1010(%rcx), %xmm0
movaps %xmm0, (%rsp)
movl $0x100, %eax            # imm = 0x100
movl 0x11cf5(%rip), %ecx     # 0x1bce0
testb $0x2, %cl
jne 0xa0ae
movq 0x11c35(%rip), %rdi     # 0x1bc30
movl 0x11cda(%rip), %r8d     # 0x1bcdc
movl %r8d, %edx
imull %r14d, %edx
movl 0x11cc9(%rip), %ecx     # 0x1bcd8
imull %ebx, %ecx
decl %r8d
movq %rsp, %r15
pushq $0x1
popq %rbp
movq %r15, %rsi
movl %ebp, %r9d
callq 0x53e0
movq 0x11c03(%rip), %rdi     # 0x1bc30
movl 0x11ca9(%rip), %edx     # 0x1bcdc
imull %r14d, %edx
movl 0x11c9a(%rip), %r9d     # 0x1bcd8
movl %r9d, %ecx
imull %ebx, %ecx
decl %r9d
movq %r15, %rsi
movl %ebp, %r8d
callq 0x53e0
movq 0x11bd7(%rip), %rdi     # 0x1bc30
leal 0x1(%r14), %edx
imull 0x11c78(%rip), %edx     # 0x1bcdc
decl %edx
movl 0x11c6b(%rip), %r9d     # 0x1bcd8
movl %r9d, %ecx
imull %ebx, %ecx
decl %r9d
movq %r15, %rsi
movl %ebp, %r8d
callq 0x53e0
movq 0x11ba8(%rip), %rdi     # 0x1bc30
movl 0x11c4d(%rip), %r8d     # 0x1bcdc
imull %r8d, %r14d
incl %ebx
imull 0x11c3c(%rip), %ebx     # 0x1bcd8
decl %ebx
movq %r15, %rsi
movl %r14d, %edx
movl %ebx, %ecx
movl %ebp, %r9d
jmp 0xa158
movl 0x11c30(%rip), %edx     # 0x1bce4
cmpq $0x8, %rdx
ja 0xa15d
leaq 0x498f(%rip), %rsi      # 0xea54
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
btl $0xb, %ecx
jb 0xa15d
movzwl %r13w, %ecx
shlq $0x20, %rcx
movabsq $-0xffff00000001, %rdx  # imm = 0xFFFF0000FFFFFFFF
andq %rdx, %r15
orq %rcx, %r15
shlq $0x20, %r12
orq %rax, %r12
movq %r15, %rdi
jmp 0xa199
btl $0xb, %ecx
jb 0xa15d
movq 0x11b24(%rip), %rdi     # 0x1bc30
movl 0x11bc9(%rip), %r8d     # 0x1bcdc
imull %r8d, %r14d
incl %ebx
imull 0x11bb8(%rip), %ebx     # 0x1bcd8
addl $-0x2, %ebx
movq %rsp, %rsi
pushq $0x2
popq %r9
jmp 0xa153
btl $0xb, %ecx
jb 0xa15d
movq 0x11af7(%rip), %rdi     # 0x1bc30
imull 0x11b9b(%rip), %r14d    # 0x1bcdc
movl 0x11b90(%rip), %r9d     # 0x1bcd8
imull %r9d, %ebx
movq %rsp, %rsi
pushq $0x2
popq %r8
movl %r14d, %edx
movl %ebx, %ecx
callq 0x53e0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
btl $0xb, %ecx
jb 0xa15d
movabsq $-0x1000000000000, %rcx # imm = 0xFFFF000000000000
andq %rcx, %r15
movzwl %r13w, %ecx
shlq $0x20, %rcx
leaq (%rcx,%r15), %rdi
addq $0x2603, %rdi           # imm = 0x2603
shlq $0x20, %r12
orq %rax, %r12
movq %r12, %rsi
movl %r14d, %edx
movl %ebx, %ecx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa1b1