// File: /workspace/github_c_makefile_star2_O0/neovim[P]libvterm/src/screen.c
// Function: get_chars
static size_t _get_chars(const VTermScreen *screen, const int utf8, void *buffer, size_t len, const VTermRect rect)
{
  size_t outpos = 0;
  int padding = 0;

#define PUT(c)                                             \
  if(utf8) {                                               \
    size_t thislen = utf8_seqlen(c);                       \
    if(buffer && outpos + thislen <= len)                  \
      outpos += fill_utf8((c), (char *)buffer + outpos);   \
    else                                                   \
      outpos += thislen;                                   \
  }                                                        \
  else {                                                   \
    if(buffer && outpos + 1 <= len)                        \
      ((uint32_t*)buffer)[outpos++] = (c);                 \
    else                                                   \
      outpos++;                                            \
  }

  for(int row = rect.start_row; row < rect.end_row; row++) {
    for(int col = rect.start_col; col < rect.end_col; col++) {
      ScreenCell *cell = getcell(screen, row, col);

      if(cell->chars[0] == 0)
        // Erased cell, might need a space
        padding++;
      else if(cell->chars[0] == (uint32_t)-1)
        // Gap behind a double-width char, do nothing
        ;
      else {
        while(padding) {
          PUT(UNICODE_SPACE);
          padding--;
        }
        for(int i = 0; i < VTERM_MAX_CHARS_PER_CELL && cell->chars[i]; i++) {
          PUT(cell->chars[i]);
        }
      }
    }

    if(row < rect.end_row - 1) {
      PUT(UNICODE_LINEFEED);
      padding = 0;
    }
  }

  return outpos;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %r8, -0x10(%rbp)
movq %r9, -0x8(%rbp)
movq %rdi, -0x18(%rbp)
movl %esi, -0x1c(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x678c
movl -0x8(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x66ce
movq -0x18(%rbp), %rdi
movl -0x40(%rbp), %esi
movl -0x44(%rbp), %edx
callq 0x6a70
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x650f
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x66be
movq -0x50(%rbp), %rax
cmpl $-0x1, (%rax)
jne 0x651d
jmp 0x66bc
jmp 0x651f
cmpl $0x0, -0x3c(%rbp)
je 0x65cd
cmpl $0x0, -0x1c(%rbp)
je 0x6580
movl $0x20, %edi
callq 0x7620
movl %eax, %eax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x6572
movq -0x38(%rbp), %rax
addq -0x58(%rbp), %rax
cmpq -0x30(%rbp), %rax
ja 0x6572
movq -0x28(%rbp), %rsi
addq -0x38(%rbp), %rsi
movl $0x20, %edi
callq 0x76a0
cltq
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x657e
movq -0x58(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x65bf
cmpq $0x0, -0x28(%rbp)
je 0x65b1
movq -0x38(%rbp), %rax
addq $0x1, %rax
cmpq -0x30(%rbp), %rax
ja 0x65b1
movq -0x28(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x38(%rbp)
movl $0x20, (%rax,%rcx,4)
jmp 0x65bd
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x65bf
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x651f
movl $0x0, -0x5c(%rbp)
xorl %eax, %eax
cmpl $0x6, -0x5c(%rbp)
movb %al, -0x71(%rbp)
jge 0x65f1
movq -0x50(%rbp), %rax
movslq -0x5c(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
setne %al
movb %al, -0x71(%rbp)
movb -0x71(%rbp), %al
testb $0x1, %al
jne 0x65fd
jmp 0x66ba
cmpl $0x0, -0x1c(%rbp)
je 0x6664
movq -0x50(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, %edi
callq 0x7620
movl %eax, %eax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x6656
movq -0x38(%rbp), %rax
addq -0x68(%rbp), %rax
cmpq -0x30(%rbp), %rax
ja 0x6656
movq -0x50(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, %edi
movq -0x28(%rbp), %rsi
addq -0x38(%rbp), %rsi
callq 0x76a0
cltq
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x6662
movq -0x68(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x66aa
cmpq $0x0, -0x28(%rbp)
je 0x669c
movq -0x38(%rbp), %rax
addq $0x1, %rax
cmpq -0x30(%rbp), %rax
ja 0x669c
movq -0x50(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x28(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x38(%rbp)
movl %edx, (%rax,%rcx,4)
jmp 0x66a8
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x66aa
jmp 0x66ac
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x65d4
jmp 0x66bc
jmp 0x66be
jmp 0x66c0
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x64d9
movl -0x40(%rbp), %eax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x677c
cmpl $0x0, -0x1c(%rbp)
je 0x6736
movl $0xa, %edi
callq 0x7620
movl %eax, %eax
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x6728
movq -0x38(%rbp), %rax
addq -0x70(%rbp), %rax
cmpq -0x30(%rbp), %rax
ja 0x6728
movq -0x28(%rbp), %rsi
addq -0x38(%rbp), %rsi
movl $0xa, %edi
callq 0x76a0
cltq
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x6734
movq -0x70(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x6775
cmpq $0x0, -0x28(%rbp)
je 0x6767
movq -0x38(%rbp), %rax
addq $0x1, %rax
cmpq -0x30(%rbp), %rax
ja 0x6767
movq -0x28(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x38(%rbp)
movl $0xa, (%rax,%rcx,4)
jmp 0x6773
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x6775
movl $0x0, -0x3c(%rbp)
jmp 0x677e
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x64c7
movq -0x38(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)