// File: /workspace/github_c_makefile_star2_O1/justy989[P]ce/ce_vim.c
// Function: ce_vim_verb_delete
bool ce_vim_verb_delete(CeVim_t* vim, const CeVimAction_t* action, CeRange_t motion_range, CeView_t* view,
                        CePoint_t* cursor, CeVimVisualData_t* visual, CeVimBufferData_t* buffer_data,
                        const CeConfigOptions_t* config_options){
     ce_range_sort(&motion_range);

     // delete the range
     CeVimYankType_t yank_type = action->yank_type;
     if(action->exclude_end){
          motion_range.end = ce_buffer_advance_point(view->buffer, motion_range.end, -1);
          if(motion_range.end.x == ce_utf8_strlen(view->buffer->lines[motion_range.end.y])){
               yank_type = CE_VIM_YANK_TYPE_LINE;
          }
     }
     int64_t delete_len = ce_buffer_range_len(view->buffer, motion_range.start, motion_range.end);
     if(delete_len <= 0) return true;
     // if the end of the range is at the end of the buffer, take off the extra newline, unless the line is empty
     CePoint_t buffer_end = ce_buffer_end_point(view->buffer);
     buffer_end.x++; // include the final newline
     if(ce_point_after(motion_range.end, buffer_end) && motion_range.end.x != 0){
          delete_len = ce_buffer_range_len(view->buffer, motion_range.start, buffer_end);
     }
     char* removed_string = ce_buffer_dupe_string(view->buffer, motion_range.start, delete_len);
     if(!ce_buffer_remove_string(view->buffer, motion_range.start, delete_len)){
          free(removed_string);
          return false;
     }

     // do not include the CE_NEWLINE if it is the final newline in the buffer
     if(ce_point_after(motion_range.end, ce_buffer_end_point(view->buffer))){
          int64_t last_index = ce_utf8_last_index(removed_string);
          if(last_index >= 0 && removed_string[last_index] == CE_NEWLINE){
               removed_string[last_index] = 0;
          }
     }

     CePoint_t end_cursor = ce_buffer_clamp_point(view->buffer, motion_range.start, action->clamp_x);

     // commit the change
     CeBufferChange_t change = {};
     change.chain = action->chain_undo;
     change.insertion = false;
     change.string = removed_string;
     change.location = motion_range.start;
     change.cursor_before = *cursor;
     change.cursor_after = end_cursor;
     ce_buffer_change(view->buffer, &change);

     *cursor = end_cursor;
     vim->chain_undo = action->chain_undo;
     vim->mode = CE_VIM_MODE_NORMAL;

     if(!action->do_not_yank){
          CeVimYank_t* yank = vim->yanks + ce_vim_register_index('"');
          ce_vim_yank_free(yank);
          yank->text = strdup(removed_string);
          yank->type = yank_type;
     }
     return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, 0x18(%rsp)
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r15
leaq 0xa0(%rsp), %r13
movq %r13, %rdi
callq 0x1079c
movl 0x38(%r14), %ebp
cmpb $0x1, 0x3e(%r14)
jne 0x25ec9
movq 0x40(%r12), %rdi
movq 0x10(%r13), %rsi
movq 0x18(%r13), %rdx
movq $-0x1, %rcx
callq 0xeffa
movq %rax, %rbx
movq %rax, 0x10(%r13)
movq %rdx, 0x18(%r13)
movq 0x40(%r12), %rax
movq (%rax), %rax
movq (%rax,%rdx,8), %rdi
callq 0xe485
cmpq %rax, %rbx
movl $0x2, %eax
cmovel %eax, %ebp
movl %ebp, 0x4(%rsp)
movq 0x40(%r12), %rdi
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq 0x10(%r13), %rcx
movq 0x18(%r13), %r8
callq 0xecb5
testq %rax, %rax
jle 0x26072
movq %rax, %rbp
movq %r15, 0x10(%rsp)
movq 0x40(%r12), %rdi
callq 0xda40
movq %rax, %r15
movq %rdx, %rbx
incq %r15
movq 0x10(%r13), %rdi
movq 0x18(%r13), %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0xedfb
testb %al, %al
je 0x25f44
cmpq $0x0, 0x10(%r13)
je 0x25f44
movq 0x40(%r12), %rdi
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %r15, %rcx
movq %rbx, %r8
callq 0xecb5
movq %rax, %rbp
movq 0x40(%r12), %rdi
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %rbp, %rcx
callq 0xf79a
movq %rax, %rbx
movq 0x40(%r12), %rdi
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %rbp, %rcx
callq 0xf36b
movl %eax, %ebp
testb %al, %al
je 0x26077
movq 0x40(%r12), %rdi
callq 0xda40
movq %rdx, %rcx
movq 0x10(%r13), %rdi
movq 0x18(%r13), %rsi
movq %rax, %rdx
callq 0xedfb
testb %al, %al
je 0x25fb3
movq %rbx, %rdi
callq 0xe97d
testq %rax, %rax
js 0x25fb3
cmpb $0xa, (%rbx,%rax)
jne 0x25fb3
movb $0x0, (%rbx,%rax)
movq 0x40(%r12), %rdi
movl 0x40(%r14), %ecx
movq (%r13), %rsi
movq 0x8(%r13), %rdx
callq 0xf112
movq %rbx, %rcx
movq %rax, %rbx
movq %rdx, %r15
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rsi
movaps %xmm0, 0x30(%rsi)
movaps %xmm0, 0x20(%rsi)
movaps %xmm0, 0x10(%rsi)
movaps %xmm0, (%rsi)
movb 0x3c(%r14), %al
movb %al, (%rsi)
movb $0x0, 0x1(%rsi)
movq %rcx, 0x8(%rsp)
movq %rcx, 0x8(%rsi)
movups (%r13), %xmm0
movaps %xmm0, 0x10(%rsi)
movq 0x18(%rsp), %r13
movups (%r13), %xmm0
movaps %xmm0, 0x20(%rsi)
movq %rbx, 0x30(%rsi)
movq %rdx, 0x38(%rsi)
movq 0x40(%r12), %rdi
callq 0xfad6
movq %rbx, (%r13)
movq %r15, 0x8(%r13)
movb 0x3c(%r14), %al
movq 0x10(%rsp), %rbx
movb %al, 0x19d8(%rbx)
movl $0x0, (%rbx)
cmpb $0x0, 0x3f(%r14)
jne 0x2607f
leaq 0x1080(%rbx), %rdi
callq 0x243a6
movq 0x8(%rsp), %rdi
callq 0xd640
movq %rax, 0x1088(%rbx)
movl 0x4(%rsp), %eax
movl %eax, 0x1080(%rbx)
jmp 0x2607f
movb $0x1, %bpl
jmp 0x2607f
movq %rbx, %rdi
callq 0xd090
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq