// File: /workspace/github_c_makefile_star2_O1/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
movl 0x68(%rsp), %r12d
movq 0x60(%rsp), %r13
movl %r8d, %edi
movl %r9d, %esi
callq 0x7458
testl %eax, %eax
je 0xb17a
leaq 0x50(%rsp), %rax
xorb $0x20, 0x4(%rax)
movq %r13, %rdi
xorl %esi, %esi
movl %ebp, %edx
movl %r12d, %ecx
callq 0xb470
movl 0x16879(%rip), %eax     # 0x21a08
testb %al, %al
js 0xb348
movq %r15, %r12
shrq $0x20, %r12
andl $0x28d, %r12d           # imm = 0x28D
testb $0x20, %al
jne 0xb1f6
movl %ebx, %edi
movl %r14d, %esi
callq 0x7458
testl %eax, %eax
leaq 0x133d8(%rip), %rax     # 0x1e594
leaq 0x133d5(%rip), %rcx     # 0x1e598
cmoveq %rax, %rcx
movl (%rcx), %r13d
leaq 0x133bf(%rip), %rax     # 0x1e590
leaq 0x133b4(%rip), %rcx     # 0x1e58c
cmoveq %rax, %rcx
movl (%rcx), %eax
movq 0x1660b(%rip), %rcx     # 0x217f0
movq %r13, %rdx
shlq $0x4, %rdx
movups (%rcx,%rdx), %xmm0
movaps %xmm0, (%rsp)
jmp 0xb24c
movzwl %r12w, %r12d
orl $0x20, %r12d
movl 0x13387(%rip), %r13d    # 0x1e58c
movl %ebx, %edi
movl %r14d, %esi
callq 0x7458
movq 0x165da(%rip), %rcx     # 0x217f0
testl %eax, %eax
je 0xb234
movl 0x13374(%rip), %eax     # 0x1e594
shlq $0x4, %rax
movups (%rcx,%rax), %xmm0
movaps %xmm0, (%rsp)
movl 0x13366(%rip), %eax     # 0x1e598
jmp 0xb24c
movl 0x1335e(%rip), %eax     # 0x1e598
shlq $0x4, %rax
movups (%rcx,%rax), %xmm0
movaps %xmm0, (%rsp)
movl 0x13348(%rip), %eax     # 0x1e594
movl 0x167b6(%rip), %ecx     # 0x21a08
testb $0x2, %cl
jne 0xb357
movq 0x166f6(%rip), %rdi     # 0x21958
movl 0x13b84(%rip), %eax     # 0x1edec
movl 0x16795(%rip), %r8d     # 0x21a04
movl %r8d, %edx
imull %ebx, %edx
addl %eax, %edx
movl 0x16783(%rip), %ecx     # 0x21a00
imull %r14d, %ecx
addl %eax, %ecx
decl %r8d
movq %rsp, %r15
movq %r15, %rsi
movl $0x1, %r9d
callq 0x6400
movq 0x166ba(%rip), %rdi     # 0x21958
movl 0x13b48(%rip), %eax     # 0x1edec
movl 0x1675a(%rip), %edx     # 0x21a04
imull %ebx, %edx
addl %eax, %edx
movl 0x1674a(%rip), %r9d     # 0x21a00
movl %r9d, %ecx
imull %r14d, %ecx
addl %eax, %ecx
decl %r9d
movq %r15, %rsi
movl $0x1, %r8d
callq 0x6400
movq 0x16681(%rip), %rdi     # 0x21958
movl 0x13b0f(%rip), %eax     # 0x1edec
leal 0x1(%rbx), %ecx
imull 0x1671d(%rip), %ecx     # 0x21a04
leal (%rax,%rcx), %edx
decl %edx
movl 0x1670d(%rip), %r9d     # 0x21a00
movl %r9d, %ecx
imull %r14d, %ecx
addl %eax, %ecx
decl %r9d
movq %r15, %rsi
movl $0x1, %r8d
callq 0x6400
movq 0x16644(%rip), %rdi     # 0x21958
movl 0x13ad2(%rip), %eax     # 0x1edec
movl 0x166e3(%rip), %r8d     # 0x21a04
imull %r8d, %ebx
addl %eax, %ebx
incl %r14d
imull 0x166ce(%rip), %r14d    # 0x21a00
leal (%rax,%r14), %ecx
decl %ecx
movq %r15, %rsi
movl %ebx, %edx
movl $0x1, %r9d
callq 0x6400
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x166af(%rip), %edx     # 0x21a0c
cmpq $0x8, %rdx
ja 0xb348
leaq 0x46da(%rip), %rsi      # 0xfa44
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
btl $0xb, %ecx
jb 0xb348
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 0xb458
btl $0xb, %ecx
jb 0xb348
movq 0x165a9(%rip), %rdi     # 0x21958
movl 0x13a37(%rip), %eax     # 0x1edec
movl 0x16648(%rip), %r8d     # 0x21a04
imull %r8d, %ebx
addl %eax, %ebx
incl %r14d
imull 0x16633(%rip), %r14d    # 0x21a00
leal (%rax,%r14), %ecx
addl $-0x2, %ecx
movq %rsp, %rsi
movl %ebx, %edx
movl $0x2, %r9d
jmp 0xb343
btl $0xb, %ecx
jb 0xb348
movq 0x16563(%rip), %rdi     # 0x21958
movl 0x139f1(%rip), %eax     # 0x1edec
imull 0x16602(%rip), %ebx     # 0x21a04
addl %eax, %ebx
movl 0x165f5(%rip), %r9d     # 0x21a00
imull %r9d, %r14d
addl %eax, %r14d
movq %rsp, %rsi
movl %ebx, %edx
movl %r14d, %ecx
movl $0x2, %r8d
jmp 0xb343
btl $0xb, %ecx
jb 0xb348
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 0xb652