// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r9d, %ebp
movq %rcx, %r12
movq %rdx, 0x8(%rsp)
movl %esi, %r14d
movq %rdi, (%rsp)
movl 0x78(%rsp), %r13d
movq 0x70(%rsp), %r15
leaq 0x60(%rsp), %rbx
movl %r8d, %edi
movl %r9d, %esi
callq 0x758e
testl %eax, %eax
je 0xc147
xorb $0x20, 0x4(%rbx)
movq %r15, %rdi
xorl %esi, %esi
movl %ebp, %edx
movl %r13d, %ecx
callq 0xc49d
movl 0x13844(%rip), %eax     # 0x1f9a0
testb %al, %al
js 0xc48e
movq 0x8(%rsp), %r15
shrq $0x20, %r15
andl $0xa8d, %r15d           # imm = 0xA8D
testb $0x20, %al
jne 0xc196
movq (%rsp), %rdi
movl %r14d, %esi
callq 0x758e
testl %eax, %eax
je 0xc1d2
movl $0x103, %r13d           # imm = 0x103
movl 0xc468(%rip), %ebp      # 0x185fc
jmp 0xc1ef
movzwl %r15w, %r15d
orl $0x20, %r15d
movl 0xc457(%rip), %r13d     # 0x185fc
movq (%rsp), %rdi
movl %r14d, %esi
callq 0x758e
movq 0x135d0(%rip), %rcx     # 0x1f788
testl %eax, %eax
je 0xc208
movups 0x1020(%rcx), %xmm0
movaps %xmm0, 0x10(%rsp)
movl $0x103, %ebp            # imm = 0x103
jmp 0xc266
movq %r12, %r13
shrq $0x20, %r13
testb $0x20, 0x4(%rbx)
movl %r12d, %ebp
cmovel %r13d, %ebp
cmovel %r12d, %r13d
btl $0x18, %r13d
jb 0xc21b
movq 0x13592(%rip), %rax     # 0x1f788
movl %r13d, %ecx
shlq $0x4, %rcx
movups (%rax,%rcx), %xmm0
movaps %xmm0, 0x10(%rsp)
jmp 0xc266
movups 0x1030(%rcx), %xmm0
movaps %xmm0, 0x10(%rsp)
movl $0x102, %ebp            # imm = 0x102
jmp 0xc266
leaq 0x20(%rsp), %rcx
movw $0xffff, 0x6(%rcx)      # imm = 0xFFFF
movl %r13d, %eax
shrl $0x8, %eax
movl $0xff00, %edx           # imm = 0xFF00
andl %edx, %eax
movw %ax, (%rcx)
andl %r13d, %edx
movw %dx, 0x2(%rcx)
movl %r13d, %eax
shll $0x8, %eax
movw %ax, 0x4(%rcx)
movq 0x13632(%rip), %rdi     # 0x1f880
movq 0x1369b(%rip), %rsi     # 0x1f8f0
movq 0x1362c(%rip), %rdx     # 0x1f888
leaq 0x10(%rsp), %r8
callq 0x67d0
movl 0x13734(%rip), %eax     # 0x1f9a0
testb $0x2, %al
jne 0xc378
movq 0x1366d(%rip), %rdi     # 0x1f8e8
movl 0x1371a(%rip), %r8d     # 0x1f99c
movl %r8d, %edx
movq (%rsp), %rbx
imull %ebx, %edx
addl 0x136fe(%rip), %edx     # 0x1f990
movl 0x13700(%rip), %ecx     # 0x1f998
imull %r14d, %ecx
addl 0x136f2(%rip), %ecx     # 0x1f994
decl %r8d
leaq 0x10(%rsp), %r15
movq %r15, %rsi
movl $0x1, %r9d
callq 0x6430
movq 0x13629(%rip), %rdi     # 0x1f8e8
movl 0x136d7(%rip), %edx     # 0x1f99c
imull %ebx, %edx
addl 0x136c2(%rip), %edx     # 0x1f990
movl 0x136c3(%rip), %r9d     # 0x1f998
movl %r9d, %ecx
imull %r14d, %ecx
addl 0x136b2(%rip), %ecx     # 0x1f994
decl %r9d
movq %r15, %rsi
movl $0x1, %r8d
callq 0x6430
movq 0x135ee(%rip), %rdi     # 0x1f8e8
leal 0x1(%rbx), %eax
imull 0x13698(%rip), %eax     # 0x1f99c
movl 0x13686(%rip), %ecx     # 0x1f990
leal (%rcx,%rax), %edx
decl %edx
movl 0x13682(%rip), %r9d     # 0x1f998
movl %r9d, %ecx
imull %r14d, %ecx
addl 0x13671(%rip), %ecx     # 0x1f994
decl %r9d
movq %r15, %rsi
movl $0x1, %r8d
callq 0x6430
movq 0x135ad(%rip), %rdi     # 0x1f8e8
movl 0x1365a(%rip), %r8d     # 0x1f99c
imull %r8d, %ebx
addl 0x13644(%rip), %ebx     # 0x1f990
movl 0x13642(%rip), %eax     # 0x1f994
incl %r14d
imull 0x1363b(%rip), %r14d    # 0x1f998
leal (%rax,%r14), %ecx
decl %ecx
movq %r15, %rsi
movl %ebx, %edx
movl $0x1, %r9d
callq 0x6430
jmp 0xc48e
movl 0x13626(%rip), %ecx     # 0x1f9a4
cmpq $0x8, %rcx
ja 0xc48e
leaq 0x5705(%rip), %rdx      # 0x11a94
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
btl $0xb, %eax
jb 0xc48e
movzwl %r15w, %eax
shlq $0x20, %rax
movabsq $-0xffff00000001, %rcx  # imm = 0xFFFF0000FFFFFFFF
movq 0x8(%rsp), %rdi
andq %rcx, %rdi
orq %rax, %rdi
jmp 0xc479
btl $0xb, %eax
jb 0xc48e
movq 0x13513(%rip), %rdi     # 0x1f8e8
movl 0x135c0(%rip), %r8d     # 0x1f99c
movq (%rsp), %rdx
imull %r8d, %edx
addl 0x135a6(%rip), %edx     # 0x1f990
movl 0x135a4(%rip), %eax     # 0x1f994
incl %r14d
imull 0x1359d(%rip), %r14d    # 0x1f998
leal (%rax,%r14), %ecx
decl %ecx
leaq 0x10(%rsp), %rsi
jmp 0xc368
btl $0xb, %eax
jb 0xc48e
movq 0x134d0(%rip), %rdi     # 0x1f8e8
movq (%rsp), %rdx
imull 0x13579(%rip), %edx     # 0x1f99c
addl 0x13567(%rip), %edx     # 0x1f990
movl 0x13568(%rip), %r9d     # 0x1f998
imull %r9d, %r14d
addl 0x13559(%rip), %r14d    # 0x1f994
leaq 0x10(%rsp), %rsi
movl %r14d, %ecx
movl $0x1, %r8d
jmp 0xc36e
btl $0xb, %eax
jb 0xc48e
movabsq $-0x1000000000000, %rax # imm = 0xFFFF000000000000
movq 0x8(%rsp), %rcx
andq %rax, %rcx
movzwl %r15w, %eax
shlq $0x20, %rax
leaq (%rax,%rcx), %rdi
addq $0x2603, %rdi           # imm = 0x2603
shlq $0x20, %r13
movl %ebp, %esi
orq %r13, %rsi
movq (%rsp), %rdx
movl %r14d, %ecx
callq 0xc6ce
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq