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

	/* 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 {
			/** this is the main part of the dynamic cursor color patch */
			g.bg = g.fg;
			g.fg = defaultbg;
		}

		/**
		 * 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 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 */
			XftDrawRect(xw.draw, &drawcol,
					win.hborderpx + cx * win.cw,
					win.vborderpx + (cy + 1) * win.ch - \
						cursorthickness,
					win.cw, cursorthickness);
			break;
		case 5: /* Blinking bar */
		case 6: /* Steady bar */
			XftDrawRect(xw.draw, &drawcol,
					win.hborderpx + cx * win.cw,
					win.vborderpx + cy * win.ch,
					cursorthickness, win.ch);
			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
leaq 0x10(%rbp), %rax
movq %rax, -0x40(%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 0x61f0
cmpl $0x0, %eax
je 0xc245
movq -0x40(%rbp), %rax
movzwl 0x4(%rax), %ecx
xorl $0x20, %ecx
movw %cx, 0x4(%rax)
movq -0x40(%rbp), %rax
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
movq (%rax), %rdi
movq 0x8(%rax), %rsi
callq 0xc5e0
movl 0x10147(%rip), %eax     # 0x1c3a8
andl $0x80, %eax
cmpl $0x0, %eax
je 0xc270
jmp 0xc5d1
movzwl -0xc(%rbp), %eax
andl $0x28d, %eax            # imm = 0x28D
movw %ax, -0xc(%rbp)
movl 0x10125(%rip), %eax     # 0x1c3a8
andl $0x20, %eax
cmpl $0x0, %eax
je 0xc312
movzwl -0xc(%rbp), %eax
orl $0x20, %eax
movw %ax, -0xc(%rbp)
movl 0xb440(%rip), %eax      # 0x176e0
movl %eax, -0x4(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x61f0
cmpl $0x0, %eax
je 0xc2e1
movq 0xfec6(%rip), %rax      # 0x1c180
movl 0xbc40(%rip), %ecx      # 0x17f00
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x30(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movl 0xbc28(%rip), %eax      # 0x17f04
movl %eax, -0x8(%rbp)
jmp 0xc30d
movq 0xfe98(%rip), %rax      # 0x1c180
movl 0xbc16(%rip), %ecx      # 0x17f04
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x30(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movl 0xbbf6(%rip), %eax      # 0x17f00
movl %eax, -0x8(%rbp)
jmp 0xc3c8
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x61f0
cmpl $0x0, %eax
je 0xc336
movl 0xb3b8(%rip), %eax      # 0x176e0
movl %eax, -0x8(%rbp)
movl 0xbbd3(%rip), %eax      # 0x17f04
movl %eax, -0x4(%rbp)
jmp 0xc345
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
movl 0xb3a2(%rip), %eax      # 0x176e4
movl %eax, -0x8(%rbp)
movl -0x4(%rbp), %eax
andl $0x1000000, %eax        # imm = 0x1000000
cmpl $0x0, %eax
je 0xc3a6
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 0xfeef(%rip), %rdi      # 0x1c278
movq 0xff60(%rip), %rsi      # 0x1c2f0
movq 0xfee9(%rip), %rdx      # 0x1c280
leaq -0x38(%rbp), %rcx
leaq -0x30(%rbp), %r8
callq 0x56f0
jmp 0xc3c6
movq 0xfdd3(%rip), %rax      # 0x1c180
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 0xc3c8
movl 0xffda(%rip), %eax      # 0x1c3a8
andl $0x2, %eax
cmpl $0x0, %eax
je 0xc4b5
movl 0xffcc(%rip), %eax      # 0x1c3ac
movq %rax, -0x48(%rbp)
subq $0x7, %rax
ja 0xc4b0
movq -0x48(%rbp), %rax
leaq 0x6933(%rip), %rcx      # 0x12d2c
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 0xc5e0
jmp 0xc4b0
movq 0xfec0(%rip), %rdi      # 0x1c2e8
movl 0xff6a(%rip), %edx      # 0x1c398
movl -0x14(%rbp), %eax
imull 0xff6c(%rip), %eax      # 0x1c3a4
addl %eax, %edx
movl 0xff5c(%rip), %ecx      # 0x1c39c
movl -0x18(%rbp), %eax
addl $0x1, %eax
imull 0xff53(%rip), %eax      # 0x1c3a0
addl %eax, %ecx
subl 0xbab3(%rip), %ecx      # 0x17f08
movl 0xff48(%rip), %r8d      # 0x1c3a4
movl 0xbaa5(%rip), %r9d      # 0x17f08
leaq -0x30(%rbp), %rsi
callq 0x53d0
jmp 0xc4b0
movq 0xfe73(%rip), %rdi      # 0x1c2e8
movl 0xff1d(%rip), %edx      # 0x1c398
movl -0x14(%rbp), %eax
imull 0xff1f(%rip), %eax      # 0x1c3a4
addl %eax, %edx
movl 0xff0f(%rip), %ecx      # 0x1c39c
movl -0x18(%rbp), %eax
imull 0xff09(%rip), %eax      # 0x1c3a0
addl %eax, %ecx
movl 0xba68(%rip), %r8d      # 0x17f08
movl 0xfef9(%rip), %r9d      # 0x1c3a0
leaq -0x30(%rbp), %rsi
callq 0x53d0
jmp 0xc5d1
movq 0xfe2c(%rip), %rdi      # 0x1c2e8
movl 0xfed6(%rip), %edx      # 0x1c398
movl -0x14(%rbp), %eax
imull 0xfed8(%rip), %eax      # 0x1c3a4
addl %eax, %edx
movl 0xfec8(%rip), %ecx      # 0x1c39c
movl -0x18(%rbp), %eax
imull 0xfec2(%rip), %eax      # 0x1c3a0
addl %eax, %ecx
movl 0xfebd(%rip), %r8d      # 0x1c3a4
subl $0x1, %r8d
leaq -0x30(%rbp), %rsi
movl $0x1, %r9d
callq 0x53d0
movq 0xfde7(%rip), %rdi      # 0x1c2e8
movl 0xfe91(%rip), %edx      # 0x1c398
movl -0x14(%rbp), %eax
imull 0xfe93(%rip), %eax      # 0x1c3a4
addl %eax, %edx
movl 0xfe83(%rip), %ecx      # 0x1c39c
movl -0x18(%rbp), %eax
imull 0xfe7d(%rip), %eax      # 0x1c3a0
addl %eax, %ecx
movl 0xfe74(%rip), %r9d      # 0x1c3a0
subl $0x1, %r9d
leaq -0x30(%rbp), %rsi
movl $0x1, %r8d
callq 0x53d0
movq 0xfda2(%rip), %rdi      # 0x1c2e8
movl 0xfe4c(%rip), %edx      # 0x1c398
movl -0x14(%rbp), %eax
addl $0x1, %eax
imull 0xfe4b(%rip), %eax      # 0x1c3a4
addl %eax, %edx
subl $0x1, %edx
movl 0xfe38(%rip), %ecx      # 0x1c39c
movl -0x18(%rbp), %eax
imull 0xfe32(%rip), %eax      # 0x1c3a0
addl %eax, %ecx
movl 0xfe29(%rip), %r9d      # 0x1c3a0
subl $0x1, %r9d
leaq -0x30(%rbp), %rsi
movl $0x1, %r8d
callq 0x53d0
movq 0xfd57(%rip), %rdi      # 0x1c2e8
movl 0xfe01(%rip), %edx      # 0x1c398
movl -0x14(%rbp), %eax
imull 0xfe03(%rip), %eax      # 0x1c3a4
addl %eax, %edx
movl 0xfdf3(%rip), %ecx      # 0x1c39c
movl -0x18(%rbp), %eax
addl $0x1, %eax
imull 0xfdea(%rip), %eax      # 0x1c3a0
addl %eax, %ecx
subl $0x1, %ecx
movl 0xfde2(%rip), %r8d      # 0x1c3a4
leaq -0x30(%rbp), %rsi
movl $0x1, %r9d
callq 0x53d0
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)