// File: /workspace/github_c_makefile_star2_O3/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, 0xf31b(%rip)     # 0x1579c
je 0x65ea
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl 0xf319(%rip), %eax      # 0x157b4
movl 0xf2f7(%rip), %ecx      # 0x15798
subl 0xf2e9(%rip), %ecx      # 0x15790
incl %ecx
leal 0x4(,%rax,4), %eax
imull %ecx, %eax
movslq %eax, %rdi
callq 0x5e2c
movq %rax, %r15
movslq 0xf2cb(%rip), %r14      # 0x15790
movl 0xf2cc(%rip), %r13d     # 0x15798
movq %rax, 0x10(%rsp)
cmpl %r13d, %r14d
jg 0x65d2
movq 0x10(%rsp), %r15
movl %r14d, %edi
callq 0x65ed
testl %eax, %eax
je 0x65b4
movl %eax, %r12d
cmpl $0x2, 0xf28b(%rip)      # 0x15784
jne 0x6503
movl 0xf28b(%rip), %eax      # 0x1578c
jmp 0x6519
xorl %eax, %eax
cmpl %r14d, 0xf284(%rip)     # 0x15790
jne 0x6514
movl 0xf278(%rip), %eax      # 0x1578c
cmpl %r14d, %r13d
jne 0x6521
movl 0xf275(%rip), %esi      # 0x15794
jmp 0x6529
movl 0xf28d(%rip), %esi      # 0x157b4
decl %esi
movq 0xf288(%rip), %rcx      # 0x157b8
movq (%rcx,%r14,8), %rcx
cltq
movq %rax, %rbp
shlq $0x4, %rbp
addq %rcx, %rbp
leal -0x1(%r12), %edx
cmpl %edx, %esi
movl %esi, 0xc(%rsp)
cmovll %esi, %edx
movslq %edx, %rdx
movq %rdx, %rbx
shlq $0x4, %rbx
addq %rcx, %rbx
cmpl %eax, %edx
jl 0x656d
cmpl $0x20, (%rbx)
jne 0x656d
addq $-0x10, %rbx
cmpq %rbp, %rbx
jae 0x655f
cmpq %rbx, %rbp
ja 0x6596
testb $0x4, 0x5(%rbp)
jne 0x6586
movl (%rbp), %edi
movq %r15, %rsi
callq 0x5f44
addq %rax, %r15
addq $0x10, %rbp
cmpq %rbx, %rbp
jbe 0x6572
movl 0xf202(%rip), %r13d     # 0x15798
movslq %r13d, %rax
cmpq %rax, %r14
jl 0x65a5
cmpl %r12d, 0xc(%rsp)
jl 0x65bb
testb $0x1, 0x5(%rbx)
je 0x65b4
cmpl $0x2, 0xf1d2(%rip)      # 0x15784
jne 0x65bb
movb $0xa, (%r15)
incq %r15
leaq 0x1(%r14), %rax
movslq 0xf1d2(%rip), %r13      # 0x15798
cmpq %r13, %r14
movq %rax, %r14
jl 0x64df
movb $0x0, (%r15)
movq 0x10(%rsp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
retq