// File: /workspace/github_c_makefile_star2_O1/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, %r14
movq %rsi, %r13
movq %rdi, %r12
movq 0x58(%rdi), %rax
movq 0x600(%rax), %rax
cmpq 0x16179(%rip), %rax     # 0x3afb8
je 0x24f21
cmpq 0x1613c(%rip), %rax     # 0x3af88
je 0x24f21
cmpq 0x16107(%rip), %rax     # 0x3af60
je 0x24f21
cmpq 0x160f2(%rip), %rax     # 0x3af58
je 0x24f21
cmpq 0x160f5(%rip), %rax     # 0x3af68
jne 0x24ff0
movq %r14, %r15
shrq $0x3f, %r15
testq %r14, %r14
js 0x24fea
movq (%r12), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq (%rax,%r14,8), %r13
movsbq (%r13), %r12
testq %r12, %r12
sete %bpl
je 0x24eff
callq 0xd720
movq (%rax), %rcx
testb $0x1, (%rcx,%r12,2)
movq %r13, %rax
je 0x24ed2
movsbq 0x1(%rax), %rdx
testq %rdx, %rdx
sete %bpl
je 0x24eff
incq %rax
testb $0x1, (%rcx,%rdx,2)
jne 0x24ebb
movq %rax, %rcx
cmpb $0x0, (%rcx)
leaq 0x1(%rcx), %rcx
jne 0x24ed5
subl %r13d, %eax
shlq $0x20, %rax
cmpb $0x3a, -0x2(%rcx)
movabsq $0x500000000, %rcx      # imm = 0x500000000
leaq (%rax,%rcx), %rbx
cmovneq %rax, %rbx
sarq $0x20, %rbx
testb %bpl, %bpl
je 0x24fea
leaq -0x1(%r14), %rax
testq %r14, %r14
setle %r15b
movq %rax, %r14
jg 0x24e92
jmp 0x24fea
movq %rcx, 0x10(%rsp)
xorl %ebx, %ebx
movl %ebx, (%rsp)
leaq 0x38(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
movl $0x7b, %r8d
xorl %r9d, %r9d
callq 0x27173
movl %ebx, (%rsp)
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
movl $0x28, %r8d
xorl %r9d, %r9d
callq 0x27173
movq (%rbp), %rdx
movq (%r15), %r13
testq %r13, %rdx
js 0x24ff2
movq 0x20(%rsp), %rsi
movq 0x40(%rsp), %r14
movq %r13, %rdi
movq %r14, %rcx
callq 0xedfb
testb %al, %al
je 0x24f99
incq %r13
movq %r13, %rbx
jmp 0x24ff2
movq %r12, %rdi
movq %r14, %rsi
callq 0x260e5
movq %rax, %rbx
movl $0x0, (%rsp)
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
movq %r14, %rcx
movl $0x28, %r8d
xorl %r9d, %r9d
callq 0x27173
cmpq $0x0, (%r15)
js 0x24fe3
movq 0x20(%rsp), %rsi
movq %r12, %rdi
callq 0x260e5
movq %rax, %rbx
addq 0x10(%rsp), %rbx
jmp 0x24ff2
testb $0x1, %r15b
je 0x24ff2
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq