// File: /workspace/github_c_makefile_star2_O1/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, 0xf401(%rip)     # 0x157ac
je 0x64ff
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0xf402(%rip), %eax      # 0x157c4
movl 0xf3e0(%rip), %ecx      # 0x157a8
subl 0xf3d2(%rip), %ecx      # 0x157a0
incl %ecx
leal 0x4(,%rax,4), %eax
imull %ecx, %eax
movslq %eax, %rdi
callq 0x5e3c
movq %rax, %r15
movslq 0xf3b4(%rip), %r14      # 0x157a0
movl 0xf3b6(%rip), %ebx      # 0x157a8
movq %rax, (%rsp)
cmpl %ebx, %r14d
jg 0x64e8
movq (%rsp), %r15
movl %r14d, %edi
callq 0x6502
testl %eax, %eax
je 0x64ca
movl %eax, %r12d
cmpl $0x2, 0xf377(%rip)      # 0x15794
jne 0x6427
movl 0xf377(%rip), %eax      # 0x1579c
jmp 0x643d
xorl %eax, %eax
cmpl %r14d, 0xf370(%rip)     # 0x157a0
jne 0x6438
movl 0xf364(%rip), %eax      # 0x1579c
cmpl %r14d, %ebx
jne 0x6445
movl 0xf361(%rip), %ebp      # 0x157a4
jmp 0x644d
movl 0xf379(%rip), %ebp      # 0x157c4
decl %ebp
movq 0xf374(%rip), %rcx      # 0x157c8
movslq %eax, %rbx
shlq $0x4, %rbx
addq (%rcx,%r14,8), %rbx
movq 0xf362(%rip), %rax      # 0x157c8
leal -0x1(%r12), %ecx
cmpl %ecx, %ebp
cmovll %ebp, %ecx
movslq %ecx, %r13
shlq $0x4, %r13
addq (%rax,%r14,8), %r13
cmpq %rbx, %r13
jb 0x64a4
cmpl $0x20, (%r13)
jne 0x64a4
addq $-0x10, %r13
jmp 0x647b
testb $0x4, 0x5(%rbx)
jne 0x64a0
movl (%rbx), %edi
movq %r15, %rsi
callq 0x5f54
addq %rax, %r15
addq $0x10, %rbx
cmpq %r13, %rbx
jbe 0x648d
movslq 0xf2f8(%rip), %rax      # 0x157a8
cmpq %rax, %r14
jl 0x64ba
cmpl %r12d, %ebp
jl 0x64d1
testb $0x1, 0x5(%r13)
je 0x64ca
cmpl $0x2, 0xf2cc(%rip)      # 0x15794
jne 0x64d1
movb $0xa, (%r15)
incq %r15
leaq 0x1(%r14), %rax
movslq 0xf2cc(%rip), %rbx      # 0x157a8
cmpq %rbx, %r14
movq %rax, %r14
jl 0x6403
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