// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce_vim.c
// Function: ce_vim_get_indentation
int64_t ce_vim_get_indentation(CeBuffer_t* buffer, CePoint_t point, int64_t tab_length){
     CeAppBufferData_t* buffer_data = buffer->app_data;

     if(buffer_data->syntax_function == ce_syntax_highlight_c ||
        buffer_data->syntax_function == ce_syntax_highlight_cpp ||
        buffer_data->syntax_function == ce_syntax_highlight_java ||
        buffer_data->syntax_function == ce_syntax_highlight_config){
          CeRange_t brace_range = ce_vim_find_pair(buffer, point, '{', false, 0);
          CeRange_t paren_range = ce_vim_find_pair(buffer, point, '(', false, 0);
          if(brace_range.start.x < 0 && paren_range.start.x < 0) return 0;
          int64_t indent = 0;
          if(ce_point_after(paren_range.start, brace_range.start)){
               indent = paren_range.start.x + 1;
          }else{
               indent = ce_vim_soft_begin_line(buffer, brace_range.start.y);
               // if in our indent, we are inside parens, get the indentation of where the parens started
               paren_range = ce_vim_find_pair(buffer, (CePoint_t){indent, brace_range.start.y}, '(', false, 0);
               if(paren_range.start.x >= 0){
                    indent = ce_vim_soft_begin_line(buffer, paren_range.start.y);
               }
               indent += tab_length;
          }
          return indent;
     }else if(buffer_data->syntax_function == ce_syntax_highlight_python){
          for(int64_t y = point.y; y >= 0; --y){
               const char* itr = buffer->lines[y];

               // find previous line that isn't blank
               bool blank = true;

               while(*itr){
                    if(!isblank((int)(*itr))){
                         blank = false;
                         break;
                    }

                    itr++;
               }

               if(blank) continue;

               // use it as indentation unless it ends in a ':'
               int indentation = itr - buffer->lines[y];

               while(*itr) itr++;
               itr--;

               if(*itr == ':') indentation += 5;
               return indentation;
          }
     }

     return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
movq 0x58(%rdi), %rax
movq 0x600(%rax), %rax
cmpq 0x16ce0(%rip), %rax     # 0x38fb8
je 0x22389
cmpq 0x16ca3(%rip), %rax     # 0x38f88
je 0x22389
cmpq 0x16c6e(%rip), %rax     # 0x38f60
je 0x22389
cmpq 0x16c59(%rip), %rax     # 0x38f58
je 0x22389
xorl %r14d, %r14d
cmpq 0x16c59(%rip), %rax     # 0x38f68
jne 0x2244a
movabsq $0x100000000, %r13      # imm = 0x100000000
movq %rbx, 0x8(%rsp)
testq %r12, %r12
js 0x2244a
movq (%rbx), %rax
movq (%rax,%r12,8), %rbp
xorl %r15d, %r15d
movsbq (%rbp), %rbx
testq %rbx, %rbx
je 0x22357
callq 0xd720
movq (%rax), %rax
testb $0x1, (%rax,%rbx,2)
je 0x22361
incq %rbp
addq %r13, %r15
jmp 0x22337
decq %r12
movq 0x8(%rsp), %rbx
jmp 0x22324
cmpb $0x0, (%rbp)
leaq 0x1(%rbp), %rbp
jne 0x22361
movabsq $0x500000000, %r14      # imm = 0x500000000
addq %r15, %r14
cmpb $0x3a, -0x2(%rbp)
cmovneq %r15, %r14
sarq $0x20, %r14
jmp 0x2244a
movq %rcx, 0x10(%rsp)
andl $0x0, (%rsp)
leaq 0x38(%rsp), %rbp
pushq $0x7b
popq %r8
xorl %r14d, %r14d
movq %rbp, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r12, %rcx
xorl %r9d, %r9d
callq 0x2429d
andl $0x0, (%rsp)
leaq 0x18(%rsp), %r15
pushq $0x28
popq %r8
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r12, %rcx
xorl %r9d, %r9d
callq 0x2429d
movq (%rbp), %rdx
movq (%r15), %r13
testq %r13, %rdx
js 0x2244a
movq 0x20(%rsp), %rsi
movq 0x40(%rsp), %r12
movq %r13, %rdi
movq %r12, %rcx
callq 0xea69
testb %al, %al
je 0x22400
incq %r13
movq %r13, %r14
jmp 0x2244a
movq %rbx, %rdi
movq %r12, %rsi
callq 0x23364
movq %rax, %r14
andl $0x0, (%rsp)
leaq 0x18(%rsp), %r15
pushq $0x28
popq %r8
movq %r15, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movq %r12, %rcx
xorl %r9d, %r9d
callq 0x2429d
cmpq $0x0, (%r15)
js 0x22445
movq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x23364
movq %rax, %r14
addq 0x10(%rsp), %r14
movq %r14, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq