// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce_app.c
// Function: ce_clang_format_selection
bool ce_clang_format_selection(char* clang_format_exe, CeView_t* view, CeVimMode_t vim_mode, CeVimVisualData_t* visual){
    CePoint_t highlight_start = {};
    CePoint_t highlight_end = {};
    if(!ce_vim_get_selection_range(vim_mode, visual, view, &highlight_start, &highlight_end)){
        return false;
    }
    // Pass clang-format the entire buffer, but tell it the offset and length to format.
    char* buffer_str = ce_buffer_dupe(view->buffer);
    int64_t buffer_str_len = ce_utf8_strlen(buffer_str);
    char command_buffer[MAX_PATH_LEN];
    snprintf(command_buffer, MAX_PATH_LEN, "%s --lines=%" PRId64 ":%" PRId64,
             clang_format_exe, highlight_start.y + 1, highlight_end.y + 1);
    ClangFormatResult_t result = _clang_format_string(command_buffer, buffer_str,
                                                      buffer_str_len);
    if(!result.success){
        return false;
    }
    int64_t result_len = ce_utf8_strlen(result.bytes);
    if(result_len <= 0){
        return false;
    }

    bool removed = ce_buffer_remove_string_change(view->buffer, (CePoint_t){0, 0}, buffer_str_len,
                                                  &view->cursor, view->cursor, false);
    if(!removed){
        ce_log("Failed to clear buffer %s to insert clang format results\n", view->buffer->name);
        free(result.bytes);
        return false;
    }
    bool inserted = ce_buffer_insert_string_change(view->buffer, result.bytes, (CePoint_t){0, 0}, &view->cursor,
                                                   view->cursor, true);
    if(!inserted){
        ce_log("Failed to insert clang format results into %s\n", view->buffer->name);
        free(result.bytes);
        return false;
    }
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x438, %rsp            # imm = 0x438
movq %rsi, %rbx
movq %rdi, %r14
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rax
movaps %xmm0, (%rax)
leaq 0x10(%rsp), %r8
movaps %xmm0, (%r8)
movl %edx, %edi
movq %rcx, %rsi
movq %rbx, %rdx
movq %rax, %rcx
callq 0x26dcc
testb %al, %al
je 0x1432a
movq 0x40(%rbx), %rdi
callq 0xf570
movq %rax, %r12
movq %rax, %rdi
callq 0xe38c
movq %rax, %r15
movq 0x28(%rsp), %r8
incq %r8
movq 0x18(%rsp), %r9
incq %r9
leaq 0x17bcb(%rip), %rdx     # 0x2be60
xorl %ebp, %ebp
leaq 0x30(%rsp), %r13
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0xd260
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x14020
testb $0x1, %al
je 0x1432c
movq %rdx, %r14
movq %rdx, %rdi
callq 0xe38c
testq %rax, %rax
jle 0x1432a
movq 0x40(%rbx), %rdi
leaq 0x30(%rbx), %r12
movups 0x30(%rbx), %xmm0
movups %xmm0, (%rsp)
xorl %esi, %esi
xorl %edx, %edx
movq %r15, %rcx
movq %r12, %r8
xorl %r9d, %r9d
callq 0xf77c
movq 0x40(%rbx), %rdi
testb %al, %al
je 0x14340
movups (%r12), %xmm0
movups %xmm0, (%rsp)
pushq $0x1
popq %r9
movq %r14, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r12, %r8
callq 0xf5c8
movb $0x1, %bpl
testb %al, %al
jne 0x1432c
movq 0x40(%rbx), %rdi
leaq 0x17b09(%rip), %rax     # 0x2be31
jmp 0x14347
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x438, %rsp            # imm = 0x438
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17ab0(%rip), %rax     # 0x2bdf7
movq 0x10(%rdi), %rsi
xorl %ebp, %ebp
movq %rax, %rdi
xorl %eax, %eax
callq 0xd8e5
movq %r14, %rdi
callq 0xd090
jmp 0x1432c