// File: /workspace/github_c_makefile_star2_O2/jaimecgomezz[P]st/st.c
// Function: getsel
char *getsel(void) {
  char *str, *ptr;
  // >>>>>>>>>>>>>>>>>>>> vim-browse
  // ==================== vim-browse
  int y, bufsize, lastx, linelen;
  // ==================== vim-browse
  // <<<<<<<<<<<<<<<<<<<< vim-browse
  Glyph *gp, *last;

  if (sel.ob.x == -1)
    return NULL;

  // >>>>>>>>>>>>>>>>>>>> vim-browse
  // ==================== vim-browse
  bufsize = (term.col + 1) * (sel.ne.y - sel.nb.y + 1) * UTF_SIZ;
  // ==================== vim-browse
  // <<<<<<<<<<<<<<<<<<<< vim-browse
  ptr = str = xmalloc(bufsize);

  /* append every set & selected glyph to the selection */
  // >>>>>>>>>>>>>>>>>>>> vim-browse
  // ==================== vim-browse
  for (y = sel.nb.y; y <= sel.ne.y; y++) {
    if ((linelen = tlinelen(y)) == 0) {
      *ptr++ = '\n';
      continue;
    }
  // ==================== vim-browse
  // <<<<<<<<<<<<<<<<<<<< vim-browse

    if (sel.type == SEL_RECTANGULAR) {
      // >>>>>>>>>>>>>>>>>>>> vim-browse-scrollback
      // ==================== vim-browse-scrollback
      gp = &term.line[y][sel.nb.x];
      // ==================== vim-browse-scrollback
      // <<<<<<<<<<<<<<<<<<<< vim-browse-scrollback
      lastx = sel.ne.x;
    } else {
      // >>>>>>>>>>>>>>>>>>>> vim-browse-scrollback
      // ==================== vim-browse-scrollback
      gp = &term.line[y][sel.nb.y == y ? sel.nb.x : 0];
      lastx = (sel.ne.y == y) ? sel.ne.x : term.col - 1;
      // ==================== vim-browse-scrollback
      // <<<<<<<<<<<<<<<<<<<< vim-browse-scrollback
    }
    // >>>>>>>>>>>>>>>>>>>> vim-browse-scrollback
    // ==================== vim-browse-scrollback
    last = &term.line[y][MIN(lastx, linelen - 1)];
    while (last >= gp && last->u == ' ')
      --last;
    // ==================== vim-browse-scrollback
    // <<<<<<<<<<<<<<<<<<<< vim-browse-scrollback

    for (; gp <= last; ++gp) {
      // >>>>>>>>>>>>>>>>>>>> vim-browse
      // ==================== vim-browse
      if (gp->mode & ATTR_WDUMMY)
        continue;
      // ==================== vim-browse
      // <<<<<<<<<<<<<<<<<<<< vim-browse

      ptr += utf8encode(gp->u, ptr);
    }

    /*
     * Copy and pasting of line endings is inconsistent
     * in the inconsistent terminal and GUI world.
     * The best solution seems like to produce '\n' when
     * something is copied from st and convert '\n' to
     * '\r', when something to be pasted is received by
     * st.
     * FIXME: Fix the computer world.
     */
    // >>>>>>>>>>>>>>>>>>>> vim-browse
    // ==================== vim-browse
    if ((y < sel.ne.y || lastx >= linelen) &&
    // ==================== vim-browse
    // <<<<<<<<<<<<<<<<<<<< vim-browse
        (!(last->mode & ATTR_WRAP) || sel.type == SEL_RECTANGULAR))
      *ptr++ = '\n';
  }
  *ptr = 0;
  return str;
}

// Assembly:
cmpl $-0x1, 0xe85a(%rip)     # 0x1479c
je 0x607f
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0xe85b(%rip), %eax      # 0x147b4
movl 0xe839(%rip), %ecx      # 0x14798
subl 0xe82b(%rip), %ecx      # 0x14790
incl %ecx
leal 0x4(,%rax,4), %eax
imull %ecx, %eax
movslq %eax, %rdi
callq 0x59fc
movq %rax, %r15
movslq 0xe80d(%rip), %r14      # 0x14790
movq %rax, (%rsp)
movslq 0xe80a(%rip), %rbx      # 0x14798
cmpq %rbx, %r14
jg 0x6068
movl %r14d, %edi
callq 0x6082
testl %eax, %eax
je 0x6059
movl %eax, %r12d
cmpl $0x2, 0xe7d3(%rip)      # 0x14784
jne 0x5fbb
movl 0xe7d3(%rip), %eax      # 0x1478c
jmp 0x5fd1
xorl %eax, %eax
cmpl %r14d, 0xe7cc(%rip)     # 0x14790
jne 0x5fcc
movl 0xe7c0(%rip), %eax      # 0x1478c
cmpl %r14d, %ebx
jne 0x5fd9
movl 0xe7bd(%rip), %ebp      # 0x14794
jmp 0x5fe1
movl 0xe7d5(%rip), %ebp      # 0x147b4
decl %ebp
movq 0xe7d0(%rip), %rcx      # 0x147b8
movq (%rcx,%r14,8), %rcx
movslq %eax, %r13
shlq $0x4, %r13
addq %rcx, %r13
leal -0x1(%r12), %eax
cmpl %eax, %ebp
cmovll %ebp, %eax
movslq %eax, %rbx
shlq $0x4, %rbx
addq %rcx, %rbx
cmpq %r13, %rbx
jb 0x6034
cmpl $0x20, (%rbx)
jne 0x6034
addq $-0x10, %rbx
jmp 0x600a
testb $0x4, 0x5(%r13)
jne 0x6030
movl (%r13), %edi
movq %r15, %rsi
callq 0x5b12
addq %rax, %r15
addq $0x10, %r13
cmpq %rbx, %r13
jbe 0x601a
movslq 0xe758(%rip), %rax      # 0x14798
cmpq %rax, %r14
jl 0x604a
cmpl %r12d, %ebp
jl 0x6060
testb $0x1, 0x5(%rbx)
je 0x6059
cmpl $0x2, 0xe72d(%rip)      # 0x14784
jne 0x6060
movb $0xa, (%r15)
incq %r15
incq %r14
jmp 0x5f87
movb $0x0, (%r15)
movq (%rsp), %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
retq