// File: /workspace/github_c_makefile_star2_O0/neovim[P]libvterm/src/screen.c
// Function: damagerect
static void damagerect(VTermScreen *screen, VTermRect rect)
{
  VTermRect emit;

  switch(screen->damage_merge) {
  case VTERM_DAMAGE_CELL:
    /* Always emit damage event */
    emit = rect;
    break;

  case VTERM_DAMAGE_ROW:
    /* Emit damage longer than one row. Try to merge with existing damage in
     * the same row */
    if(rect.end_row > rect.start_row + 1) {
      // Bigger than 1 line - flush existing, emit this
      vterm_screen_flush_damage(screen);
      emit = rect;
    }
    else if(screen->damaged.start_row == -1) {
      // None stored yet
      screen->damaged = rect;
      return;
    }
    else if(rect.start_row == screen->damaged.start_row) {
      // Merge with the stored line
      if(screen->damaged.start_col > rect.start_col)
        screen->damaged.start_col = rect.start_col;
      if(screen->damaged.end_col < rect.end_col)
        screen->damaged.end_col = rect.end_col;
      return;
    }
    else {
      // Emit the currently stored line, store a new one
      emit = screen->damaged;
      screen->damaged = rect;
    }
    break;

  case VTERM_DAMAGE_SCREEN:
  case VTERM_DAMAGE_SCROLL:
    /* Never emit damage event */
    if(screen->damaged.start_row == -1)
      screen->damaged = rect;
    else {
      rect_expand(&screen->damaged, &rect);
    }
    return;

  default:
    DEBUG_LOG("TODO: Maybe merge damage for level %d\n", screen->damage_merge);
    return;
  }

  if(screen->callbacks && screen->callbacks->damage)
    (*screen->callbacks->damage)(emit, screen->cbdata);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rsi, -0x10(%rbp)
movq %rdx, -0x8(%rbp)
movq %rdi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl 0x24(%rax), %eax
movl %eax, -0x2c(%rbp)
testl %eax, %eax
je 0x86b2
jmp 0x8694
movl -0x2c(%rbp), %eax
subl $0x1, %eax
je 0x86c7
jmp 0x869e
movl -0x2c(%rbp), %eax
addl $-0x2, %eax
subl $0x2, %eax
jb 0x8780
jmp 0x87b3
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x87b5
movl -0xc(%rbp), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jle 0x86f2
movq -0x18(%rbp), %rdi
callq 0x2040
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x877e
movq -0x18(%rbp), %rax
cmpl $-0x1, 0x28(%rax)
jne 0x8715
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, 0x28(%rax)
movq -0x8(%rbp), %rcx
movq %rcx, 0x30(%rax)
jmp 0x87eb
movl -0x10(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jne 0x8752
movq -0x18(%rbp), %rax
movl 0x30(%rax), %eax
cmpl -0x8(%rbp), %eax
jle 0x8737
movl -0x8(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x18(%rbp), %rax
movl 0x34(%rax), %eax
cmpl -0x4(%rbp), %eax
jge 0x874d
movl -0x4(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x34(%rax)
jmp 0x87eb
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rcx
movq %rcx, -0x28(%rbp)
movq 0x30(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, 0x28(%rax)
movq -0x8(%rbp), %rcx
movq %rcx, 0x30(%rax)
jmp 0x877c
jmp 0x877e
jmp 0x87b5
movq -0x18(%rbp), %rax
cmpl $-0x1, 0x28(%rax)
jne 0x87a0
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, 0x28(%rax)
movq -0x8(%rbp), %rcx
movq %rcx, 0x30(%rax)
jmp 0x87b1
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
leaq -0x10(%rbp), %rsi
callq 0x8800
jmp 0x87eb
jmp 0x87eb
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x87eb
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
cmpq $0x0, (%rax)
je 0x87eb
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rdx
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq *%rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)