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

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

	/* Redraw the line where cursor was previously.
	 * It will restore the ligatures broken by the cursor. */
	xdrawline(line, 0, oy, len);

	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
movq %rdx, %r15
movl %esi, %r14d
movl %edi, %ebx
movq 0x60(%rsp), %r12
movl 0x68(%rsp), %r13d
movl %r8d, %edi
movl %r9d, %esi
callq 0x6fef
movq %r12, %rdi
xorl %esi, %esi
movl %ebp, %edx
movl %r13d, %ecx
callq 0xadb8
movl 0x16f14(%rip), %eax     # 0x219f8
testb %al, %al
js 0xac94
movq %r15, %r12
shrq $0x20, %r12
andl $0x28d, %r12d           # imm = 0x28D
testb $0x20, %al
jne 0xab4b
movl %ebx, %edi
movl %r14d, %esi
callq 0x6fef
testl %eax, %eax
leaq 0x13a73(%rip), %rax     # 0x1e584
leaq 0x13a70(%rip), %rcx     # 0x1e588
cmoveq %rax, %rcx
movl (%rcx), %r13d
leaq 0x13a5a(%rip), %rax     # 0x1e580
leaq 0x13a4f(%rip), %rcx     # 0x1e57c
cmoveq %rax, %rcx
movl (%rcx), %eax
movq 0x16ca6(%rip), %rcx     # 0x217e0
movq %r13, %rdx
shlq $0x4, %rdx
movups (%rcx,%rdx), %xmm0
movaps %xmm0, (%rsp)
jmp 0xaba1
movzwl %r12w, %r12d
orl $0x20, %r12d
movl 0x13a22(%rip), %r13d    # 0x1e57c
movl %ebx, %edi
movl %r14d, %esi
callq 0x6fef
movq 0x16c75(%rip), %rcx     # 0x217e0
testl %eax, %eax
je 0xab89
movl 0x13a0f(%rip), %eax     # 0x1e584
shlq $0x4, %rax
movups (%rcx,%rax), %xmm0
movaps %xmm0, (%rsp)
movl 0x13a01(%rip), %eax     # 0x1e588
jmp 0xaba1
movl 0x139f9(%rip), %eax     # 0x1e588
shlq $0x4, %rax
movups (%rcx,%rax), %xmm0
movaps %xmm0, (%rsp)
movl 0x139e3(%rip), %eax     # 0x1e584
movl 0x16e51(%rip), %ecx     # 0x219f8
testb $0x2, %cl
jne 0xaca3
movq 0x16d91(%rip), %rdi     # 0x21948
movl 0x1421f(%rip), %eax     # 0x1eddc
movl 0x16e30(%rip), %r8d     # 0x219f4
movl %r8d, %edx
imull %ebx, %edx
addl %eax, %edx
movl 0x16e1e(%rip), %ecx     # 0x219f0
imull %r14d, %ecx
addl %eax, %ecx
decl %r8d
movq %rsp, %r15
pushq $0x1
popq %rbp
movq %r15, %rsi
movl %ebp, %r9d
callq 0x6400
movq 0x16d55(%rip), %rdi     # 0x21948
movl 0x141e3(%rip), %eax     # 0x1eddc
movl 0x16df5(%rip), %edx     # 0x219f4
imull %ebx, %edx
addl %eax, %edx
movl 0x16de5(%rip), %r9d     # 0x219f0
movl %r9d, %ecx
imull %r14d, %ecx
addl %eax, %ecx
decl %r9d
movq %r15, %rsi
movl %ebp, %r8d
callq 0x6400
movq 0x16d1f(%rip), %rdi     # 0x21948
movl 0x141ad(%rip), %eax     # 0x1eddc
leal 0x1(%rbx), %ecx
imull 0x16dbb(%rip), %ecx     # 0x219f4
leal (%rax,%rcx), %edx
decl %edx
movl 0x16dab(%rip), %r9d     # 0x219f0
movl %r9d, %ecx
imull %r14d, %ecx
addl %eax, %ecx
decl %r9d
movq %r15, %rsi
movl %ebp, %r8d
callq 0x6400
movq 0x16ce5(%rip), %rdi     # 0x21948
movl 0x14173(%rip), %eax     # 0x1eddc
movl 0x16d84(%rip), %r8d     # 0x219f4
imull %r8d, %ebx
addl %eax, %ebx
incl %r14d
imull 0x16d6f(%rip), %r14d    # 0x219f0
leal (%rax,%r14), %ecx
decl %ecx
movq %r15, %rsi
movl %ebx, %edx
movl %ebp, %r9d
callq 0x6400
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x16d53(%rip), %edx     # 0x219fc
cmpq $0x8, %rdx
ja 0xac94
leaq 0x4d8a(%rip), %rsi      # 0xfa40
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
btl $0xb, %ecx
jb 0xac94
movzwl %r12w, %ecx
shlq $0x20, %rcx
movabsq $-0xffff00000001, %rdx  # imm = 0xFFFF0000FFFFFFFF
andq %rdx, %r15
orq %rcx, %r15
shlq $0x20, %r13
movl %eax, %esi
orq %r13, %rsi
movq %r15, %rdi
jmp 0xada0
btl $0xb, %ecx
jb 0xac94
movq 0x16c4d(%rip), %rdi     # 0x21948
movl 0x140db(%rip), %eax     # 0x1eddc
movl 0x16cec(%rip), %r8d     # 0x219f4
imull %r8d, %ebx
addl %eax, %ebx
incl %r14d
imull 0x16cd7(%rip), %r14d    # 0x219f0
leal (%rax,%r14), %ecx
addl $-0x2, %ecx
movq %rsp, %rsi
pushq $0x2
popq %r9
movl %ebx, %edx
jmp 0xac8f
btl $0xb, %ecx
jb 0xac94
movq 0x16c09(%rip), %rdi     # 0x21948
movl 0x14097(%rip), %eax     # 0x1eddc
imull 0x16ca8(%rip), %ebx     # 0x219f4
addl %eax, %ebx
movl 0x16c9b(%rip), %r9d     # 0x219f0
imull %r9d, %r14d
addl %eax, %r14d
movq %rsp, %rsi
pushq $0x2
popq %r8
movl %ebx, %edx
movl %r14d, %ecx
jmp 0xac8f
btl $0xb, %ecx
jb 0xac94
movabsq $-0x1000000000000, %rcx # imm = 0xFFFF000000000000
andq %rcx, %r15
movzwl %r12w, %ecx
shlq $0x20, %rcx
leaq (%rcx,%r15), %rdi
addq $0x2603, %rdi           # imm = 0x2603
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 0xaf8a