// File: /workspace/github_c_makefile_star2_O1/neovim[P]libvterm/src/screen.c
// Function: resize_buffer
static void resize_buffer(VTermScreen *screen, int bufidx, int new_rows, int new_cols, bool active, VTermStateFields *statefields)
{
  int old_rows = screen->rows;
  int old_cols = screen->cols;

  ScreenCell *old_buffer = screen->buffers[bufidx];
  VTermLineInfo *old_lineinfo = statefields->lineinfos[bufidx];

  ScreenCell *new_buffer = vterm_allocator_malloc(screen->vt, sizeof(ScreenCell) * new_rows * new_cols);
  VTermLineInfo *new_lineinfo = vterm_allocator_malloc(screen->vt, sizeof(new_lineinfo[0]) * new_rows);

  int old_row = old_rows - 1;
  int new_row = new_rows - 1;

  VTermPos old_cursor = statefields->pos;
  VTermPos new_cursor = { -1, -1 };

#ifdef DEBUG_REFLOW
  fprintf(stderr, "Resizing from %dx%d to %dx%d; cursor was at (%d,%d)\n",
      old_cols, old_rows, new_cols, new_rows, old_cursor.col, old_cursor.row);
#endif

  /* Keep track of the final row that is knonw to be blank, so we know what
   * spare space we have for scrolling into
   */
  int final_blank_row = new_rows;

  while(old_row >= 0) {
    int old_row_end = old_row;
    /* TODO: Stop if dwl or dhl */
    while(screen->reflow && old_lineinfo && old_row >= 0 && old_lineinfo[old_row].continuation)
      old_row--;
    int old_row_start = old_row;

    int width = 0;
    for(int row = old_row_start; row <= old_row_end; row++) {
      if(screen->reflow && row < (old_rows - 1) && old_lineinfo[row + 1].continuation)
        width += old_cols;
      else
        width += line_popcount(old_buffer, row, old_rows, old_cols);
    }

    if(final_blank_row == (new_row + 1) && width == 0)
      final_blank_row = new_row;

    int new_height = screen->reflow
      ? width ? (width + new_cols - 1) / new_cols : 1
      : 1;

    int new_row_end = new_row;
    int new_row_start = new_row - new_height + 1;

    old_row = old_row_start;
    int old_col = 0;

    int spare_rows = new_rows - final_blank_row;

    if(new_row_start < 0 && /* we'd fall off the top */
        spare_rows >= 0 && /* we actually have spare rows */
        (!active || new_cursor.row == -1 || (new_cursor.row - new_row_start) < new_rows))
    {
      /* Attempt to scroll content down into the blank rows at the bottom to
       * make it fit
       */
      int downwards = -new_row_start;
      if(downwards > spare_rows)
        downwards = spare_rows;
      int rowcount = new_rows - downwards;

#ifdef DEBUG_REFLOW
      fprintf(stderr, "  scroll %d rows +%d downwards\n", rowcount, downwards);
#endif

      memmove(&new_buffer[downwards * new_cols], &new_buffer[0],   rowcount * new_cols * sizeof(ScreenCell));
      memmove(&new_lineinfo[downwards],          &new_lineinfo[0], rowcount            * sizeof(new_lineinfo[0]));

      new_row += downwards;
      new_row_start += downwards;
      new_row_end += downwards;

      if(new_cursor.row >= 0)
        new_cursor.row += downwards;

      final_blank_row += downwards;
    }

#ifdef DEBUG_REFLOW
    fprintf(stderr, "  rows [%d..%d] <- [%d..%d] width=%d\n",
        new_row_start, new_row_end, old_row_start, old_row_end, width);
#endif

    if(new_row_start < 0) {
      if(old_row_start <= old_cursor.row && old_cursor.row < old_row_end) {
        new_cursor.row = 0;
        new_cursor.col = old_cursor.col;
        if(new_cursor.col >= new_cols)
          new_cursor.col = new_cols-1;
      }
      break;
    }

    for(new_row = new_row_start, old_row = old_row_start; new_row <= new_row_end; new_row++) {
      int count = width >= new_cols ? new_cols : width;
      width -= count;

      int new_col = 0;

      while(count) {
        /* TODO: This could surely be done a lot faster by memcpy()'ing the entire range */
        new_buffer[new_row * new_cols + new_col] = old_buffer[old_row * old_cols + old_col];

        if(old_cursor.row == old_row && old_cursor.col == old_col)
          new_cursor.row = new_row, new_cursor.col = new_col;

        old_col++;
        if(old_col == old_cols) {
          old_row++;

          if(!screen->reflow) {
            new_col++;
            break;
          }
          old_col = 0;
        }

        new_col++;
        count--;
      }

      if(old_cursor.row == old_row && old_cursor.col >= old_col) {
        new_cursor.row = new_row, new_cursor.col = (old_cursor.col - old_col + new_col);
        if(new_cursor.col >= new_cols)
          new_cursor.col = new_cols-1;
      }

      while(new_col < new_cols) {
        clearcell(screen, &new_buffer[new_row * new_cols + new_col]);
        new_col++;
      }

      new_lineinfo[new_row].continuation = (new_row > new_row_start);
    }

    old_row = old_row_start - 1;
    new_row = new_row_start - 1;
  }

  if(old_cursor.row <= old_row) {
    /* cursor would have moved entirely off the top of the screen; lets just
     * bring it within range */
    new_cursor.row = 0, new_cursor.col = old_cursor.col;
    if(new_cursor.col >= new_cols)
      new_cursor.col = new_cols-1;
  }

  /* We really expect the cursor position to be set by now */
  if(active && (new_cursor.row == -1 || new_cursor.col == -1)) {
    fprintf(stderr, "screen_resize failed to update cursor position\n");
    abort();
  }

  if(old_row >= 0 && bufidx == BUFIDX_PRIMARY) {
    /* Push spare lines to scrollback buffer */
    if((screen->callbacks && screen->callbacks->sb_pushline) ||
          (screen->callbacks_has_pushline4 && screen->callbacks && screen->callbacks->sb_pushline4))
      for(int row = 0; row <= old_row; row++) {
        const VTermLineInfo *lineinfo = old_lineinfo + row;
        sb_pushline_from_row(screen, row, lineinfo->continuation);
      }
    if(active)
      statefields->pos.row -= (old_row + 1);
  }
  if(new_row >= 0 && bufidx == BUFIDX_PRIMARY &&
      screen->callbacks && screen->callbacks->sb_popline) {
    /* Try to backfill rows by popping scrollback buffer */
    while(new_row >= 0) {
      if(!(screen->callbacks->sb_popline(old_cols, screen->sb_buffer, screen->cbdata)))
        break;

      VTermPos pos = { .row = new_row };
      for(pos.col = 0; pos.col < old_cols && pos.col < new_cols; pos.col += screen->sb_buffer[pos.col].width) {
        VTermScreenCell *src = &screen->sb_buffer[pos.col];
        ScreenCell *dst = &new_buffer[pos.row * new_cols + pos.col];

        for(int i = 0; i < VTERM_MAX_CHARS_PER_CELL; i++) {
          dst->chars[i] = src->chars[i];
          if(!src->chars[i])
            break;
        }

        dst->pen.bold      = src->attrs.bold;
        dst->pen.underline = src->attrs.underline;
        dst->pen.italic    = src->attrs.italic;
        dst->pen.blink     = src->attrs.blink;
        dst->pen.reverse   = src->attrs.reverse ^ screen->global_reverse;
        dst->pen.conceal   = src->attrs.conceal;
        dst->pen.strike    = src->attrs.strike;
        dst->pen.font      = src->attrs.font;
        dst->pen.small     = src->attrs.small;
        dst->pen.baseline  = src->attrs.baseline;

        dst->pen.fg = src->fg;
        dst->pen.bg = src->bg;

        if(src->width == 2 && pos.col < (new_cols-1))
          (dst + 1)->chars[0] = (uint32_t) -1;
      }
      for( ; pos.col < new_cols; pos.col++)
        clearcell(screen, &new_buffer[pos.row * new_cols + pos.col]);
      new_row--;

      if(active)
        statefields->pos.row++;
    }
  }
  if(new_row >= 0) {
    /* Scroll new rows back up to the top and fill in blanks at the bottom */
    int moverows = new_rows - new_row - 1;
    memmove(&new_buffer[0], &new_buffer[(new_row + 1) * new_cols], moverows * new_cols * sizeof(ScreenCell));
    memmove(&new_lineinfo[0], &new_lineinfo[new_row + 1], moverows * sizeof(new_lineinfo[0]));

    new_cursor.row -= (new_row + 1);

    for(new_row = moverows; new_row < new_rows; new_row++) {
      for(int col = 0; col < new_cols; col++)
        clearcell(screen, &new_buffer[new_row * new_cols + col]);
      new_lineinfo[new_row] = (VTermLineInfo){ 0 };
    }
  }

  vterm_allocator_free(screen->vt, old_buffer);
  screen->buffers[bufidx] = new_buffer;

  vterm_allocator_free(screen->vt, old_lineinfo);
  statefields->lineinfos[bufidx] = new_lineinfo;

  if(active)
    statefields->pos = new_cursor;

  return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %r9, %rbx
movl %r8d, 0x18(%rsp)
movl %ecx, 0x8(%rsp)
movl %edx, 0xc(%rsp)
movq %rdi, %r14
movslq 0x50(%rdi), %rax
movq %rax, 0xa0(%rsp)
movl 0x54(%rdi), %ebp
movl %esi, 0x6c(%rsp)
movl %esi, %eax
movq 0x60(%rdi,%rax,8), %r12
movq %rax, 0xc0(%rsp)
movq 0x8(%r9,%rax,8), %rax
movq %rax, 0x90(%rsp)
movslq %edx, %r13
movslq %ecx, %r15
leaq (,%r15,4), %rax
leaq (%rax,%rax,8), %rsi
movq %rsi, 0x58(%rsp)
imulq %r13, %rsi
movq (%rdi), %rdi
callq 0xa39f
movq %rax, 0x38(%rsp)
movq (%r14), %rdi
leaq (,%r13,4), %rsi
callq 0xa39f
movq %r13, %r8
movl 0x8(%rsp), %r11d
movq %rax, 0x60(%rsp)
movq 0xa0(%rsp), %rdi
decq %rdi
decl %r8d
movl 0x4(%rbx), %eax
movslq %ebp, %rdx
movl %edx, %ecx
sarl $0x1f, %ecx
movl %ebp, 0x34(%rsp)
andl %ebp, %ecx
movl %ecx, 0xb0(%rsp)
leal -0x1(%r15), %ecx
movl 0x18(%rsp), %esi
movq %r14, %r10
xorb $0x1, %sil
movb %sil, 0x13(%rsp)
movq %r15, 0x70(%rsp)
cmpl %r15d, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x14(%rsp)
cmovll %eax, %ecx
movl %ecx, 0xa8(%rsp)
movq %rbx, 0x88(%rsp)
movl (%rbx), %eax
movl %eax, 0x50(%rsp)
leaq 0x80(%r14), %r13
leal 0x1(%rdx), %eax
movl %eax, 0xb4(%rsp)
leaq -0x24(%r12), %rax
movq %rax, 0xc8(%rsp)
movq %rdx, 0xb8(%rsp)
leaq (,%rdx,4), %rax
leaq (%rax,%rax,8), %rax
movq %rax, 0x80(%rsp)
movl 0xc(%rsp), %eax
movl %eax, 0x1c(%rsp)
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rdi, %rax
movq %rdi, 0xa0(%rsp)
movq %rax, 0x20(%rsp)
movq %r10, 0x48(%rsp)
movq %r13, 0xd0(%rsp)
cmpl $0x0, 0x20(%rsp)
js 0x61c5
movq %r10, %rax
movq 0x90(%rsp), %r10
testq %r10, %r10
setne %dl
movb 0x58(%rax), %cl
movl %ecx, %eax
shrb %al
andb %dl, %al
movq 0x20(%rsp), %rdi
cmpb $0x1, %al
jne 0x5e46
movq 0x20(%rsp), %rdx
movl %edx, %esi
testb $0x8, (%r10,%rsi,4)
je 0x5e44
leal -0x1(%rdx), %edi
testl %edx, %edx
setg %sil
movl %edi, %edx
testb %sil, %al
jne 0x5e29
jmp 0x5e46
movl %edx, %edi
movq %r8, 0x28(%rsp)
xorl %r15d, %r15d
movq %rdi, 0x40(%rsp)
cmpl 0x20(%rsp), %edi
jg 0x5ee5
movslq 0x40(%rsp), %rax
movq 0x20(%rsp), %rdx
incl %edx
leaq (%rax,%rax,8), %rsi
leaq 0x24(,%rsi,4), %rsi
imulq 0xb8(%rsp), %rsi
addq 0xc8(%rsp), %rsi
xorl %r15d, %r15d
testb $0x2, %cl
je 0x5ea4
cmpq 0xa0(%rsp), %rax
jge 0x5ea4
testb $0x8, 0x4(%r10,%rax,4)
movl 0x34(%rsp), %edi
jne 0x5ed3
movq %rsi, %r8
movl 0xb4(%rsp), %edi
movq 0xb8(%rsp), %r9
testq %r9, %r9
jle 0x5ecc
decq %r9
decl %edi
cmpl $0x0, (%r8)
leaq -0x24(%r8), %r8
je 0x5eb6
jmp 0x5ed3
movl 0xb0(%rsp), %edi
addl %edi, %r15d
incq %rax
addq 0x80(%rsp), %rsi
cmpl %eax, %edx
jne 0x5e89
movq 0x28(%rsp), %r8
leal 0x1(%r8), %eax
movl 0x1c(%rsp), %edx
xorl %edx, %eax
orl %r15d, %eax
cmovel %r8d, %edx
movl %edx, 0x1c(%rsp)
movl $0x1, %eax
testb $0x2, %cl
je 0x5f21
testl %r15d, %r15d
movq 0x48(%rsp), %r10
je 0x5f26
movq 0x78(%rsp), %rax
addl %r15d, %eax
cltd
idivl %r11d
jmp 0x5f26
movq 0x48(%rsp), %r10
movl %r8d, %ebp
subl %eax, %ebp
leal 0x1(%rbp), %edx
cmpl $-0x2, %ebp
movq 0x40(%rsp), %rdi
jg 0x6002
movl 0xc(%rsp), %eax
subl 0x1c(%rsp), %eax
js 0x6002
cmpl $-0x1, %r14d
sete %cl
orb 0x13(%rsp), %cl
jne 0x5f66
movl %r14d, %ecx
subl %edx, %ecx
cmpl 0xc(%rsp), %ecx
jge 0x6002
notl %ebp
cmpl %ebp, %eax
cmovll %eax, %ebp
movl 0xc(%rsp), %ecx
subl %ebp, %ecx
movl %ecx, 0xac(%rsp)
movl %ebp, %eax
imull %r11d, %eax
cltq
leaq (%rax,%rax,8), %rax
movq 0x38(%rsp), %rsi
leaq (%rsi,%rax,4), %rdi
movl %ecx, %eax
imull %r11d, %eax
cltq
shlq $0x2, %rax
movq %rdx, 0x98(%rsp)
leaq (%rax,%rax,8), %rdx
callq 0x21b0
movq 0x60(%rsp), %rsi
leaq (%rsi,%rbp,4), %rdi
movslq 0xac(%rsp), %rdx
shlq $0x2, %rdx
callq 0x21b0
movq 0x98(%rsp), %rdx
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %r10
movq 0x28(%rsp), %r8
movl 0x8(%rsp), %r11d
addl %ebp, %r8d
addl %ebp, %edx
testl %r14d, %r14d
leal (%rbp,%r14), %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmovsl %ecx, %eax
addl 0x1c(%rsp), %ebp
movl %ebp, 0x1c(%rsp)
movl %eax, %r14d
testl %edx, %edx
js 0x6191
cmpl %r8d, %edx
movq %rdx, 0x98(%rsp)
jg 0x617c
movl %edx, %esi
incl %r8d
movq 0x58(%rsp), %rcx
imulq %rsi, %rcx
addq 0x38(%rsp), %rcx
xorl %edx, %edx
movq %rsi, 0x20(%rsp)
movq %r8, 0x28(%rsp)
cmpl %r11d, %r15d
movl %r11d, %r8d
cmovll %r15d, %r8d
testl %r8d, %r8d
je 0x60bc
movq %r10, %r13
xorl %r9d, %r9d
movq %rcx, %r10
movl %edi, %r11d
movl 0x34(%rsp), %ebp
imull %ebp, %r11d
addl %edx, %r11d
movslq %r11d, %r11
leaq (%r11,%r11,8), %r11
movl 0x20(%r12,%r11,4), %eax
movl %eax, 0x20(%r10)
movups (%r12,%r11,4), %xmm0
movups 0x10(%r12,%r11,4), %xmm1
movups %xmm1, 0x10(%r10)
movups %xmm0, (%r10)
movl 0x50(%rsp), %eax
xorl %edi, %eax
movl 0x14(%rsp), %r11d
xorl %edx, %r11d
orl %eax, %r11d
cmovel %esi, %r14d
cmovel %r9d, %ebx
incl %edx
cmpl %ebp, %edx
jne 0x60ae
incl %edi
testb $0x2, 0x58(%r13)
je 0x60c1
xorl %edx, %edx
incl %r9d
addq $0x24, %r10
cmpl %r9d, %r8d
jne 0x6052
jmp 0x60c4
xorl %r9d, %r9d
jmp 0x60c4
incl %r9d
movl %ebx, %eax
cmpl %edi, 0x50(%rsp)
setne %r10b
movl 0x14(%rsp), %r11d
subl %edx, %r11d
setl %bpl
orb %r10b, %bpl
leal (%r11,%r9), %ebx
movl 0x8(%rsp), %r11d
cmpl %r11d, %ebx
cmovgel 0x78(%rsp), %ebx
testb %bpl, %bpl
cmovel %esi, %r14d
cmovnel %eax, %ebx
cmpl %r11d, %r9d
movq 0xd0(%rsp), %r13
jge 0x613f
movslq %r9d, %rax
leaq (,%rax,4), %r9
leaq (%r9,%r9,8), %r9
movq 0x70(%rsp), %r10
subq %rax, %r10
movl $0x0, (%rcx,%r9)
movq (%r13), %rax
movq %rax, 0x18(%rcx,%r9)
movl 0x8(%r13), %eax
movl %eax, 0x20(%rcx,%r9)
addq $0x24, %r9
decq %r10
jne 0x611c
subl %r8d, %r15d
cmpq 0x20(%rsp), %rsi
seta %al
movq 0x60(%rsp), %r9
movb (%r9,%rsi,4), %r8b
shlb $0x3, %al
andb $-0x9, %r8b
orb %al, %r8b
movb %r8b, (%r9,%rsi,4)
incq %rsi
addq 0x58(%rsp), %rcx
movq 0x28(%rsp), %r8
cmpl %esi, %r8d
movq 0x48(%rsp), %r10
jne 0x603a
movq 0x40(%rsp), %rdi
decl %edi
movq 0x98(%rsp), %rdx
leal -0x1(%rdx), %r8d
jmp 0x61b4
movl 0x50(%rsp), %ecx
cmpl %ecx, %edi
setle %al
cmpl 0x20(%rsp), %ecx
setl %cl
testb %al, %cl
movl $0x0, %eax
cmovnel %eax, %r14d
cmovnel 0xa8(%rsp), %ebx
movl %edi, %eax
movq %rax, 0x20(%rsp)
testl %edx, %edx
jns 0x5df6
jmp 0x61ca
movq 0x20(%rsp), %rdi
movl 0x14(%rsp), %eax
cmpl %r11d, %eax
cmovgel 0x78(%rsp), %eax
xorl %ecx, %ecx
cmpl %edi, 0x50(%rsp)
cmovgl %r14d, %ecx
cmovgl %ebx, %eax
movl %eax, 0x14(%rsp)
cmpb $0x0, 0x18(%rsp)
je 0x6202
cmpl $-0x1, %ecx
je 0x668f
cmpl $-0x1, 0x14(%rsp)
je 0x668f
movl %ecx, 0x80(%rsp)
movl 0x6c(%rsp), %eax
testl %eax, %eax
movq %r10, %rbp
jne 0x62a8
testl %edi, %edi
js 0x62a8
movq %rdi, 0x40(%rsp)
movq %r8, 0x28(%rsp)
movq 0x10(%r10), %rax
testq %rax, %rax
movq 0x90(%rsp), %r14
je 0x6242
cmpq $0x0, 0x30(%rax)
jne 0x6255
testq %rax, %rax
je 0x6282
cmpb $0x0, 0x20(%r10)
je 0x6282
cmpq $0x0, 0x48(%rax)
je 0x6282
movq 0x40(%rsp), %rax
leal 0x1(%rax), %ebx
xorl %r15d, %r15d
movb (%r14,%r15,4), %al
andb $0x8, %al
shrb $0x3, %al
movzbl %al, %edx
movq %r10, %rdi
movl %r15d, %esi
callq 0x6694
movq %rbp, %r10
incq %r15
cmpq %r15, %rbx
jne 0x6260
cmpb $0x0, 0x18(%rsp)
movl 0x8(%rsp), %r11d
movq 0x28(%rsp), %r8
movl 0x6c(%rsp), %eax
movq 0x40(%rsp), %rcx
je 0x62a8
notl %ecx
movq 0x88(%rsp), %rdx
addl %ecx, (%rdx)
testl %eax, %eax
movq 0x38(%rsp), %r14
jne 0x6548
testl %r8d, %r8d
js 0x6548
movq 0x10(%r10), %rax
testq %rax, %rax
je 0x6548
cmpq $0x0, 0x38(%rax)
je 0x6548
movl 0x34(%rsp), %eax
cmpl %r11d, %eax
movl %r11d, %ebx
cmovll %eax, %ebx
movl %r8d, %r8d
movq 0x70(%rsp), %rax
imulq %r8, %rax
leaq (%rax,%rax,8), %rax
leaq (%r14,%rax,4), %r14
movq 0x58(%rsp), %rax
negq %rax
movq %rax, 0x50(%rsp)
movq %r8, 0x28(%rsp)
movq 0x78(%r10), %rsi
movq 0x10(%r10), %rax
movq 0x18(%r10), %rdx
movl 0x34(%rsp), %edi
callq *0x38(%rax)
testl %eax, %eax
je 0x6536
testl %ebx, %ebx
movq 0x28(%rsp), %rax
jle 0x64b8
imulq 0x70(%rsp), %rax
leaq (%rax,%rax,8), %rax
movq 0x38(%rsp), %rcx
leaq (%rcx,%rax,4), %rcx
xorl %eax, %eax
movl 0x8(%rsp), %r11d
movq %rbp, %r10
movslq %eax, %rsi
leaq (%rsi,%rsi,4), %rdx
leaq (,%rdx,8), %rdi
addq 0x78(%r10), %rdi
shlq $0x2, %rsi
leaq (%rsi,%rsi,8), %r8
leaq (%rcx,%r8), %rsi
addq %r14, %r8
xorl %r9d, %r9d
movl (%rdi,%r9,4), %r10d
movl %r10d, (%r8,%r9,4)
cmpl $0x0, (%rdi,%r9,4)
je 0x638f
leaq 0x1(%r9), %r10
cmpq $0x5, %r9
movq %r10, %r9
jb 0x6373
movl 0x1c(%rdi), %r9d
andl $0x1, %r9d
movl 0x20(%rsi), %r8d
andl $-0x2, %r8d
orl %r9d, %r8d
movl %r8d, 0x20(%rsi)
movl 0x1c(%rdi), %r9d
andl $0x6, %r9d
andl $-0x7, %r8d
orl %r9d, %r8d
movl %r8d, 0x20(%rsi)
movl 0x1c(%rdi), %r9d
andl $0x8, %r9d
andl $-0x9, %r8d
orl %r9d, %r8d
movl %r8d, 0x20(%rsi)
movl 0x1c(%rdi), %r9d
andl $0x10, %r9d
andl $-0x11, %r8d
orl %r9d, %r8d
movl %r8d, 0x20(%rsi)
movq %rbp, %r10
movl 0x58(%rbp), %r9d
shll $0x5, %r9d
xorl 0x1c(%rdi), %r9d
andl $0x20, %r9d
andl $-0x21, %r8d
orl %r9d, %r8d
movl %r8d, 0x20(%rsi)
movl 0x1c(%rdi), %r9d
andl $0x40, %r9d
andl $-0x41, %r8d
orl %r9d, %r8d
movl %r8d, 0x20(%rsi)
movl 0x1c(%rdi), %r9d
movl $0x80, %r15d
andl %r15d, %r9d
andl $0xffffff7f, %r8d       # imm = 0xFFFFFF7F
orl %r9d, %r8d
movl %r8d, 0x20(%rsi)
movl 0x1c(%rdi), %r9d
movl $0xf00, %r15d           # imm = 0xF00
andl %r15d, %r9d
andl $0xfffff0ff, %r8d       # imm = 0xFFFFF0FF
orl %r9d, %r8d
movl %r8d, 0x20(%rsi)
movl 0x1c(%rdi), %r9d
shrl $0x3, %r9d
andl $0x1000, %r9d           # imm = 0x1000
andl $0xffffefff, %r8d       # imm = 0xFFFFEFFF
orl %r9d, %r8d
movl %r8d, 0x20(%rsi)
movl 0x1c(%rdi), %r9d
shrl $0x3, %r9d
andl $0x6000, %r9d           # imm = 0x6000
andl $0xffff9fff, %r8d       # imm = 0xFFFF9FFF
orl %r9d, %r8d
movl %r8d, 0x20(%rsi)
movl 0x20(%rdi), %r8d
movl %r8d, 0x18(%rsi)
movl 0x24(%rdi), %r8d
movl %r8d, 0x1c(%rsi)
cmpb $0x2, 0x18(%rdi)
jne 0x64a3
cmpl 0x78(%rsp), %eax
jge 0x64a3
movl $0xffffffff, 0x24(%rsi) # imm = 0xFFFFFFFF
movq 0x78(%r10), %rsi
movsbl 0x18(%rsi,%rdx,8), %edx
addl %edx, %eax
cmpl %ebx, %eax
jl 0x634e
jmp 0x64c2
xorl %eax, %eax
movl 0x8(%rsp), %r11d
movq %rbp, %r10
cmpl %r11d, %eax
jge 0x6501
movslq %eax, %rdx
leaq (,%rdx,4), %rax
leaq (%rax,%rax,8), %rax
movq 0x70(%rsp), %rcx
subq %rdx, %rcx
movl $0x0, (%r14,%rax)
movq (%r13), %rdx
movq %rdx, 0x18(%r14,%rax)
movl 0x8(%r13), %edx
movl %edx, 0x20(%r14,%rax)
addq $0x24, %rax
decq %rcx
jne 0x64de
cmpb $0x0, 0x18(%rsp)
movq 0x28(%rsp), %rcx
je 0x6517
movq 0x88(%rsp), %rax
incl (%rax)
leaq -0x1(%rcx), %r8
addq 0x50(%rsp), %r14
testq %rcx, %rcx
jg 0x6304
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq 0x38(%rsp), %r14
jmp 0x6548
movl 0x8(%rsp), %r11d
movq 0x38(%rsp), %r14
movq 0x28(%rsp), %r8
movq %rbp, %r10
testl %r8d, %r8d
js 0x6622
movl %r8d, %ebx
notl %ebx
addl 0xc(%rsp), %ebx
leal 0x1(%r8), %ebp
movl %ebp, %eax
imull %r11d, %eax
cltq
leaq (%rax,%rax,8), %rax
leaq (%r14,%rax,4), %rsi
movl %ebx, %eax
imull %r11d, %eax
cltq
shlq $0x2, %rax
leaq (%rax,%rax,8), %rdx
movq %r14, %rdi
movq %r8, %r15
callq 0x21b0
movl %r15d, %eax
movq 0x60(%rsp), %rdi
leaq (%rdi,%rax,4), %rsi
addq $0x4, %rsi
movslq %ebx, %rbx
leaq (,%rbx,4), %rdx
callq 0x21b0
movl 0x80(%rsp), %eax
subl %ebp, %eax
movl %eax, %ebp
cmpl 0xc(%rsp), %ebx
jge 0x662b
movl 0x8(%rsp), %edi
movl %edi, %ecx
movq 0x58(%rsp), %rax
imulq %rbx, %rax
addq %r14, %rax
addq $0x18, %rax
shlq $0x2, %rcx
leaq (%rcx,%rcx,8), %rcx
movq 0x48(%rsp), %r10
testl %edi, %edi
jle 0x6604
xorl %edx, %edx
movl $0x0, -0x18(%rax,%rdx)
movq (%r13), %rsi
movq %rsi, (%rax,%rdx)
movl 0x8(%r13), %esi
movl %esi, 0x8(%rax,%rdx)
addq $0x24, %rdx
cmpq %rdx, %rcx
jne 0x65e3
movq 0x60(%rsp), %rdx
movb $0x0, (%rdx,%rbx,4)
incq %rbx
addq 0x58(%rsp), %rax
cmpl 0xc(%rsp), %ebx
jne 0x65dd
movq 0x38(%rsp), %r14
jmp 0x6630
movl 0x80(%rsp), %ebp
jmp 0x6630
movq 0x48(%rsp), %r10
movq (%r10), %rdi
movq %r12, %rsi
movq %r10, %r15
callq 0xa40a
movq 0xc0(%rsp), %rbx
movq %r14, 0x60(%r15,%rbx,8)
movq (%r15), %rdi
movq 0x90(%rsp), %rsi
callq 0xa40a
movq 0x60(%rsp), %rax
movq 0x88(%rsp), %rcx
movq %rax, 0x8(%rcx,%rbx,8)
cmpb $0x0, 0x18(%rsp)
je 0x667d
movl %ebp, (%rcx)
movl 0x14(%rsp), %eax
movl %eax, 0x4(%rcx)
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2230