// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
leaq 0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq %rdx, -0x10(%rbp)
movq %rcx, -0x8(%rbp)
movl %edi, -0x14(%rbp)
movl %esi, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movl %r9d, -0x20(%rbp)
movl -0x1c(%rbp), %edi
movl -0x20(%rbp), %esi
callq 0x7380
cmpl $0x0, %eax
je 0xe625
movq -0x38(%rbp), %rax
movzwl 0x4(%rax), %ecx
xorl $0x20, %ecx
movw %cx, 0x4(%rax)
movq -0x38(%rbp), %rax
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
movq (%rax), %rdi
movq 0x8(%rax), %rsi
callq 0xe920
movl 0x14093(%rip), %eax     # 0x226d4
andl $0x80, %eax
cmpl $0x0, %eax
je 0xe650
jmp 0xe91a
movzwl -0xc(%rbp), %eax
andl $0x28d, %eax            # imm = 0x28D
movw %ax, -0xc(%rbp)
movl 0x14071(%rip), %eax     # 0x226d4
andl $0x20, %eax
cmpl $0x0, %eax
je 0xe6ef
movzwl -0xc(%rbp), %eax
orl $0x20, %eax
movw %ax, -0xc(%rbp)
movl 0xb12c(%rip), %eax      # 0x197ac
movl %eax, -0x4(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x7380
cmpl $0x0, %eax
je 0xe6c1
movq 0x13dbe(%rip), %rax     # 0x22458
movl 0xb114(%rip), %ecx      # 0x197b4
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x30(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movl 0xbc0c(%rip), %eax      # 0x1a2c8
movl %eax, -0x8(%rbp)
jmp 0xe6ed
movq 0x13d90(%rip), %rax     # 0x22458
movl 0xbbfa(%rip), %ecx      # 0x1a2c8
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x30(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movl 0xb0ca(%rip), %eax      # 0x197b4
movl %eax, -0x8(%rbp)
jmp 0xe745
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x7380
cmpl $0x0, %eax
je 0xe713
movl 0xb0a7(%rip), %eax      # 0x197ac
movl %eax, -0x8(%rbp)
movl 0xbbba(%rip), %eax      # 0x1a2c8
movl %eax, -0x4(%rbp)
jmp 0xe725
movl 0xb097(%rip), %eax      # 0x197b0
movl %eax, -0x8(%rbp)
movl 0xb092(%rip), %eax      # 0x197b4
movl %eax, -0x4(%rbp)
movq 0x13d2c(%rip), %rax     # 0x22458
movl -0x4(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x30(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movl 0x13f89(%rip), %eax     # 0x226d4
andl $0x2, %eax
cmpl $0x0, %eax
je 0xe81f
movl 0x13f7b(%rip), %eax     # 0x226d8
movq %rax, -0x40(%rbp)
subq $0x7, %rax
ja 0xe81a
movq -0x40(%rbp), %rax
leaq 0x66e6(%rip), %rcx      # 0x14e5c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x2603, -0x10(%rbp)    # imm = 0x2603
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0xe920
jmp 0xe81a
movl 0xb85b(%rip), %esi      # 0x19ffc
movl -0x14(%rbp), %eax
imull 0x13f21(%rip), %eax     # 0x226cc
addl %eax, %esi
movl 0xb849(%rip), %edx      # 0x19ffc
movl -0x18(%rbp), %eax
addl $0x1, %eax
imull 0x13f08(%rip), %eax     # 0x226c8
addl %eax, %edx
subl 0xbb04(%rip), %edx      # 0x1a2cc
movl 0x13efe(%rip), %ecx     # 0x226cc
movl 0xbaf7(%rip), %r8d      # 0x1a2cc
leaq -0x30(%rbp), %rdi
callq 0xe980
jmp 0xe81a
movl 0xb816(%rip), %esi      # 0x19ffc
movl -0x14(%rbp), %eax
imull 0x13edc(%rip), %eax     # 0x226cc
addl %eax, %esi
movl 0xb804(%rip), %edx      # 0x19ffc
movl -0x18(%rbp), %eax
imull 0x13ec6(%rip), %eax     # 0x226c8
addl %eax, %edx
movl 0xbac2(%rip), %ecx      # 0x1a2cc
movl 0x13eb7(%rip), %r8d     # 0x226c8
leaq -0x30(%rbp), %rdi
callq 0xe980
jmp 0xe91a
movl 0xb7d7(%rip), %esi      # 0x19ffc
movl -0x14(%rbp), %eax
imull 0x13e9d(%rip), %eax     # 0x226cc
addl %eax, %esi
movl 0xb7c5(%rip), %edx      # 0x19ffc
movl -0x18(%rbp), %eax
imull 0x13e87(%rip), %eax     # 0x226c8
addl %eax, %edx
movl 0x13e83(%rip), %ecx     # 0x226cc
subl $0x1, %ecx
leaq -0x30(%rbp), %rdi
movl $0x1, %r8d
callq 0xe980
movl 0xb79b(%rip), %esi      # 0x19ffc
movl -0x14(%rbp), %eax
imull 0x13e61(%rip), %eax     # 0x226cc
addl %eax, %esi
movl 0xb789(%rip), %edx      # 0x19ffc
movl -0x18(%rbp), %eax
imull 0x13e4b(%rip), %eax     # 0x226c8
addl %eax, %edx
movl 0x13e42(%rip), %r8d     # 0x226c8
subl $0x1, %r8d
leaq -0x30(%rbp), %rdi
movl $0x1, %ecx
callq 0xe980
movl 0xb75e(%rip), %esi      # 0x19ffc
movl -0x14(%rbp), %eax
addl $0x1, %eax
imull 0x13e21(%rip), %eax     # 0x226cc
addl %eax, %esi
subl $0x1, %esi
movl 0xb746(%rip), %edx      # 0x19ffc
movl -0x18(%rbp), %eax
imull 0x13e08(%rip), %eax     # 0x226c8
addl %eax, %edx
movl 0x13dff(%rip), %r8d     # 0x226c8
subl $0x1, %r8d
leaq -0x30(%rbp), %rdi
movl $0x1, %ecx
callq 0xe980
movl 0xb71b(%rip), %esi      # 0x19ffc
movl -0x14(%rbp), %eax
imull 0x13de1(%rip), %eax     # 0x226cc
addl %eax, %esi
movl 0xb709(%rip), %edx      # 0x19ffc
movl -0x18(%rbp), %eax
addl $0x1, %eax
imull 0x13dc8(%rip), %eax     # 0x226c8
addl %eax, %edx
subl $0x1, %edx
movl 0x13dc1(%rip), %ecx     # 0x226cc
leaq -0x30(%rbp), %rdi
movl $0x1, %r8d
callq 0xe980
addq $0x40, %rsp
popq %rbp
retq