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

	/* 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|ATTR_BOXDRAW;

	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 {
			/** this is the main part of the dynamic cursor color patch */
			if (!(og.mode & ATTR_REVERSE)) {
				unsigned long col = g.bg;
				g.bg = g.fg;
				g.fg = col;
			}
		}

		/**
		 * and this is the second part of the dynamic cursor color patch.
		 * it handles the `drawcol` variable
		*/
		if (IS_TRUECOL(g.bg)) {
			colbg.alpha = 0xffff;
			colbg.red = TRUERED(g.bg);
			colbg.green = TRUEGREEN(g.bg);
			colbg.blue = TRUEBLUE(g.bg);
			XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colbg, &drawcol);
		} else {
			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,
					win.hborderpx + cx * win.cw,
					win.vborderpx + (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,
					win.hborderpx + cx * win.cw,
					win.vborderpx + 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,
				win.hborderpx + cx * win.cw,
				win.vborderpx + cy * win.ch,
				win.cw - 1, 1);
		XftDrawRect(xw.draw, &drawcol,
				win.hborderpx + cx * win.cw,
				win.vborderpx + cy * win.ch,
				1, win.ch - 1);
		XftDrawRect(xw.draw, &drawcol,
				win.hborderpx + (cx + 1) * win.cw - 1,
				win.vborderpx + cy * win.ch,
				1, win.ch - 1);
		XftDrawRect(xw.draw, &drawcol,
				win.hborderpx + cx * win.cw,
				win.vborderpx + (cy + 1) * win.ch - 1,
				win.cw, 1);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl 0x28(%rbp), %eax
movq 0x20(%rbp), %rax
leaq 0x10(%rbp), %rax
movq %rax, -0x48(%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 0x7330
cmpl $0x0, %eax
je 0xdf8c
movq -0x48(%rbp), %rax
movzwl 0x4(%rax), %ecx
xorl $0x20, %ecx
movw %cx, 0x4(%rax)
movq 0x20(%rbp), %rdi
movl -0x20(%rbp), %edx
movl 0x28(%rbp), %ecx
xorl %esi, %esi
callq 0xe3a0
movl 0x157bd(%rip), %eax     # 0x23760
andl $0x80, %eax
cmpl $0x0, %eax
je 0xdfb2
jmp 0xe39a
movzwl -0xc(%rbp), %eax
andl $0xa8d, %eax            # imm = 0xA8D
movw %ax, -0xc(%rbp)
movl 0x1579b(%rip), %eax     # 0x23760
andl $0x20, %eax
cmpl $0x0, %eax
je 0xe054
movzwl -0xc(%rbp), %eax
orl $0x20, %eax
movw %ax, -0xc(%rbp)
movl 0xc85a(%rip), %eax      # 0x1a83c
movl %eax, -0x4(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x7330
cmpl $0x0, %eax
je 0xe023
movq 0x1554c(%rip), %rax     # 0x23548
movl 0xd386(%rip), %ecx      # 0x1b388
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x30(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movl 0xd36e(%rip), %eax      # 0x1b38c
movl %eax, -0x8(%rbp)
jmp 0xe04f
movq 0x1551e(%rip), %rax     # 0x23548
movl 0xd35c(%rip), %ecx      # 0x1b38c
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x30(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movl 0xd33c(%rip), %eax      # 0x1b388
movl %eax, -0x8(%rbp)
jmp 0xe121
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x7330
cmpl $0x0, %eax
je 0xe078
movl 0xc7d2(%rip), %eax      # 0x1a83c
movl %eax, -0x8(%rbp)
movl 0xd319(%rip), %eax      # 0x1b38c
movl %eax, -0x4(%rbp)
jmp 0xe09e
movq -0x48(%rbp), %rax
movzwl 0x4(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
jne 0xe09c
movl -0x4(%rbp), %eax
movq %rax, -0x40(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
movq -0x40(%rbp), %rax
movl %eax, -0x8(%rbp)
jmp 0xe09e
movl -0x4(%rbp), %eax
andl $0x1000000, %eax        # imm = 0x1000000
cmpl $0x0, %eax
je 0xe0ff
movw $0xffff, -0x32(%rbp)    # imm = 0xFFFF
movl -0x4(%rbp), %eax
andl $0xff0000, %eax         # imm = 0xFF0000
shrl $0x8, %eax
movw %ax, -0x38(%rbp)
movl -0x4(%rbp), %eax
andl $0xff00, %eax           # imm = 0xFF00
movw %ax, -0x36(%rbp)
movl -0x4(%rbp), %eax
andl $0xff, %eax
shll $0x8, %eax
movw %ax, -0x34(%rbp)
movq 0x1555e(%rip), %rdi     # 0x23640
movq 0x155c7(%rip), %rsi     # 0x236b0
movq 0x15558(%rip), %rdx     # 0x23648
leaq -0x38(%rbp), %rcx
leaq -0x30(%rbp), %r8
callq 0x67d0
jmp 0xe11f
movq 0x15442(%rip), %rax     # 0x23548
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)
jmp 0xe121
movl 0x15639(%rip), %eax     # 0x23760
andl $0x2, %eax
cmpl $0x0, %eax
je 0xe27e
movl 0x1562b(%rip), %eax     # 0x23764
movq %rax, -0x50(%rbp)
subq $0x8, %rax
ja 0xe279
movq -0x50(%rbp), %rax
leaq 0x7b9e(%rip), %rcx      # 0x15cf0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x155ff(%rip), %eax     # 0x23760
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0xe170
jmp 0xe279
jmp 0xe172
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0xe580
jmp 0xe279
movl 0x155d0(%rip), %eax     # 0x23760
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0xe19f
jmp 0xe279
jmp 0xe1a1
movq 0x15500(%rip), %rdi     # 0x236a8
movl 0x155a2(%rip), %edx     # 0x23750
movl -0x14(%rbp), %eax
imull 0x155a4(%rip), %eax     # 0x2375c
addl %eax, %edx
movl 0x15594(%rip), %ecx     # 0x23754
movl -0x18(%rbp), %eax
addl $0x1, %eax
imull 0x1558b(%rip), %eax     # 0x23758
addl %eax, %ecx
subl 0xd1bb(%rip), %ecx      # 0x1b390
movl 0x15580(%rip), %r8d     # 0x2375c
movl 0xd1ad(%rip), %r9d      # 0x1b390
leaq -0x30(%rbp), %rsi
callq 0x6430
jmp 0xe279
movl 0x15569(%rip), %eax     # 0x23760
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0xe203
jmp 0xe279
jmp 0xe205
movq 0x1549c(%rip), %rdi     # 0x236a8
movl 0x1553e(%rip), %edx     # 0x23750
movl -0x14(%rbp), %eax
imull 0x15540(%rip), %eax     # 0x2375c
addl %eax, %edx
movl 0x15530(%rip), %ecx     # 0x23754
movl -0x18(%rbp), %eax
imull 0x1552a(%rip), %eax     # 0x23758
addl %eax, %ecx
movl 0xd159(%rip), %r8d      # 0x1b390
movl 0x1551a(%rip), %r9d     # 0x23758
leaq -0x30(%rbp), %rsi
callq 0x6430
jmp 0xe279
movl 0x15511(%rip), %eax     # 0x23760
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0xe25b
jmp 0xe279
jmp 0xe25d
movl 0xd131(%rip), %eax      # 0x1b394
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0xe580
jmp 0xe39a
movq 0x15423(%rip), %rdi     # 0x236a8
movl 0x154c5(%rip), %edx     # 0x23750
movl -0x14(%rbp), %eax
imull 0x154c7(%rip), %eax     # 0x2375c
addl %eax, %edx
movl 0x154b7(%rip), %ecx     # 0x23754
movl -0x18(%rbp), %eax
imull 0x154b1(%rip), %eax     # 0x23758
addl %eax, %ecx
movl 0x154ac(%rip), %r8d     # 0x2375c
subl $0x1, %r8d
leaq -0x30(%rbp), %rsi
movl $0x1, %r9d
callq 0x6430
movq 0x153de(%rip), %rdi     # 0x236a8
movl 0x15480(%rip), %edx     # 0x23750
movl -0x14(%rbp), %eax
imull 0x15482(%rip), %eax     # 0x2375c
addl %eax, %edx
movl 0x15472(%rip), %ecx     # 0x23754
movl -0x18(%rbp), %eax
imull 0x1546c(%rip), %eax     # 0x23758
addl %eax, %ecx
movl 0x15463(%rip), %r9d     # 0x23758
subl $0x1, %r9d
leaq -0x30(%rbp), %rsi
movl $0x1, %r8d
callq 0x6430
movq 0x15399(%rip), %rdi     # 0x236a8
movl 0x1543b(%rip), %edx     # 0x23750
movl -0x14(%rbp), %eax
addl $0x1, %eax
imull 0x1543a(%rip), %eax     # 0x2375c
addl %eax, %edx
subl $0x1, %edx
movl 0x15427(%rip), %ecx     # 0x23754
movl -0x18(%rbp), %eax
imull 0x15421(%rip), %eax     # 0x23758
addl %eax, %ecx
movl 0x15418(%rip), %r9d     # 0x23758
subl $0x1, %r9d
leaq -0x30(%rbp), %rsi
movl $0x1, %r8d
callq 0x6430
movq 0x1534e(%rip), %rdi     # 0x236a8
movl 0x153f0(%rip), %edx     # 0x23750
movl -0x14(%rbp), %eax
imull 0x153f2(%rip), %eax     # 0x2375c
addl %eax, %edx
movl 0x153e2(%rip), %ecx     # 0x23754
movl -0x18(%rbp), %eax
addl $0x1, %eax
imull 0x153d9(%rip), %eax     # 0x23758
addl %eax, %ecx
subl $0x1, %ecx
movl 0x153d1(%rip), %r8d     # 0x2375c
leaq -0x30(%rbp), %rsi
movl $0x1, %r9d
callq 0x6430
addq $0x50, %rsp
popq %rbp
retq