// File: /workspace/github_c_makefile_star2_O1/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 0xe514
movl $0x2, %ebx
testq %rax, %rax
je 0x268af
movq %r13, 0x10(%rsp)
movq (%r13), %rax
movq %r12, (%rsp)
movq (%rax,%r12,8), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0xe5be
movq %rax, %rbp
leaq 0x8(%rsp), %rdx
movq $0x0, (%rdx)
movq %rax, %rdi
movq %r13, %rsi
callq 0x1025d
movl %eax, %r15d
callq 0xd720
movq %rax, %r12
cmpl $0x5f, %r15d
je 0x268f9
movq (%r12), %rax
movslq %r15d, %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, %ecx
andl $0x8, %ecx
jne 0x268f9
movl $0x1, %r15d
btl $0xd, %eax
jb 0x26905
movl %ebx, %r15d
jmp 0x268fc
movq $-0x1, %r14
movq $-0x1, %rdx
testq %r15, %r15
jne 0x26a28
testq %r12, %r12
jle 0x26a3a
movq (%r13), %rax
movq -0x8(%rax,%r12,8), %rdi
decq %r12
callq 0xe485
movq %rax, %r14
testq %rax, %rax
jle 0x26a41
decq %r14
movl $0x3, %ebx
jmp 0x26845
xorl %r15d, %r15d
testq %r14, %r14
je 0x26a1e
leaq 0x8(%rsp), %rax
subq (%rax), %rbp
leaq 0xa88c(%rip), %rbx      # 0x311a0
movq %rbp, %rdi
movq %r13, %rsi
leaq 0x8(%rsp), %rdx
callq 0x1025d
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 0x26a21
xorl %ecx, %ecx
movb $0x1, %dl
cmpl $0x5f, %eax
je 0x269b8
movl $0x0, %r15d
andl $0x8, %esi
jne 0x269bb
jmp 0x26a21
xorl %ecx, %ecx
movb $0x1, %dl
cmpl $0x5f, %eax
je 0x269b8
movq (%r12), %rsi
cltq
movzwl (%rsi,%rax,2), %eax
movl %eax, %esi
movl $0x0, %r15d
andl $0x8, %esi
jne 0x269bb
xorl %ecx, %ecx
btl $0xd, %eax
setae %cl
movl %ecx, %r15d
incl %r15d
xorl %edx, %edx
jmp 0x269bb
movq (%r12), %rcx
movslq %eax, %rdx
movzwl (%rcx,%rdx,2), %ecx
btl $0xd, %ecx
jb 0x26a21
cmpl $0x5f, %eax
je 0x26a21
andl $0x8, %ecx
jne 0x26a21
xorl %edx, %edx
movl $0x2, %r15d
movb $0x1, %cl
jmp 0x269bb
xorl %r15d, %r15d
subq 0x8(%rsp), %rbp
decq %r14
cmpq %r13, %rbp
jae 0x26914
orb %cl, %dl
jne 0x26a21
movq (%rsp), %r15
testq %r15, %r15
jle 0x26a46
decq %r15
movq 0x10(%rsp), %r13
movq (%r13), %rax
movq (%rax,%r15,8), %rdi
callq 0xe485
movq %rax, %r14
testq %rax, %rax
jle 0x26a25
decq %r14
movq (%r13), %rax
movq %r15, (%rsp)
movq (%rax,%r15,8), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0xe5be
movq %rax, %rbp
movl $0x3, %r15d
jmp 0x26914
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 0x26a28
movq %r12, %rdx
jmp 0x26a28
xorl %r14d, %r14d
xorl %r15d, %r15d
jmp 0x26a25