// File: /workspace/github_c_makefile_star2_O0/justy989[P]ce/ce_vim.c
// Function: paste_text
static bool paste_text(CeVim_t* vim, const CeVimAction_t* action, CeRange_t motion_range, CeView_t* view,
                       CePoint_t* cursor, const CeConfigOptions_t* config_options, bool after){
     CeVimYank_t* yank = vim->yanks + ce_vim_register_index(action->verb.integer);
     if(!yank->text) return false;

     CePoint_t insertion_point = motion_range.end;

     switch(yank->type){
     default:
          ce_log("unsupported yank type %d\n", yank->type);
          return false;
     case CE_VIM_YANK_TYPE_LINE:
          insertion_point.x = 0;
          if(after) insertion_point.y++;
          break;
     case CE_VIM_YANK_TYPE_STRING:
          if(after){
               insertion_point.x++;
               int64_t line_len = ce_utf8_strlen(view->buffer->lines[insertion_point.y]);
               if(insertion_point.x > line_len) insertion_point.x = line_len - 1;
               if(insertion_point.x < 0) insertion_point.x = 0;
          }
          break;
     case CE_VIM_YANK_TYPE_BLOCK:
     {
          bool chain = false;

          // if the buffer isn't long enough, insert some lines
          int64_t line_count_check = insertion_point.y + yank->block_line_count;
          if(line_count_check > view->buffer->line_count){
               int64_t line_diff = line_count_check - view->buffer->line_count;
               char* newline_str = malloc(line_diff + 1);
               memset(newline_str, '\n', line_diff);
               newline_str[line_diff] = 0;

               CePoint_t newline_point = ce_buffer_end_point(view->buffer);
               if(!ce_buffer_insert_string(view->buffer, newline_str, newline_point)) return false;

               // commit the change
               CeBufferChange_t change = {};
               change.chain = chain;
               change.insertion = true;
               change.string = newline_str;
               change.location = newline_point;
               change.cursor_before = *cursor;
               change.cursor_after = *cursor;
               ce_buffer_change(view->buffer, &change);
               chain = true;
          }

          for(int64_t i = 0; i < yank->block_line_count; i++){
               if(!yank->block[i]) continue;
               CePoint_t point = {insertion_point.x, insertion_point.y + i};

               // if the line isn't long enough, append space so it is long enough
               int64_t line_len = ce_utf8_strlen(view->buffer->lines[point.y]);
               if(insertion_point.x > line_len){
                    int64_t space_len = (insertion_point.x - line_len);
                    char* space_str = malloc(space_len + 1);
                    memset(space_str, ' ', space_len);
                    space_str[space_len] = 0;

                    CePoint_t space_point = {line_len, point.y};
                    if(!ce_buffer_insert_string(view->buffer, space_str, space_point)) return false;

                    // commit the change
                    CeBufferChange_t change = {};
                    change.chain = chain;
                    change.insertion = true;
                    change.string = space_str;
                    change.location = space_point;
                    change.cursor_before = *cursor;
                    change.cursor_after = *cursor;
                    ce_buffer_change(view->buffer, &change);
                    chain = true;
               }

               char* insert_str = strdup(yank->block[i]);
               if(!ce_buffer_insert_string(view->buffer, insert_str, point)) return false;

               // commit the change
               CeBufferChange_t change = {};
               change.chain = chain;
               change.insertion = true;
               change.string = insert_str;
               change.location = point;
               change.cursor_before = *cursor;
               change.cursor_after = *cursor;
               ce_buffer_change(view->buffer, &change);
               chain = true;
          }

          vim->mode = CE_VIM_MODE_NORMAL;
          return true;
     }
     }

     char* insert_str = strdup(yank->text);

     // if we are inserting at the end of a file, put the newline at the beginning and insert at the end of the previous line
     if(insertion_point.x == 0 && insertion_point.y == view->buffer->line_count){
          int64_t insert_len = strlen(insert_str);
          if(insert_len > 0){
               int64_t last_index = insert_len - 1;
               if(insert_str[last_index] == CE_NEWLINE){
                    for(int64_t i = last_index; i > 0; i--){
                         insert_str[i] = insert_str[i - 1];
                    }
                    insert_str[0] = CE_NEWLINE;
                    insertion_point.y = view->buffer->line_count - 1;
                    insertion_point.x = ce_utf8_strlen(view->buffer->lines[insertion_point.y]);
               }
          }
     }

     if(!ce_buffer_insert_string(view->buffer, insert_str, insertion_point)) return false;

     CePoint_t cursor_end = {};

     switch(yank->type){
     default:
          break;
     case CE_VIM_YANK_TYPE_LINE:
          cursor_end = insertion_point;
          break;
     case CE_VIM_YANK_TYPE_STRING:
          cursor_end = ce_buffer_advance_point(view->buffer, *cursor, ce_utf8_strlen(yank->text));
          break;
     }

     // commit the change
     CeBufferChange_t change = {};
     change.chain = action->chain_undo;
     change.insertion = true;
     change.string = insert_str;
     change.location = insertion_point;
     change.cursor_before = *cursor;
     change.cursor_after = cursor_end;
     ce_buffer_change(view->buffer, &change);

     *cursor = cursor_end;
     vim->mode = CE_VIM_MODE_NORMAL;

     return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movb %r9b, %al
leaq 0x10(%rbp), %r9
movq %r9, -0x220(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
andb $0x1, %al
movb %al, -0x31(%rbp)
movq -0x10(%rbp), %rax
addq $0x1050, %rax           # imm = 0x1050
movq %rax, -0x218(%rbp)
movq -0x18(%rbp), %rax
movl 0x30(%rax), %edi
callq 0x33a80
movq %rax, %rcx
movq -0x218(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x3b848
movb $0x0, -0x1(%rbp)
jmp 0x3bfe0
movq -0x220(%rbp), %rax
movups 0x10(%rax), %xmm0
movaps %xmm0, -0x50(%rbp)
movq -0x40(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x224(%rbp)
subl $0x1, %eax
je 0x3b8c4
jmp 0x3b86a
movl -0x224(%rbp), %eax
subl $0x2, %eax
je 0x3b8a5
jmp 0x3b877
movl -0x224(%rbp), %eax
subl $0x3, %eax
je 0x3b91e
jmp 0x3b888
movq -0x40(%rbp), %rax
movl (%rax), %esi
leaq 0x9e1e(%rip), %rdi      # 0x456b3
movb $0x0, %al
callq 0xd8f0
movb $0x0, -0x1(%rbp)
jmp 0x3bfe0
movq $0x0, -0x50(%rbp)
testb $0x1, -0x31(%rbp)
je 0x3b8bf
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x3bd32
testb $0x1, -0x31(%rbp)
je 0x3b919
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movq (%rax), %rax
movq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xea70
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x58(%rbp), %rax
jle 0x3b908
movq -0x58(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jge 0x3b917
movq $0x0, -0x50(%rbp)
jmp 0x3b919
jmp 0x3bd32
movb $0x0, -0x59(%rbp)
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
addq 0x10(%rcx), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq -0x20(%rbp), %rcx
movq 0x40(%rcx), %rcx
cmpq 0x8(%rcx), %rax
jle 0x3ba5f
movq -0x68(%rbp), %rax
movq -0x20(%rbp), %rcx
movq 0x40(%rcx), %rcx
subq 0x8(%rcx), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
addq $0x1, %rdi
callq 0xd4a0
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
movq -0x70(%rbp), %rdx
movl $0xa, %esi
callq 0xd290
movq -0x78(%rbp), %rax
movq -0x70(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0xda10
movq %rax, -0x88(%rbp)
movq %rdx, -0x80(%rbp)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x78(%rbp), %rsi
movq -0x88(%rbp), %rdx
movq -0x80(%rbp), %rcx
callq 0xda70
testb $0x1, %al
jne 0x3b9cc
movb $0x0, -0x1(%rbp)
jmp 0x3bfe0
leaq -0xc8(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0xd290
movb -0x59(%rbp), %al
andb $0x1, %al
movb %al, -0xc8(%rbp)
movb $0x1, -0xc7(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0xa8(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x98(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x10e90
movb $0x1, -0x59(%rbp)
movq $0x0, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
movq -0x40(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jge 0x3bd1f
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq -0xd0(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x3ba9a
jmp 0x3bd08
movq -0x50(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x48(%rbp), %rax
addq -0xd0(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movq (%rax), %rax
movq -0xd8(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xea70
movq %rax, -0xe8(%rbp)
movq -0x50(%rbp), %rax
cmpq -0xe8(%rbp), %rax
jle 0x3bc21
movq -0x50(%rbp), %rax
subq -0xe8(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rdi
addq $0x1, %rdi
callq 0xd4a0
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rdi
movq -0xf0(%rbp), %rdx
movl $0x20, %esi
callq 0xd290
movq -0xf8(%rbp), %rax
movq -0xf0(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0xe8(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0xd8(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0xf8(%rbp), %rsi
movq -0x108(%rbp), %rdx
movq -0x100(%rbp), %rcx
callq 0xda70
testb $0x1, %al
jne 0x3bb88
movb $0x0, -0x1(%rbp)
jmp 0x3bfe0
leaq -0x148(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0xd290
movb -0x59(%rbp), %al
andb $0x1, %al
movb %al, -0x148(%rbp)
movb $0x1, -0x147(%rbp)
movq -0xf8(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x100(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x128(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x120(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x118(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x110(%rbp)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rdi
leaq -0x148(%rbp), %rsi
callq 0x10e90
movb $0x1, -0x59(%rbp)
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq -0xd0(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xd620
movq %rax, -0x150(%rbp)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x150(%rbp), %rsi
movq -0xe0(%rbp), %rdx
movq -0xd8(%rbp), %rcx
callq 0xda70
testb $0x1, %al
jne 0x3bc6f
movb $0x0, -0x1(%rbp)
jmp 0x3bfe0
leaq -0x190(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0xd290
movb -0x59(%rbp), %al
andb $0x1, %al
movb %al, -0x190(%rbp)
movb $0x1, -0x18f(%rbp)
movq -0x150(%rbp), %rax
movq %rax, -0x188(%rbp)
movq -0xe0(%rbp), %rax
movq %rax, -0x180(%rbp)
movq -0xd8(%rbp), %rax
movq %rax, -0x178(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x170(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x168(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x160(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x158(%rbp)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rdi
leaq -0x190(%rbp), %rsi
callq 0x10e90
movb $0x1, -0x59(%rbp)
movq -0xd0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd0(%rbp)
jmp 0x3ba6a
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movb $0x1, -0x1(%rbp)
jmp 0x3bfe0
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xd620
movq %rax, -0x198(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x3be45
movq -0x48(%rbp), %rax
movq -0x20(%rbp), %rcx
movq 0x40(%rcx), %rcx
cmpq 0x8(%rcx), %rax
jne 0x3be45
movq -0x198(%rbp), %rdi
callq 0xd200
movq %rax, -0x1a0(%rbp)
cmpq $0x0, -0x1a0(%rbp)
jle 0x3be43
movq -0x1a0(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x1a8(%rbp)
movq -0x198(%rbp), %rax
movq -0x1a8(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x3be41
movq -0x1a8(%rbp), %rax
movq %rax, -0x1b0(%rbp)
cmpq $0x0, -0x1b0(%rbp)
jle 0x3be07
movq -0x198(%rbp), %rax
movq -0x1b0(%rbp), %rcx
subq $0x1, %rcx
movb (%rax,%rcx), %dl
movq -0x198(%rbp), %rax
movq -0x1b0(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x1b0(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x1b0(%rbp)
jmp 0x3bdc3
movq -0x198(%rbp), %rax
movb $0xa, (%rax)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rax
subq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movq (%rax), %rax
movq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xea70
movq %rax, -0x50(%rbp)
jmp 0x3be43
jmp 0x3be45
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x198(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x48(%rbp), %rcx
callq 0xda70
testb $0x1, %al
jne 0x3be6e
movb $0x0, -0x1(%rbp)
jmp 0x3bfe0
xorps %xmm0, %xmm0
movaps %xmm0, -0x1c0(%rbp)
movq -0x40(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x228(%rbp)
subl $0x1, %eax
je 0x3beb5
jmp 0x3be8b
movl -0x228(%rbp), %eax
subl $0x2, %eax
je 0x3be9d
jmp 0x3be98
jmp 0x3bf23
movq -0x50(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x1b8(%rbp)
jmp 0x3bf23
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x238(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x230(%rbp)
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xea70
movq -0x238(%rbp), %rdi
movq %rax, %rcx
movq -0x230(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
callq 0xfaf0
movq %rax, -0x1d0(%rbp)
movq %rdx, -0x1c8(%rbp)
movq -0x1d0(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movq -0x1c8(%rbp), %rax
movq %rax, -0x1b8(%rbp)
leaq -0x210(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0xd290
movq -0x18(%rbp), %rax
movb 0x3c(%rax), %al
andb $0x1, %al
movb %al, -0x210(%rbp)
movb $0x1, -0x20f(%rbp)
movq -0x198(%rbp), %rax
movq %rax, -0x208(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x200(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x1f8(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x1f0(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x1e8(%rbp)
movq -0x1c0(%rbp), %rax
movq %rax, -0x1e0(%rbp)
movq -0x1b8(%rbp), %rax
movq %rax, -0x1d8(%rbp)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rdi
leaq -0x210(%rbp), %rsi
callq 0x10e90
movq -0x28(%rbp), %rax
movq -0x1c0(%rbp), %rcx
movq %rcx, (%rax)
movq -0x1b8(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
nop