// File: /workspace/github_c_makefile_star2_O2/odknt[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 7: /* st extension */
			g.u = 0x2603; /* snowman (U+2603) */
			/* FALLTHROUGH */
		case 0: /* Blinking Block */
		case 1: /* Blinking Block (Default) */
		case 2: /* Steady Block */
			xdrawglyph(g, cx, cy);
			break;
		case 3: /* Blinking Underline */
		case 4: /* Steady Underline */
			xdrawrect(&drawcol, borderpx + cx * win.cw,
			          borderpx + (cy + 1) * win.ch - cursorthickness,
			          win.cw, cursorthickness);
			break;
		case 5: /* Blinking bar */
		case 6: /* Steady bar */
			xdrawrect(&drawcol, borderpx + cx * win.cw,
			          borderpx + cy * win.ch,
			          cursorthickness, win.ch);
			break;
		}
	} else {
		xdrawrect(&drawcol,
		          borderpx + cx * win.cw,
		          borderpx + cy * win.ch,
		          win.cw - 1, 1);
		xdrawrect(&drawcol,
		          borderpx + cx * win.cw,
		          borderpx + cy * win.ch,
		          1, win.ch - 1);
		xdrawrect(&drawcol,
		          borderpx + (cx + 1) * win.cw - 1,
		          borderpx + cy * win.ch,
		          1, win.ch - 1);
		xdrawrect(&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, %r14d
movl %edi, %ebx
leaq 0x50(%rsp), %r13
movl %r8d, %edi
movl %r9d, %esi
callq 0x707f
testl %eax, %eax
je 0xb8f7
xorb $0x20, 0x4(%r13)
movq (%r13), %rdi
movq 0x8(%r13), %rsi
movl %r12d, %edx
movl %ebp, %ecx
callq 0xbb54
movl 0x13035(%rip), %eax     # 0x1e944
testb %al, %al
js 0xba8b
movq %r15, %r12
shrq $0x20, %r12
andl $0x28d, %r12d           # imm = 0x28D
testb $0x20, %al
jne 0xb96f
movl %ebx, %edi
movl %r14d, %esi
callq 0x707f
testl %eax, %eax
movl $0x101, %r13d           # imm = 0x101
cmovel 0xbc81(%rip), %r13d     # 0x175c4
leaq 0xbc76(%rip), %rax      # 0x175c0
leaq 0xbc6b(%rip), %rcx      # 0x175bc
cmoveq %rax, %rcx
movl (%rcx), %eax
movq 0x12d6a(%rip), %rcx     # 0x1e6c8
movq %r13, %rdx
shlq $0x4, %rdx
movups (%rcx,%rdx), %xmm0
movaps %xmm0, (%rsp)
jmp 0xb9bd
movzwl %r12w, %r12d
orl $0x20, %r12d
movl 0xbc3e(%rip), %r13d     # 0x175bc
movl %ebx, %edi
movl %r14d, %esi
callq 0x707f
movq 0x12d39(%rip), %rcx     # 0x1e6c8
testl %eax, %eax
je 0xb9ac
movl 0xbc2b(%rip), %eax      # 0x175c4
shlq $0x4, %rax
movups (%rcx,%rax), %xmm0
movaps %xmm0, (%rsp)
movl $0x101, %eax            # imm = 0x101
jmp 0xb9bd
movups 0x1010(%rcx), %xmm0
movaps %xmm0, (%rsp)
movl 0xbc07(%rip), %eax      # 0x175c4
testb $0x2, 0x12f80(%rip)     # 0x1e944
jne 0xba9a
movl 0xc43c(%rip), %eax      # 0x17e0c
movl 0x12f66(%rip), %ecx     # 0x1e93c
movl %ecx, %esi
imull %ebx, %esi
addl %eax, %esi
movl 0x12f55(%rip), %edx     # 0x1e938
imull %r14d, %edx
addl %eax, %edx
decl %ecx
movq %rsp, %r15
pushq $0x1
popq %rbp
movq %r15, %rdi
movl %ebp, %r8d
callq 0xbbac
movl 0xc40a(%rip), %eax      # 0x17e0c
movl 0x12f34(%rip), %esi     # 0x1e93c
imull %ebx, %esi
addl %eax, %esi
movl 0x12f24(%rip), %r8d     # 0x1e938
movl %r8d, %edx
imull %r14d, %edx
addl %eax, %edx
decl %r8d
movq %r15, %rdi
movl %ebp, %ecx
callq 0xbbac
movl 0xc3dc(%rip), %eax      # 0x17e0c
leal 0x1(%rbx), %ecx
imull 0x12f02(%rip), %ecx     # 0x1e93c
leal (%rax,%rcx), %esi
decl %esi
movl 0x12ef2(%rip), %r8d     # 0x1e938
movl %r8d, %edx
imull %r14d, %edx
addl %eax, %edx
decl %r8d
movq %r15, %rdi
movl %ebp, %ecx
callq 0xbbac
movl 0xc3aa(%rip), %eax      # 0x17e0c
movl 0x12ed4(%rip), %ecx     # 0x1e93c
imull %ecx, %ebx
addl %eax, %ebx
incl %r14d
imull 0x12ec0(%rip), %r14d    # 0x1e938
leal (%rax,%r14), %edx
decl %edx
movq %r15, %rdi
movl %ebx, %esi
movl %ebp, %r8d
callq 0xbbac
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x12ea8(%rip), %ecx     # 0x1e948
cmpq $0x7, %rcx
ja 0xba8b
leaq 0x5103(%rip), %rdx      # 0x10bb0
movslq (%rdx,%rcx,4), %rsi
addq %rdx, %rsi
movq %r15, %rcx
jmpq *%rsi
movl 0xc34d(%rip), %eax      # 0x17e0c
movl 0x12e77(%rip), %ecx     # 0x1e93c
imull %ecx, %ebx
addl %eax, %ebx
incl %r14d
imull 0x12e63(%rip), %r14d    # 0x1e938
leal (%rax,%r14), %edx
addl $-0x2, %edx
movq %rsp, %rdi
pushq $0x2
popq %r8
movl %ebx, %esi
jmp 0xba86
movl 0xc31f(%rip), %eax      # 0x17e0c
imull 0x12e48(%rip), %ebx     # 0x1e93c
addl %eax, %ebx
movl 0x12e3b(%rip), %r8d     # 0x1e938
imull %r8d, %r14d
addl %eax, %r14d
movq %rsp, %rdi
pushq $0x2
popq %rcx
movl %ebx, %esi
movl %r14d, %edx
jmp 0xba86
movl $0x2603, %ecx           # imm = 0x2603
movabsq $-0x1000000000000, %rdx # imm = 0xFFFF000000000000
andq %rdx, %r15
movzwl %r12w, %edx
shlq $0x20, %rdx
movl %ecx, %edi
orq %r15, %rdi
orq %rdx, %rdi
shlq $0x20, %r13
movl %eax, %esi
orq %r13, %rsi
movl %ebx, %edx
movl %r14d, %ecx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xbb54