// File: /workspace/github_c_makefile_star2_O2/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 $0x58, %rsp
movq %rcx, 0x10(%rsp)
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r15
leaq 0x90(%rsp), %r13
movq %r13, %rdi
callq 0x1021f
movl 0x38(%r14), %ebp
cmpb $0x1, 0x3e(%r14)
jne 0x2317e
movq 0x40(%r12), %rdi
movq 0x10(%r13), %rsi
movq 0x18(%r13), %rdx
pushq $-0x1
popq %rcx
callq 0xec3a
movq %rax, %rbx
movq %rax, 0x10(%r13)
movq %rdx, 0x18(%r13)
movq 0x40(%r12), %rax
movq (%rax), %rax
movq (%rax,%rdx,8), %rdi
callq 0xe38c
cmpq %rax, %rbx
pushq $0x2
popq %rax
cmovel %eax, %ebp
movq 0x40(%r12), %rdi
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq 0x10(%r13), %rcx
movq 0x18(%r13), %r8
callq 0xe98a
movq %rax, %rbx
movb $0x1, %al
testq %rbx, %rbx
jle 0x23316
movl %ebp, 0x4(%rsp)
movq %r15, 0x8(%rsp)
movq 0x40(%r12), %rdi
callq 0xd9cc
movq %rax, %r15
movq %rdx, %rbp
incq %r15
movq 0x10(%r13), %rdi
movq 0x18(%r13), %rsi
movq %r15, %rdx
movq %rbp, %rcx
callq 0xea69
testb %al, %al
je 0x231fb
cmpq $0x0, 0x10(%r13)
je 0x231fb
movq 0x40(%r12), %rdi
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %r15, %rcx
movq %rbp, %r8
callq 0xe98a
movq %rax, %rbx
movq 0x40(%r12), %rdi
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %rbx, %rcx
callq 0xf361
movq %rax, %r15
movq 0x40(%r12), %rdi
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %rbx, %rcx
callq 0xef3b
testb %al, %al
je 0x2330c
movq 0x40(%r12), %rdi
callq 0xd9cc
movq %rdx, %rcx
movq 0x10(%r13), %rdi
movq 0x18(%r13), %rsi
movq %rax, %rdx
callq 0xea69
testb %al, %al
je 0x2326a
movq %r15, %rdi
callq 0xe784
testq %rax, %rax
js 0x2326a
cmpb $0xa, (%r15,%rax)
jne 0x2326a
movb $0x0, (%r15,%rax)
movq 0x40(%r12), %rdi
movl 0x40(%r14), %ecx
movq (%r13), %rsi
movq 0x8(%r13), %rdx
callq 0xecee
leaq 0x18(%rsp), %rsi
andq $0x0, (%rsi)
movq %rax, %rbx
movq %rdx, %rbp
movb 0x3c(%r14), %al
movb %al, (%rsi)
movq %r15, 0x8(%rsi)
movups (%r13), %xmm0
movups %xmm0, 0x10(%rsi)
movq 0x10(%rsp), %r13
movups (%r13), %xmm0
movups %xmm0, 0x20(%rsi)
movq %rbx, 0x30(%rsi)
movq %rdx, 0x38(%rsi)
movq 0x40(%r12), %rdi
callq 0xf64d
movq %rbx, (%r13)
movq %rbp, 0x8(%r13)
movb 0x3c(%r14), %al
movq 0x8(%rsp), %rbx
movb %al, 0x19d8(%rbx)
andl $0x0, (%rbx)
cmpb $0x0, 0x3f(%r14)
jne 0x23308
leaq 0x1080(%rbx), %rdi
callq 0x2196f
movq %r15, %rdi
callq 0xd640
movq %rax, 0x1088(%rbx)
movl 0x4(%rsp), %eax
movl %eax, 0x1080(%rbx)
movb $0x1, %al
jmp 0x23316
movq %r15, %rdi
callq 0xd090
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq