// File: /workspace/github_c_makefile_star2_O1/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 0x6348
testl %eax, %eax
je 0xa75a
xorb $0x20, 0x4(%r13)
movq (%r13), %rdi
movq 0x8(%r13), %rsi
movl %r12d, %edx
movl %ebp, %ecx
callq 0xa9f8
movl 0x1156e(%rip), %eax     # 0x1bce0
testb %al, %al
js 0xa8e9
movq %r15, %r13
shrq $0x20, %r13
andl $0x28d, %r13d           # imm = 0x28D
testb $0x20, %al
jne 0xa7d1
movl %r14d, %edi
movl %ebx, %esi
callq 0x6348
xorl %r12d, %r12d
testl %eax, %eax
leaq 0xad4e(%rip), %rax      # 0x154f0
leaq 0xad43(%rip), %rcx      # 0x154ec
cmoveq %rax, %rcx
sete %r12b
xorl $0x101, %r12d           # imm = 0x101
movq 0x11311(%rip), %rax     # 0x1bad0
movl %r12d, %edx
shll $0x4, %edx
movups (%rax,%rdx), %xmm0
movl (%rcx), %eax
movaps %xmm0, (%rsp)
jmp 0xa817
movzwl %r13w, %r13d
orl $0x20, %r13d
movl 0xad0c(%rip), %r12d     # 0x154ec
movl %r14d, %edi
movl %ebx, %esi
callq 0x6348
movq 0x112df(%rip), %rcx     # 0x1bad0
testl %eax, %eax
je 0xa807
movups 0x1000(%rcx), %xmm0
movaps %xmm0, (%rsp)
movl $0x101, %eax            # imm = 0x101
jmp 0xa817
movups 0x1010(%rcx), %xmm0
movaps %xmm0, (%rsp)
movl $0x100, %eax            # imm = 0x100
movl 0x114c3(%rip), %ecx     # 0x1bce0
testb $0x2, %cl
jne 0xa8f8
movq 0x11403(%rip), %rdi     # 0x1bc30
movl 0x114a8(%rip), %r8d     # 0x1bcdc
movl %r8d, %edx
imull %r14d, %edx
movl 0x11497(%rip), %ecx     # 0x1bcd8
imull %ebx, %ecx
decl %r8d
movq %rsp, %r15
movq %r15, %rsi
movl $0x1, %r9d
callq 0x53e0
movq 0x113d1(%rip), %rdi     # 0x1bc30
movl 0x11477(%rip), %edx     # 0x1bcdc
imull %r14d, %edx
movl 0x11468(%rip), %r9d     # 0x1bcd8
movl %r9d, %ecx
imull %ebx, %ecx
decl %r9d
movq %r15, %rsi
movl $0x1, %r8d
callq 0x53e0
movq 0x113a2(%rip), %rdi     # 0x1bc30
leal 0x1(%r14), %edx
imull 0x11443(%rip), %edx     # 0x1bcdc
decl %edx
movl 0x11436(%rip), %r9d     # 0x1bcd8
movl %r9d, %ecx
imull %ebx, %ecx
decl %r9d
movq %r15, %rsi
movl $0x1, %r8d
callq 0x53e0
movq 0x11370(%rip), %rdi     # 0x1bc30
movl 0x11415(%rip), %r8d     # 0x1bcdc
imull %r8d, %r14d
incl %ebx
imull 0x11404(%rip), %ebx     # 0x1bcd8
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 0x113e6(%rip), %edx     # 0x1bce4
cmpq $0x8, %rdx
ja 0xa8e9
leaq 0x4149(%rip), %rsi      # 0xea54
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
btl $0xb, %ecx
jb 0xa8e9
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 0xa9e0
btl $0xb, %ecx
jb 0xa8e9
movq 0x112e2(%rip), %rdi     # 0x1bc30
movl 0x11387(%rip), %r8d     # 0x1bcdc
imull %r8d, %r14d
incl %ebx
imull 0x11376(%rip), %ebx     # 0x1bcd8
addl $-0x2, %ebx
movq %rsp, %rsi
movl %r14d, %edx
movl %ebx, %ecx
movl $0x2, %r9d
jmp 0xa8e4
btl $0xb, %ecx
jb 0xa8e9
movq 0x112a7(%rip), %rdi     # 0x1bc30
imull 0x1134b(%rip), %r14d    # 0x1bcdc
movl 0x11340(%rip), %r9d     # 0x1bcd8
imull %r9d, %ebx
movq %rsp, %rsi
movl %r14d, %edx
movl %ebx, %ecx
movl $0x2, %r8d
jmp 0xa8e4
btl $0xb, %ecx
jb 0xa8e9
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 0xa9f8