// File: /workspace/github_c_makefile_star2_O3/mcaimi[P]st/x.c
// Function: xdrawcursor
void
xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
{
  Color drawcol;

  /* 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|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 {
      g.fg = defaultbg;
      g.bg = defaultcs;
    }
    drawcol = dc.col[g.bg];
  }

  /* draw the new one */
  if (IS_SET(MODE_FOCUSED)) {
    switch (win.cursor) {
    case 7: /* st extension: snowman (U+2603) */
      g.u = 0x2603;
      /* 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.dynborder_w + cx * win.cw,
          win.dynborder_h + (cy + 1) * win.ch - \
            cursorthickness,
          win.cw, cursorthickness);
      break;
    case 5: /* Blinking bar */
    case 6: /* Steady bar */
      XftDrawRect(xw.draw, &drawcol,
          win.dynborder_w + cx * win.cw,
          win.dynborder_h + cy * win.ch,
          cursorthickness, win.ch);
      break;
    }
  } else {
    XftDrawRect(xw.draw, &drawcol,
        win.dynborder_w + cx * win.cw,
        win.dynborder_h + cy * win.ch,
        win.cw - 1, 1);
    XftDrawRect(xw.draw, &drawcol,
        win.dynborder_w + cx * win.cw,
        win.dynborder_h + cy * win.ch,
        1, win.ch - 1);
    XftDrawRect(xw.draw, &drawcol,
        win.dynborder_w + (cx + 1) * win.cw - 1,
        win.dynborder_h + cy * win.ch,
        1, win.ch - 1);
    XftDrawRect(xw.draw, &drawcol,
        win.dynborder_w + cx * win.cw,
        win.dynborder_h + (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
movl %r8d, %r12d
movq %rdx, %r15
movl %esi, %r14d
movl %edi, %ebx
leaq 0x50(%rsp), %r13
movl %r8d, %edi
movl %r9d, %esi
callq 0x76e7
testl %eax, %eax
je 0xc997
xorb $0x20, 0x4(%r13)
movq (%r13), %rdi
movq 0x8(%r13), %rsi
movl %r12d, %edx
movl %ebp, %ecx
callq 0xcc56
movl 0x14385(%rip), %eax     # 0x20d34
testb %al, %al
js 0xcb72
movq %r15, %r12
shrq $0x20, %r12
andl $0xa8d, %r12d           # imm = 0xA8D
testb $0x20, %al
jne 0xca16
movl %ebx, %edi
movl %r14d, %esi
callq 0x76e7
testl %eax, %eax
leaq 0x10bd8(%rip), %rax     # 0x1d5b4
leaq 0x10bd5(%rip), %rcx     # 0x1d5b8
cmoveq %rax, %rcx
movl (%rcx), %r13d
leaq 0x10bbb(%rip), %rax     # 0x1d5ac
leaq 0x10bb8(%rip), %rcx     # 0x1d5b0
cmoveq %rax, %rcx
movl (%rcx), %eax
movq 0x140cb(%rip), %rcx     # 0x20ad0
movq %r13, %rdx
shlq $0x4, %rdx
movups (%rcx,%rdx), %xmm0
movaps %xmm0, (%rsp)
jmp 0xca6c
movzwl %r12w, %r12d
orl $0x20, %r12d
movl 0x10b8b(%rip), %r13d    # 0x1d5b0
movl %ebx, %edi
movl %r14d, %esi
callq 0x76e7
movq 0x1409a(%rip), %rcx     # 0x20ad0
testl %eax, %eax
je 0xca54
movl 0x10b74(%rip), %eax     # 0x1d5b4
shlq $0x4, %rax
movups (%rcx,%rax), %xmm0
movaps %xmm0, (%rsp)
movl 0x10b66(%rip), %eax     # 0x1d5b8
jmp 0xca6c
movl 0x10b5e(%rip), %eax     # 0x1d5b8
shlq $0x4, %rax
movups (%rcx,%rax), %xmm0
movaps %xmm0, (%rsp)
movl 0x10b48(%rip), %eax     # 0x1d5b4
testb $0x2, 0x142c1(%rip)     # 0x20d34
jne 0xcb81
movq 0x141e8(%rip), %rdi     # 0x20c68
movl 0x142a5(%rip), %r8d     # 0x20d2c
movl %r8d, %edx
imull %ebx, %edx
addl 0x14291(%rip), %edx     # 0x20d24
movl 0x1428f(%rip), %ecx     # 0x20d28
imull %r14d, %ecx
addl 0x1427d(%rip), %ecx     # 0x20d20
decl %r8d
movq %rsp, %r15
movq %r15, %rsi
movl $0x1, %r9d
callq 0x6420
movq 0x141aa(%rip), %rdi     # 0x20c68
movl 0x14268(%rip), %edx     # 0x20d2c
imull %ebx, %edx
addl 0x14257(%rip), %edx     # 0x20d24
movl 0x14254(%rip), %r9d     # 0x20d28
movl %r9d, %ecx
imull %r14d, %ecx
addl 0x1423f(%rip), %ecx     # 0x20d20
decl %r9d
movq %r15, %rsi
movl $0x1, %r8d
callq 0x6420
movq 0x1416f(%rip), %rdi     # 0x20c68
leal 0x1(%rbx), %eax
imull 0x14229(%rip), %eax     # 0x20d2c
movl 0x1421b(%rip), %ecx     # 0x20d24
leal (%rcx,%rax), %edx
decl %edx
movl 0x14213(%rip), %r9d     # 0x20d28
movl %r9d, %ecx
imull %r14d, %ecx
addl 0x141fe(%rip), %ecx     # 0x20d20
decl %r9d
movq %r15, %rsi
movl $0x1, %r8d
callq 0x6420
movq 0x1412e(%rip), %rdi     # 0x20c68
movl 0x141eb(%rip), %r8d     # 0x20d2c
imull %r8d, %ebx
addl 0x141d9(%rip), %ebx     # 0x20d24
movl 0x141cf(%rip), %eax     # 0x20d20
incl %r14d
imull 0x141cc(%rip), %r14d    # 0x20d28
leal (%rax,%r14), %ecx
decl %ecx
movq %r15, %rsi
movl %ebx, %edx
movl $0x1, %r9d
callq 0x6420
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x141b1(%rip), %ecx     # 0x20d38
cmpq $0x7, %rcx
ja 0xcb72
leaq 0x6044(%rip), %rdx      # 0x12bd8
movslq (%rdx,%rcx,4), %rsi
addq %rdx, %rsi
movq %r15, %rcx
jmpq *%rsi
movq 0x140c1(%rip), %rdi     # 0x20c68
movl 0x1417e(%rip), %r8d     # 0x20d2c
imull %r8d, %ebx
addl 0x1416c(%rip), %ebx     # 0x20d24
movl 0x14162(%rip), %eax     # 0x20d20
incl %r14d
imull 0x1415f(%rip), %r14d    # 0x20d28
leal (%rax,%r14), %ecx
addl $-0x2, %ecx
movq %rsp, %rsi
movl %ebx, %edx
movl $0x2, %r9d
jmp 0xcb6d
movq 0x14084(%rip), %rdi     # 0x20c68
imull 0x14141(%rip), %ebx     # 0x20d2c
addl 0x14133(%rip), %ebx     # 0x20d24
movl 0x14130(%rip), %r9d     # 0x20d28
imull %r9d, %r14d
addl 0x1411d(%rip), %r14d    # 0x20d20
movq %rsp, %rsi
movl %ebx, %edx
movl %r14d, %ecx
movl $0x2, %r8d
jmp 0xcb6d
movl $0x2603, %ecx           # imm = 0x2603
movabsq $-0x1000000000000, %rdx # imm = 0xFFFF000000000000
andq %rdx, %r15
movzwl %r12w, %edx
shlq $0x20, %rdx
movl %ecx, %edi
orq %r15, %rdi
orq %rdx, %rdi
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 0xcc56