// File: /workspace/github_c_makefile_star2_O0/neovim[P]libvterm/src/screen.c
// Function: resize
static int resize(int new_rows, int new_cols, VTermStateFields *fields, void *user)
{
  VTermScreen *screen = user;

  int altscreen_active = (screen->buffers[BUFIDX_ALTSCREEN] && screen->buffer == screen->buffers[BUFIDX_ALTSCREEN]);

  int old_rows = screen->rows;
  int old_cols = screen->cols;

  if(new_cols > old_cols) {
    /* Ensure that ->sb_buffer is large enough for a new or and old row */
    if(screen->sb_buffer)
      vterm_allocator_free(screen->vt, screen->sb_buffer);

    screen->sb_buffer = vterm_allocator_malloc(screen->vt, sizeof(VTermScreenCell) * new_cols);
  }

  resize_buffer(screen, 0, new_rows, new_cols, !altscreen_active, fields);
  if(screen->buffers[BUFIDX_ALTSCREEN])
    resize_buffer(screen, 1, new_rows, new_cols, altscreen_active, fields);
  else if(new_rows != old_rows) {
    /* We don't need a full resize of the altscreen because it isn't enabled
     * but we should at least keep the lineinfo the right size */
    vterm_allocator_free(screen->vt, fields->lineinfos[BUFIDX_ALTSCREEN]);

    VTermLineInfo *new_lineinfo = vterm_allocator_malloc(screen->vt, sizeof(new_lineinfo[0]) * new_rows);
    for(int row = 0; row < new_rows; row++)
      new_lineinfo[row] = (VTermLineInfo){ 0 };

    fields->lineinfos[BUFIDX_ALTSCREEN] = new_lineinfo;
  }

  screen->buffer = altscreen_active ? screen->buffers[BUFIDX_ALTSCREEN] : screen->buffers[BUFIDX_PRIMARY];

  screen->rows = new_rows;
  screen->cols = new_cols;

  if(new_cols <= old_cols) {
    if(screen->sb_buffer)
      vterm_allocator_free(screen->vt, screen->sb_buffer);

    screen->sb_buffer = vterm_allocator_malloc(screen->vt, sizeof(VTermScreenCell) * new_cols);
  }

  /* TODO: Maaaaybe we can optimise this if there's no reflow happening */
  damagescreen(screen);

  if(screen->callbacks && screen->callbacks->resize)
    return (*screen->callbacks->resize)(new_rows, new_cols, screen->cbdata);

  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x68(%rcx)
movb %al, -0x49(%rbp)
je 0x8134
movq -0x28(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x28(%rbp), %rcx
cmpq 0x68(%rcx), %rax
sete %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rax
movl 0x50(%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movl 0x54(%rax), %eax
movl %eax, -0x34(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x34(%rbp), %eax
jle 0x8199
movq -0x28(%rbp), %rax
cmpq $0x0, 0x78(%rax)
je 0x817a
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x78(%rax), %rsi
callq 0x11ae0
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movslq -0xc(%rbp), %rax
imulq $0x28, %rax, %rsi
callq 0x11a20
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x78(%rax)
movq -0x28(%rbp), %rdi
movl -0x8(%rbp), %edx
movl -0xc(%rbp), %ecx
cmpl $0x0, -0x2c(%rbp)
setne %al
xorb $-0x1, %al
movq -0x18(%rbp), %r9
xorl %esi, %esi
movzbl %al, %r8d
andl $0x1, %r8d
xorl %esi, %esi
callq 0x8e20
movq -0x28(%rbp), %rax
cmpq $0x0, 0x68(%rax)
je 0x81f8
movq -0x28(%rbp), %rdi
movl -0x8(%rbp), %edx
movl -0xc(%rbp), %ecx
cmpl $0x0, -0x2c(%rbp)
setne %al
movq -0x18(%rbp), %r9
movzbl %al, %r8d
andl $0x1, %r8d
movl $0x1, %esi
callq 0x8e20
jmp 0x828a
movl -0x8(%rbp), %eax
cmpl -0x30(%rbp), %eax
je 0x8288
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x11ae0
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movslq -0x8(%rbp), %rsi
shlq $0x2, %rsi
callq 0x11a20
movq %rax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x827c
movq -0x40(%rbp), %rax
movslq -0x44(%rbp), %rcx
movb -0x48(%rbp), %dl
andb $-0x2, %dl
orb $0x0, %dl
movb %dl, -0x48(%rbp)
movb -0x48(%rbp), %dl
andb $-0x7, %dl
orb $0x0, %dl
movb %dl, -0x48(%rbp)
movb -0x48(%rbp), %dl
andb $-0x9, %dl
orb $0x0, %dl
movb %dl, -0x48(%rbp)
movl -0x48(%rbp), %edx
movl %edx, (%rax,%rcx,4)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x8237
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x828a
cmpl $0x0, -0x2c(%rbp)
je 0x829e
movq -0x28(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0x82aa
movq -0x28(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x70(%rax)
movl -0x8(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x50(%rax)
movl -0xc(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x54(%rax)
movl -0xc(%rbp), %eax
cmpl -0x34(%rbp), %eax
jg 0x8310
movq -0x28(%rbp), %rax
cmpq $0x0, 0x78(%rax)
je 0x82f1
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x78(%rax), %rsi
callq 0x11ae0
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movslq -0xc(%rbp), %rax
imulq $0x28, %rax, %rsi
callq 0x11a20
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x78(%rax)
movq -0x28(%rbp), %rdi
callq 0x8dd0
movq -0x28(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x8354
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
cmpq $0x0, 0x28(%rax)
je 0x8354
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x28(%rax), %rax
movl -0x8(%rbp), %edi
movl -0xc(%rbp), %esi
movq -0x28(%rbp), %rcx
movq 0x18(%rcx), %rdx
callq *%rax
movl %eax, -0x4(%rbp)
jmp 0x835b
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)