// File: /workspace/github_c_makefile_star2_O3/justy989[P]ce/ce_vim.c
// Function: ce_vim_move_begin_little_word
CePoint_t ce_vim_move_begin_little_word(CeBuffer_t* buffer, CePoint_t start){
     WordState_t state = WORD_INSIDE_OTHER;

     start.x--;
     if(!ce_buffer_point_is_valid(buffer, start)){
          if(start.x == -1){
               start.y--;
               if(start.y < 0) return (CePoint_t){0, 0};
               start.x = ce_utf8_strlen(buffer->lines[start.y]);
               if(start.x > 0) start.x--;
               else return start;
               state = WORD_NEW_LINE;
          }else{
               return (CePoint_t){-1, -1};
          }
     }


     char* line_start = buffer->lines[start.y];
     char* itr = ce_utf8_iterate_to(line_start, start.x); // start one character back

     int64_t rune_len = 0;
     CeRune_t rune = ce_utf8_decode_reverse(itr, line_start, &rune_len);

     if(is_little_word_character(rune)){
          if(start.x == 0) return start;
          state = WORD_INSIDE_WORD;
     }else if(isspace(rune)){
          state = WORD_INSIDE_SPACE;
     }else{
          if(start.x == 0) return start;
     }

     itr -= rune_len;

     while(true){
          rune = ce_utf8_decode_reverse(itr, line_start, &rune_len);

          switch(state){
          default:
               assert(0);
               break;
          case WORD_INSIDE_WORD:
               if(isspace(rune)) goto END_LOOP;
               else if(!is_little_word_character(rune)) goto END_LOOP;
               break;
          case WORD_INSIDE_SPACE:
               if(is_little_word_character(rune)) state = WORD_INSIDE_WORD;
               else if(!isspace(rune)) state = WORD_INSIDE_OTHER;;
               break;
          case WORD_INSIDE_OTHER:
               if(isspace(rune)) goto END_LOOP;
               else if(is_little_word_character(rune)) goto END_LOOP;
               break;
          case WORD_NEW_LINE:
               if(is_little_word_character(rune)) state = WORD_INSIDE_WORD;
               if(isspace(rune)) state = WORD_INSIDE_SPACE;
               goto END_LOOP;
          }

          itr -= rune_len;
          start.x--;

          if(itr < line_start){
               if(state == WORD_INSIDE_WORD || state == WORD_INSIDE_OTHER) break;

               start.y--;
               if(start.y < 0) return (CePoint_t){0, 0};
               start.x = ce_utf8_strlen(buffer->lines[start.y]);
               if(start.x > 0) start.x--;
               else break;
               line_start = buffer->lines[start.y];
               itr = ce_utf8_iterate_to(line_start, start.x); // start one character back
               state = WORD_NEW_LINE;
          }
     }

END_LOOP:
     return start;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r13
leaq -0x1(%rsi), %r14
movq %r14, %rsi
callq 0xe4d4
movl $0x2, %ebx
testq %rax, %rax
je 0x26780
movq %r13, 0x10(%rsp)
movq (%r13), %rax
movq %r12, (%rsp)
movq (%rax,%r12,8), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0xe577
movq %rax, %rbp
leaq 0x8(%rsp), %rdx
movq $0x0, (%rdx)
movq %rax, %rdi
movq %r13, %rsi
callq 0x100aa
movl %eax, %r15d
callq 0xd720
movq %rax, %r12
cmpl $0x5f, %r15d
je 0x267ca
movq (%r12), %rax
movslq %r15d, %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, %ecx
andl $0x8, %ecx
jne 0x267ca
movl $0x1, %r15d
btl $0xd, %eax
jb 0x267d6
movl %ebx, %r15d
jmp 0x267cd
movq $-0x1, %r14
movq $-0x1, %rdx
testq %r15, %r15
jne 0x268f9
testq %r12, %r12
jle 0x2690b
movq (%r13), %rax
movq -0x8(%rax,%r12,8), %rdi
decq %r12
callq 0xe445
movq %rax, %r14
testq %rax, %rax
jle 0x26912
decq %r14
movl $0x3, %ebx
jmp 0x26716
xorl %r15d, %r15d
testq %r14, %r14
je 0x268ef
leaq 0x8(%rsp), %rax
subq (%rax), %rbp
leaq 0x9a6b(%rip), %rbx      # 0x30250
movq %rbp, %rdi
movq %r13, %rsi
leaq 0x8(%rsp), %rdx
callq 0x100aa
movl %r15d, %ecx
movslq (%rbx,%rcx,4), %rcx
addq %rbx, %rcx
jmpq *%rcx
movq (%r12), %rcx
movslq %eax, %rdx
movzwl (%rcx,%rdx,2), %esi
btl $0xd, %esi
jb 0x268f2
xorl %ecx, %ecx
movb $0x1, %dl
cmpl $0x5f, %eax
je 0x26889
movl $0x0, %r15d
andl $0x8, %esi
jne 0x2688c
jmp 0x268f2
xorl %ecx, %ecx
movb $0x1, %dl
cmpl $0x5f, %eax
je 0x26889
movq (%r12), %rsi
cltq
movzwl (%rsi,%rax,2), %eax
movl %eax, %esi
movl $0x0, %r15d
andl $0x8, %esi
jne 0x2688c
xorl %ecx, %ecx
btl $0xd, %eax
setae %cl
movl %ecx, %r15d
incl %r15d
xorl %edx, %edx
jmp 0x2688c
movq (%r12), %rcx
movslq %eax, %rdx
movzwl (%rcx,%rdx,2), %ecx
btl $0xd, %ecx
jb 0x268f2
cmpl $0x5f, %eax
je 0x268f2
andl $0x8, %ecx
jne 0x268f2
xorl %edx, %edx
movl $0x2, %r15d
movb $0x1, %cl
jmp 0x2688c
xorl %r15d, %r15d
subq 0x8(%rsp), %rbp
decq %r14
cmpq %r13, %rbp
jae 0x267e5
orb %cl, %dl
jne 0x268f2
movq (%rsp), %r15
testq %r15, %r15
jle 0x26917
decq %r15
movq 0x10(%rsp), %r13
movq (%r13), %rax
movq (%rax,%r15,8), %rdi
callq 0xe445
movq %rax, %r14
testq %rax, %rax
jle 0x268f6
decq %r14
movq (%r13), %rax
movq %r15, (%rsp)
movq (%rax,%r15,8), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0xe577
movq %rax, %rbp
movl $0x3, %r15d
jmp 0x267e5
xorl %r14d, %r14d
movq (%rsp), %r15
movq %r15, %rdx
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r14d, %r14d
xorl %edx, %edx
jmp 0x268f9
movq %r12, %rdx
jmp 0x268f9
xorl %r14d, %r14d
xorl %r15d, %r15d
jmp 0x268f6