// File: /workspace/github_c_makefile_star2_O3/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, %r15
movq %rsi, %r13
movq %rdi, %r12
movq 0x58(%rdi), %rax
movq 0x600(%rax), %rax
cmpq 0x151c1(%rip), %rax     # 0x39fb8
je 0x24e33
cmpq 0x15188(%rip), %rax     # 0x39f88
je 0x24e33
cmpq 0x15157(%rip), %rax     # 0x39f60
je 0x24e33
cmpq 0x15146(%rip), %rax     # 0x39f58
je 0x24e33
cmpq 0x1514d(%rip), %rax     # 0x39f68
setne %al
testq %r15, %r15
sets %cl
orb %al, %cl
je 0x24eb6
xorl %ebx, %ebx
jmp 0x24f7d
movq %rcx, 0x10(%rsp)
xorl %ebx, %ebx
movl %ebx, (%rsp)
leaq 0x38(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r15, %rcx
movl $0x7b, %r8d
xorl %r9d, %r9d
callq 0x26ff8
movl %ebx, (%rsp)
leaq 0x18(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r15, %rcx
movl $0x28, %r8d
xorl %r9d, %r9d
callq 0x26ff8
movq (%rbp), %rdx
movq (%r14), %r13
testq %r13, %rdx
js 0x24f7d
movq 0x20(%rsp), %rsi
movq 0x40(%rsp), %r15
movq %r13, %rdi
movq %r15, %rcx
callq 0xec71
testb %al, %al
je 0x24f2e
incq %r13
movq %r13, %rbx
jmp 0x24f7d
movq (%r12), %r14
xorl %ebx, %ebx
movabsq $0x100000000, %r13      # imm = 0x100000000
movq (%r14,%r15,8), %r12
movb (%r12), %bpl
testb %bpl, %bpl
je 0x24ef7
callq 0xd720
movq (%rax), %rcx
xorl %eax, %eax
movsbq %bpl, %rdx
testb $0x1, (%rcx,%rdx,2)
je 0x24f05
movb 0x1(%r12), %bpl
incq %r12
addq %r13, %rax
testb %bpl, %bpl
jne 0x24edd
leaq -0x1(%r15), %rax
testq %r15, %r15
movq %rax, %r15
jg 0x24ec6
jmp 0x24f7d
cmpb $0x0, (%r12)
leaq 0x1(%r12), %r12
jne 0x24f05
movabsq $0x500000000, %rbx      # imm = 0x500000000
addq %rax, %rbx
cmpb $0x3a, -0x2(%r12)
cmovneq %rax, %rbx
sarq $0x20, %rbx
jmp 0x24f7d
movq %r12, %rdi
movq %r15, %rsi
callq 0x25f8c
movq %rax, %rbx
movl $0x0, (%rsp)
leaq 0x18(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
movq %r15, %rcx
movl $0x28, %r8d
xorl %r9d, %r9d
callq 0x26ff8
cmpq $0x0, (%r14)
js 0x24f78
movq 0x20(%rsp), %rsi
movq %r12, %rdi
callq 0x25f8c
movq %rax, %rbx
addq 0x10(%rsp), %rbx
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq