// File: /workspace/github_c_makefile_star2_O3/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 0x641e
testl %eax, %eax
je 0xac20
xorb $0x20, 0x4(%r13)
movq (%r13), %rdi
movq 0x8(%r13), %rsi
movl %r12d, %edx
movl %ebp, %ecx
callq 0xaebe
movl 0x120a8(%rip), %eax     # 0x1cce0
testb %al, %al
js 0xadaf
movq %r15, %r13
shrq $0x20, %r13
andl $0x28d, %r13d           # imm = 0x28D
testb $0x20, %al
jne 0xac97
movl %r14d, %edi
movl %ebx, %esi
callq 0x641e
xorl %r12d, %r12d
testl %eax, %eax
leaq 0xb888(%rip), %rax      # 0x164f0
leaq 0xb87d(%rip), %rcx      # 0x164ec
cmoveq %rax, %rcx
sete %r12b
xorl $0x101, %r12d           # imm = 0x101
movq 0x11e4b(%rip), %rax     # 0x1cad0
movl %r12d, %edx
shll $0x4, %edx
movups (%rax,%rdx), %xmm0
movl (%rcx), %eax
movaps %xmm0, (%rsp)
jmp 0xacdd
movzwl %r13w, %r13d
orl $0x20, %r13d
movl 0xb846(%rip), %r12d     # 0x164ec
movl %r14d, %edi
movl %ebx, %esi
callq 0x641e
movq 0x11e19(%rip), %rcx     # 0x1cad0
testl %eax, %eax
je 0xaccd
movups 0x1000(%rcx), %xmm0
movaps %xmm0, (%rsp)
movl $0x101, %eax            # imm = 0x101
jmp 0xacdd
movups 0x1010(%rcx), %xmm0
movaps %xmm0, (%rsp)
movl $0x100, %eax            # imm = 0x100
movl 0x11ffd(%rip), %ecx     # 0x1cce0
testb $0x2, %cl
jne 0xadbe
movq 0x11f3d(%rip), %rdi     # 0x1cc30
movl 0x11fe2(%rip), %r8d     # 0x1ccdc
movl %r8d, %edx
imull %r14d, %edx
movl 0x11fd1(%rip), %ecx     # 0x1ccd8
imull %ebx, %ecx
decl %r8d
movq %rsp, %r15
movq %r15, %rsi
movl $0x1, %r9d
callq 0x53e0
movq 0x11f0b(%rip), %rdi     # 0x1cc30
movl 0x11fb1(%rip), %edx     # 0x1ccdc
imull %r14d, %edx
movl 0x11fa2(%rip), %r9d     # 0x1ccd8
movl %r9d, %ecx
imull %ebx, %ecx
decl %r9d
movq %r15, %rsi
movl $0x1, %r8d
callq 0x53e0
movq 0x11edc(%rip), %rdi     # 0x1cc30
leal 0x1(%r14), %edx
imull 0x11f7d(%rip), %edx     # 0x1ccdc
decl %edx
movl 0x11f70(%rip), %r9d     # 0x1ccd8
movl %r9d, %ecx
imull %ebx, %ecx
decl %r9d
movq %r15, %rsi
movl $0x1, %r8d
callq 0x53e0
movq 0x11eaa(%rip), %rdi     # 0x1cc30
movl 0x11f4f(%rip), %r8d     # 0x1ccdc
imull %r8d, %r14d
incl %ebx
imull 0x11f3e(%rip), %ebx     # 0x1ccd8
decl %ebx
movq %r15, %rsi
movl %r14d, %edx
movl %ebx, %ecx
movl $0x1, %r9d
callq 0x53e0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x11f20(%rip), %edx     # 0x1cce4
cmpq $0x8, %rdx
ja 0xadaf
leaq 0x4cb3(%rip), %rsi      # 0xfa84
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
btl $0xb, %ecx
jb 0xadaf
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 0xaea6
btl $0xb, %ecx
jb 0xadaf
movq 0x11e1c(%rip), %rdi     # 0x1cc30
movl 0x11ec1(%rip), %r8d     # 0x1ccdc
imull %r8d, %r14d
incl %ebx
imull 0x11eb0(%rip), %ebx     # 0x1ccd8
addl $-0x2, %ebx
movq %rsp, %rsi
movl %r14d, %edx
movl %ebx, %ecx
movl $0x2, %r9d
jmp 0xadaa
btl $0xb, %ecx
jb 0xadaf
movq 0x11de1(%rip), %rdi     # 0x1cc30
imull 0x11e85(%rip), %r14d    # 0x1ccdc
movl 0x11e7a(%rip), %r9d     # 0x1ccd8
imull %r9d, %ebx
movq %rsp, %rsi
movl %r14d, %edx
movl %ebx, %ecx
movl $0x2, %r8d
jmp 0xadaa
btl $0xb, %ecx
jb 0xadaf
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 0xaebe