// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, %rax
movq 0x30(%rbp), %rdi
leaq 0x10(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
movq %rax, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
callq 0x12840
movq -0x18(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x18(%rbp), %rax
testb $0x1, 0x3e(%rax)
je 0x34e6b
movq -0xe8(%rbp), %rax
movq -0x20(%rbp), %rcx
movq 0x40(%rcx), %rdi
movq 0x10(%rax), %rsi
movq 0x18(%rax), %rdx
movq $-0x1, %rcx
callq 0xfaf0
movq -0xe8(%rbp), %rcx
movq %rax, -0x50(%rbp)
movq %rdx, -0x48(%rbp)
movq -0x50(%rbp), %rax
movq %rax, 0x10(%rcx)
movq -0x48(%rbp), %rax
movq %rax, 0x18(%rcx)
movq 0x10(%rcx), %rax
movq %rax, -0xf0(%rbp)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movq (%rax), %rax
movq 0x18(%rcx), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xea70
movq %rax, %rcx
movq -0xf0(%rbp), %rax
cmpq %rcx, %rax
jne 0x34e69
movl $0x2, -0x3c(%rbp)
jmp 0x34e6b
movq -0xe8(%rbp), %rax
movq -0x20(%rbp), %rcx
movq 0x40(%rcx), %rdi
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
movq 0x18(%rax), %r8
callq 0xf510
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jg 0x34ea2
movb $0x1, -0x1(%rbp)
jmp 0x35162
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0xda10
movq %rax, %rcx
movq -0xe8(%rbp), %rax
movq %rcx, -0x68(%rbp)
movq %rdx, -0x60(%rbp)
movq -0x68(%rbp), %rcx
addq $0x1, %rcx
movq %rcx, -0x68(%rbp)
movq 0x10(%rax), %rdi
movq 0x18(%rax), %rsi
movq -0x68(%rbp), %rdx
movq -0x60(%rbp), %rcx
callq 0xf690
testb $0x1, %al
jne 0x34ee8
jmp 0x34f1d
movq -0xe8(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x34f1d
movq -0xe8(%rbp), %rax
movq -0x20(%rbp), %rcx
movq 0x40(%rcx), %rdi
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq -0x68(%rbp), %rcx
movq -0x60(%rbp), %r8
callq 0xf510
movq %rax, -0x58(%rbp)
movq -0xe8(%rbp), %rax
movq -0x20(%rbp), %rcx
movq 0x40(%rcx), %rdi
movq -0x58(%rbp), %rcx
movq (%rax), %rsi
movq 0x8(%rax), %rdx
callq 0x10900
movq %rax, %rcx
movq -0xe8(%rbp), %rax
movq %rcx, -0x70(%rbp)
movq -0x20(%rbp), %rcx
movq 0x40(%rcx), %rdi
movq -0x58(%rbp), %rcx
movq (%rax), %rsi
movq 0x8(%rax), %rdx
callq 0x10190
testb $0x1, %al
jne 0x34f78
movq -0x70(%rbp), %rdi
callq 0xd090
movb $0x0, -0x1(%rbp)
jmp 0x35162
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0xda10
movq %rax, %rcx
movq -0xe8(%rbp), %rax
movq %rcx, -0x80(%rbp)
movq %rdx, -0x78(%rbp)
movq 0x10(%rax), %rdi
movq 0x18(%rax), %rsi
movq -0x80(%rbp), %rdx
movq -0x78(%rbp), %rcx
callq 0xf690
testb $0x1, %al
jne 0x34fb2
jmp 0x34ff1
movq -0x70(%rbp), %rdi
callq 0xf1f0
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x88(%rbp)
jl 0x34fef
movq -0x70(%rbp), %rax
movq -0x88(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x34fef
movq -0x70(%rbp), %rax
movq -0x88(%rbp), %rcx
movb $0x0, (%rax,%rcx)
jmp 0x34ff1
movq -0xe8(%rbp), %rax
movq -0x20(%rbp), %rcx
movq 0x40(%rcx), %rdi
movq -0x18(%rbp), %rcx
movl 0x40(%rcx), %ecx
movq (%rax), %rsi
movq 0x8(%rax), %rdx
callq 0xfc90
movq %rax, -0x98(%rbp)
movq %rdx, -0x90(%rbp)
leaq -0xd8(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0xd290
movq -0xe8(%rbp), %rax
movq -0x18(%rbp), %rcx
movb 0x3c(%rcx), %cl
andb $0x1, %cl
movb %cl, -0xd8(%rbp)
movb $0x0, -0xd7(%rbp)
movq -0x70(%rbp), %rcx
movq %rcx, -0xd0(%rbp)
movq (%rax), %rcx
movq %rcx, -0xc8(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0xb8(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x10e90
movq -0x28(%rbp), %rax
movq -0x98(%rbp), %rcx
movq %rcx, (%rax)
movq -0x90(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movb 0x3c(%rax), %cl
movq -0x10(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x19d8(%rax)
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x18(%rbp), %rax
testb $0x1, 0x3f(%rax)
jne 0x3515e
movq -0x10(%rbp), %rax
addq $0x1050, %rax           # imm = 0x1050
movq %rax, -0xf8(%rbp)
movl $0x22, %edi
callq 0x33a80
movq %rax, %rcx
movq -0xf8(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xe0(%rbp)
movq -0xe0(%rbp), %rdi
callq 0x321a0
movq -0x70(%rbp), %rdi
callq 0xd620
movq %rax, %rcx
movq -0xe0(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x3c(%rbp), %ecx
movq -0xe0(%rbp), %rax
movl %ecx, (%rax)
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq