// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce_vim.c
// Function: ce_vim_motion_visual
CeVimMotionResult_t ce_vim_motion_visual(CeVim_t* vim, CeVimAction_t* action, const CeView_t* view, const CePoint_t* cursor,
                                         CeVimVisualData_t* visual, const CeConfigOptions_t* config_options,
                                         CeVimBufferData_t* buffer_data, CeRange_t* motion_range){
     if(vim->mode == CE_VIM_MODE_VISUAL || vim->mode == CE_VIM_MODE_VISUAL_LINE){
          motion_range->start = *cursor;
          motion_range->end = visual->point;
          ce_range_sort(motion_range);
          action->motion.integer = ce_buffer_range_len(view->buffer, motion_range->start, motion_range->end) - 1;

          if(vim->mode == CE_VIM_MODE_VISUAL_LINE){
               motion_range->start.x = 0;
               motion_range->end.x = ce_utf8_strlen(view->buffer->lines[motion_range->end.y]);
               action->yank_type = CE_VIM_YANK_TYPE_LINE;
               action->motion.integer = motion_range->end.y - motion_range->start.y;
          }
     }else if(vim->verb_last_action){
          switch(action->yank_type){
          default:
               break;
          case CE_VIM_YANK_TYPE_LINE:
               motion_range->start = (CePoint_t){0, cursor->y};
               motion_range->end.y = cursor->y + action->motion.integer;
               if(motion_range->end.y >= view->buffer->line_count){
                    motion_range->end.y = (view->buffer->line_count - 1);
               }
               if(motion_range->end.y < 0){
                    motion_range->end.y = 0;
               }
               motion_range->end.x = ce_utf8_strlen(view->buffer->lines[motion_range->end.y]);
               break;
          case CE_VIM_YANK_TYPE_STRING:
               motion_range->start = *cursor;
               motion_range->end = ce_buffer_advance_point(view->buffer, *cursor, action->motion.integer);
               break;
          }
     }

     return CE_VIM_MOTION_RESULT_SUCCESS;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %r12
movq 0x38(%rsp), %rbx
movl (%rdi), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0x22e62
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movups (%r8), %xmm0
movups %xmm0, 0x10(%rbx)
movq %rbx, %rdi
callq 0x1021f
movq 0x40(%r15), %rdi
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x10(%rbx), %rcx
movq 0x18(%rbx), %r8
callq 0xe98a
decl %eax
movl %eax, 0x18(%r14)
cmpl $0x3, (%r12)
jne 0x22efa
andq $0x0, (%rbx)
movq 0x40(%r15), %rax
movq (%rax), %rax
movq 0x18(%rbx), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xe38c
movq %rax, 0x10(%rbx)
movl $0x2, 0x38(%r14)
movl 0x18(%rbx), %eax
subl 0x8(%rbx), %eax
movl %eax, 0x18(%r14)
jmp 0x22efa
cmpb $0x1, 0x19d9(%r12)
jne 0x22efa
movl 0x38(%r14), %eax
cmpl $0x1, %eax
je 0x22ed5
cmpl $0x2, %eax
jne 0x22efa
movq 0x8(%rcx), %rax
andq $0x0, (%rbx)
movq %rax, 0x8(%rbx)
movslq 0x18(%r14), %rdx
addq 0x8(%rcx), %rdx
movq %rdx, 0x18(%rbx)
movq 0x40(%r15), %rax
movq 0x8(%rax), %rcx
leaq -0x1(%rcx), %rsi
cmpq %rcx, %rdx
setl %dil
cmovlq %rdx, %rsi
xorl %ecx, %ecx
testq %rsi, %rsi
setns %dl
cmovgq %rsi, %rcx
testb %dl, %dil
jne 0x22ec3
movq %rcx, 0x18(%rbx)
movq (%rax), %rax
movq (%rax,%rcx,8), %rdi
callq 0xe38c
movq %rax, 0x10(%rbx)
jmp 0x22efa
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x40(%r15), %rdi
movslq 0x18(%r14), %rax
movq (%rcx), %rsi
movq 0x8(%rcx), %rdx
movq %rax, %rcx
callq 0xec3a
movq %rax, 0x10(%rbx)
movq %rdx, 0x18(%rbx)
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq