// File: /workspace/github_c_makefile_star2_O0/jaimecgomezz[P]st/st.c
// Function: tputc
void tputc(Rune u) {
  char c[UTF_SIZ];
  int control;
  int width, len;
  Glyph *gp;

  control = ISCONTROL(u);
  if (u < 127 || !IS_SET(MODE_UTF8)) {
    c[0] = u;
    width = len = 1;
  } else {
    len = utf8encode(u, c);
    if (!control && (width = wcwidth(u)) == -1)
      width = 1;
  }

  if (IS_SET(MODE_PRINT))
    tprinter(c, len);

  /*
   * STR sequence must be checked before anything else
   * because it uses all following characters until it
   * receives a ESC, a SUB, a ST or any other C1 control
   * character.
   */
  if (term.esc & ESC_STR) {
    if (u == '\a' || u == 030 || u == 032 || u == 033 || ISCONTROLC1(u)) {
      term.esc &= ~(ESC_START | ESC_STR);
      term.esc |= ESC_STR_END;
      goto check_control_code;
    }

    if (strescseq.len + len >= strescseq.siz) {
      /*
       * Here is a bug in terminals. If the user never sends
       * some code to stop the str or esc command, then st
       * will stop responding. But this is better than
       * silently failing with unknown characters. At least
       * then users will report back.
       *
       * In the case users ever get fixed, here is the code:
       */
      /*
       * term.esc = 0;
       * strhandle();
       */
      if (strescseq.siz > (SIZE_MAX - UTF_SIZ) / 2)
        return;
      strescseq.siz *= 2;
      strescseq.buf = xrealloc(strescseq.buf, strescseq.siz);
    }

    memmove(&strescseq.buf[strescseq.len], c, len);
    strescseq.len += len;
    return;
  }

check_control_code:
  /*
   * Actions of control codes must be performed as soon they arrive
   * because they can be embedded inside a control sequence, and
   * they must not cause conflicts with sequences.
   */
  if (control) {
    tcontrolcode(u);
    /*
     * control codes are not shown ever
     */
    if (!term.esc)
      term.lastc = 0;
    return;
  } else if (term.esc & ESC_START) {
    if (term.esc & ESC_CSI) {
      csiescseq.buf[csiescseq.len++] = u;
      if (BETWEEN(u, 0x40, 0x7E) ||
          csiescseq.len >= sizeof(csiescseq.buf) - 1) {
        term.esc = 0;
        csiparse();
        csihandle();
      }
      return;
    } else if (term.esc & ESC_UTF8) {
      tdefutf8(u);
    } else if (term.esc & ESC_ALTCHARSET) {
      tdeftran(u);
    } else if (term.esc & ESC_TEST) {
      tdectest(u);
    } else {
      if (!eschandle(u))
        return;
      /* sequence already finished */
    }
    term.esc = 0;
    /*
     * All characters which form part of a sequence are not
     * printed
     */
    return;
  }
  // >>>>>>>>>>>>>>>>>>>> vim-browse
  // ==================== vim-browse
  if (selected(term.c.x, term.c.y))
    selclear();
  // ==================== vim-browse
  // <<<<<<<<<<<<<<<<<<<< vim-browse

  gp = &term.line[term.c.y][term.c.x];
  if (IS_SET(MODE_WRAP) && (term.c.state & CURSOR_WRAPNEXT)) {
    gp->mode |= ATTR_WRAP;
    tnewline(1);
    gp = &term.line[term.c.y][term.c.x];
  }

  if (IS_SET(MODE_INSERT) && term.c.x + width < term.col)
    memmove(gp + width, gp, (term.col - term.c.x - width) * sizeof(Glyph));

  if (term.c.x + width > term.col) {
    tnewline(1);
    gp = &term.line[term.c.y][term.c.x];
  }

  tsetchar(u, &term.c.attr, term.c.x, term.c.y);
  term.lastc = u;

  if (width == 2) {
    gp->mode |= ATTR_WIDE;
    if (term.c.x + 1 < term.col) {
      gp[1].u = '\0';
      gp[1].mode = ATTR_WDUMMY;
    }
  }
  if (term.c.x + width < term.col) {
    tmoveto(term.c.x + width, term.c.y);
  } else {
    term.c.state |= CURSOR_WRAPNEXT;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x4(%rbp)
xorl %eax, %eax
cmpl -0x4(%rbp), %eax
ja 0x8a5d
movb $0x1, %al
cmpl $0x1f, -0x4(%rbp)
movb %al, -0x21(%rbp)
jbe 0x8a8a
movb $0x1, %al
cmpl $0x7f, -0x4(%rbp)
movb %al, -0x21(%rbp)
je 0x8a8a
xorl %eax, %eax
movl $0x80, %ecx
cmpl -0x4(%rbp), %ecx
movb %al, -0x22(%rbp)
ja 0x8a84
cmpl $0x9f, -0x4(%rbp)
setbe %al
movb %al, -0x22(%rbp)
movb -0x22(%rbp), %al
movb %al, -0x21(%rbp)
movb -0x21(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0xc(%rbp)
cmpl $0x7f, -0x4(%rbp)
jb 0x8aa9
movl 0x1036b(%rip), %eax     # 0x18e0c
andl $0x40, %eax
cmpl $0x0, %eax
jne 0x8abf
movl -0x4(%rbp), %eax
movb %al, -0x8(%rbp)
movl $0x1, -0x14(%rbp)
movl $0x1, -0x10(%rbp)
jmp 0x8aed
movl -0x4(%rbp), %edi
leaq -0x8(%rbp), %rsi
callq 0x5bc0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0x8aeb
movl -0x4(%rbp), %edi
callq 0x5640
movl %eax, -0x10(%rbp)
cmpl $-0x1, %eax
jne 0x8aeb
movl $0x1, -0x10(%rbp)
jmp 0x8aed
movl 0x10319(%rip), %eax     # 0x18e0c
andl $0x20, %eax
cmpl $0x0, %eax
je 0x8b08
leaq -0x8(%rbp), %rdi
movslq -0x14(%rbp), %rsi
callq 0x8760
movl 0x10302(%rip), %eax     # 0x18e10
andl $0x4, %eax
cmpl $0x0, %eax
je 0x8bf4
cmpl $0x7, -0x4(%rbp)
je 0x8b45
cmpl $0x18, -0x4(%rbp)
je 0x8b45
cmpl $0x1a, -0x4(%rbp)
je 0x8b45
cmpl $0x1b, -0x4(%rbp)
je 0x8b45
movl $0x80, %eax
cmpl -0x4(%rbp), %eax
ja 0x8b68
cmpl $0x9f, -0x4(%rbp)
ja 0x8b68
movl 0x102c5(%rip), %eax     # 0x18e10
andl $-0x6, %eax
movl %eax, 0x102bc(%rip)     # 0x18e10
movl 0x102b6(%rip), %eax     # 0x18e10
orl $0x10, %eax
movl %eax, 0x102ad(%rip)     # 0x18e10
jmp 0x8bf6
movq 0x122f1(%rip), %rax     # 0x1ae60
movslq -0x14(%rbp), %rcx
addq %rcx, %rax
cmpq 0x122db(%rip), %rax     # 0x1ae58
jb 0x8bc2
movabsq $0x7ffffffffffffffd, %rax # imm = 0x7FFFFFFFFFFFFFFD
cmpq %rax, 0x122c8(%rip)     # 0x1ae58
jbe 0x8b97
jmp 0x8edf
movq 0x122ba(%rip), %rax     # 0x1ae58
shlq %rax
movq %rax, 0x122b0(%rip)     # 0x1ae58
movq 0x122a1(%rip), %rdi     # 0x1ae50
movq 0x122a2(%rip), %rsi     # 0x1ae58
callq 0x5b20
movq %rax, 0x1228e(%rip)     # 0x1ae50
movq 0x12287(%rip), %rdi     # 0x1ae50
addq 0x12290(%rip), %rdi     # 0x1ae60
leaq -0x8(%rbp), %rsi
movslq -0x14(%rbp), %rdx
callq 0x54e0
movslq -0x14(%rbp), %rax
addq 0x12278(%rip), %rax     # 0x1ae60
movq %rax, 0x12271(%rip)     # 0x1ae60
jmp 0x8edf
jmp 0x8bf6
cmpl $0x0, -0xc(%rbp)
je 0x8c1f
movl -0x4(%rbp), %eax
movzbl %al, %edi
callq 0x8f80
cmpl $0x0, 0x10202(%rip)     # 0x18e10
jne 0x8c1a
movl $0x0, 0x1020e(%rip)     # 0x18e28
jmp 0x8edf
movl 0x101eb(%rip), %eax     # 0x18e10
andl $0x1, %eax
cmpl $0x0, %eax
je 0x8d16
movl 0x101d9(%rip), %eax     # 0x18e10
andl $0x2, %eax
cmpl $0x0, %eax
je 0x8c99
movl -0x4(%rbp), %eax
movb %al, %dl
movq 0x124a5(%rip), %rcx     # 0x1b0f0
movq %rcx, %rax
addq $0x1, %rax
movq %rax, 0x12497(%rip)     # 0x1b0f0
leaq 0x12290(%rip), %rax     # 0x1aef0
movb %dl, (%rax,%rcx)
movl $0x40, %eax
cmpl -0x4(%rbp), %eax
ja 0x8c73
cmpl $0x7e, -0x4(%rbp)
jbe 0x8c80
cmpq $0x1ff, 0x12472(%rip) # imm = 0x1FF
jb 0x8c94
movl $0x0, 0x10186(%rip)     # 0x18e10
callq 0x9110
callq 0x9280
jmp 0x8edf
movl 0x10171(%rip), %eax     # 0x18e10
andl $0x40, %eax
cmpl $0x0, %eax
je 0x8cb4
movl -0x4(%rbp), %eax
movsbl %al, %edi
callq 0x9c20
jmp 0x8d05
movl 0x10156(%rip), %eax     # 0x18e10
andl $0x8, %eax
cmpl $0x0, %eax
je 0x8ccf
movl -0x4(%rbp), %eax
movsbl %al, %edi
callq 0x9c60
jmp 0x8d03
movl 0x1013b(%rip), %eax     # 0x18e10
andl $0x20, %eax
cmpl $0x0, %eax
je 0x8cea
movl -0x4(%rbp), %eax
movsbl %al, %edi
callq 0x9ce0
jmp 0x8d01
movl -0x4(%rbp), %eax
movzbl %al, %edi
callq 0x9d60
cmpl $0x0, %eax
jne 0x8cff
jmp 0x8edf
jmp 0x8d01
jmp 0x8d03
jmp 0x8d05
jmp 0x8d07
movl $0x0, 0x100ff(%rip)     # 0x18e10
jmp 0x8edf
jmp 0x8d18
movl 0x100d2(%rip), %edi     # 0x18df0
movl 0x100d0(%rip), %esi     # 0x18df4
callq 0x61d0
cmpl $0x0, %eax
je 0x8d33
callq 0x5e00
movq 0x1008e(%rip), %rax     # 0x18dc8
movslq 0x100b3(%rip), %rcx     # 0x18df4
movq (%rax,%rcx,8), %rax
movslq 0x100a4(%rip), %rcx     # 0x18df0
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movl 0x100af(%rip), %eax     # 0x18e0c
andl $0x1, %eax
cmpl $0x0, %eax
je 0x8db4
movsbl 0x1008c(%rip), %eax     # 0x18df8
andl $0x1, %eax
cmpl $0x0, %eax
je 0x8db4
movq -0x20(%rbp), %rax
movzwl 0x4(%rax), %ecx
orl $0x100, %ecx            # imm = 0x100
movw %cx, 0x4(%rax)
movl $0x1, %edi
callq 0x9fe0
movq 0x10031(%rip), %rax     # 0x18dc8
movslq 0x10056(%rip), %rcx     # 0x18df4
movq (%rax,%rcx,8), %rax
movslq 0x10047(%rip), %rcx     # 0x18df0
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movl 0x10052(%rip), %eax     # 0x18e0c
andl $0x2, %eax
cmpl $0x0, %eax
je 0x8e01
movl 0x10028(%rip), %eax     # 0x18df0
addl -0x10(%rbp), %eax
cmpl 0xfff3(%rip), %eax      # 0x18dc4
jge 0x8e01
movq -0x20(%rbp), %rdi
movslq -0x10(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
movq -0x20(%rbp), %rsi
movl 0xffd8(%rip), %eax      # 0x18dc4
subl 0xfffe(%rip), %eax      # 0x18df0
subl -0x10(%rbp), %eax
movslq %eax, %rdx
shlq $0x4, %rdx
callq 0x54e0
movl 0xffe9(%rip), %eax      # 0x18df0
addl -0x10(%rbp), %eax
cmpl 0xffb4(%rip), %eax      # 0x18dc4
jle 0x8e40
movl $0x1, %edi
callq 0x9fe0
movq 0xffa5(%rip), %rax      # 0x18dc8
movslq 0xffca(%rip), %rcx      # 0x18df4
movq (%rax,%rcx,8), %rax
movslq 0xffbb(%rip), %rcx      # 0x18df0
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movl -0x4(%rbp), %edi
movl 0xffa7(%rip), %edx      # 0x18df0
movl 0xffa5(%rip), %ecx      # 0x18df4
leaq 0xff6a(%rip), %rsi      # 0x18dc0
addq $0x20, %rsi
callq 0xa050
movl -0x4(%rbp), %eax
movl %eax, 0xffc0(%rip)      # 0x18e28
cmpl $0x2, -0x10(%rbp)
jne 0x8ea8
movq -0x20(%rbp), %rax
movzwl 0x4(%rax), %ecx
orl $0x200, %ecx            # imm = 0x200
movw %cx, 0x4(%rax)
movl 0xff6a(%rip), %eax      # 0x18df0
addl $0x1, %eax
cmpl 0xff35(%rip), %eax      # 0x18dc4
jge 0x8ea6
movq -0x20(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x20(%rbp), %rax
movw $0x400, 0x14(%rax)      # imm = 0x400
jmp 0x8ea8
movl 0xff42(%rip), %eax      # 0x18df0
addl -0x10(%rbp), %eax
cmpl 0xff0d(%rip), %eax      # 0x18dc4
jge 0x8ecf
movl 0xff31(%rip), %edi      # 0x18df0
addl -0x10(%rbp), %edi
movl 0xff2c(%rip), %esi      # 0x18df4
callq 0x7d80
jmp 0x8edf
movsbl 0xff22(%rip), %eax      # 0x18df8
orl $0x1, %eax
movb %al, 0xff19(%rip)       # 0x18df8
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)