// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
cmpl $-0x1, 0x12aad(%rip)    # 0x18dac
jne 0x630e
movq $0x0, -0x8(%rbp)
jmp 0x653e
movl 0x12ab0(%rip), %eax     # 0x18dc4
addl $0x1, %eax
movl 0x12a8b(%rip), %ecx     # 0x18da8
subl 0x12a7d(%rip), %ecx     # 0x18da0
addl $0x1, %ecx
imull %ecx, %eax
shll $0x2, %eax
movl %eax, -0x20(%rbp)
movslq -0x20(%rbp), %rdi
callq 0x5a20
movq %rax, -0x10(%rbp)
movq %rax, -0x18(%rbp)
movl 0x12a5a(%rip), %eax     # 0x18da0
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl 0x12a56(%rip), %eax     # 0x18da8
jg 0x652f
movl -0x1c(%rbp), %edi
callq 0x6550
movl %eax, -0x28(%rbp)
cmpl $0x0, %eax
jne 0x637f
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x18(%rbp)
movb $0xa, (%rax)
jmp 0x6521
cmpl $0x2, 0x12a0e(%rip)     # 0x18d94
jne 0x63b4
movq 0x12a39(%rip), %rax     # 0x18dc8
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x129fe(%rip), %rcx     # 0x18d9c
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl 0x129f5(%rip), %eax     # 0x18da4
movl %eax, -0x24(%rbp)
jmp 0x6421
movq 0x12a0d(%rip), %rax     # 0x18dc8
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movl 0x129d3(%rip), %eax     # 0x18da0
cmpl -0x1c(%rbp), %eax
jne 0x63dd
movl 0x129c4(%rip), %eax     # 0x18d9c
movl %eax, -0x44(%rbp)
jmp 0x63e4
xorl %eax, %eax
movl %eax, -0x44(%rbp)
jmp 0x63e4
movq -0x40(%rbp), %rax
movl -0x44(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl 0x129a9(%rip), %eax     # 0x18da8
cmpl -0x1c(%rbp), %eax
jne 0x640f
movl 0x1299a(%rip), %eax     # 0x18da4
movl %eax, -0x48(%rbp)
jmp 0x641b
movl 0x129af(%rip), %eax     # 0x18dc4
subl $0x1, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x24(%rbp)
movq 0x129a0(%rip), %rax     # 0x18dc8
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
movl -0x24(%rbp), %eax
movl -0x28(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x6449
movl -0x24(%rbp), %eax
movl %eax, -0x54(%rbp)
jmp 0x6452
movl -0x28(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x54(%rbp)
movq -0x50(%rbp), %rax
movl -0x54(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rcx
xorl %eax, %eax
cmpq -0x30(%rbp), %rcx
movb %al, -0x55(%rbp)
jb 0x6483
movq -0x38(%rbp), %rax
cmpl $0x20, (%rax)
sete %al
movb %al, -0x55(%rbp)
movb -0x55(%rbp), %al
testb $0x1, %al
jne 0x648c
jmp 0x649a
movq -0x38(%rbp), %rax
addq $-0x10, %rax
movq %rax, -0x38(%rbp)
jmp 0x6467
jmp 0x649c
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
ja 0x64df
movq -0x30(%rbp), %rax
movzwl 0x4(%rax), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x64ba
jmp 0x64d1
movq -0x30(%rbp), %rax
movl (%rax), %edi
movq -0x18(%rbp), %rsi
callq 0x5bc0
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x30(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x30(%rbp)
jmp 0x649c
movl -0x1c(%rbp), %eax
cmpl 0x128c0(%rip), %eax     # 0x18da8
jl 0x64f2
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jl 0x651f
movq -0x38(%rbp), %rax
movzwl 0x4(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x650d
cmpl $0x2, 0x12889(%rip)     # 0x18d94
jne 0x651f
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x18(%rbp)
movb $0xa, (%rax)
jmp 0x6521
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x6349
movq -0x18(%rbp), %rax
movb $0x0, (%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)