// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x4c0, %rsp            # imm = 0x4C0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0xd290
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0xd290
movl -0x1c(%rbp), %edi
movq -0x28(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x38(%rbp), %rcx
leaq -0x48(%rbp), %r8
callq 0x3c300
testb $0x1, %al
jne 0x198ff
movb $0x0, -0x1(%rbp)
jmp 0x19adb
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x10cf0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
callq 0xea70
movq %rax, -0x58(%rbp)
leaq -0x460(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq -0x30(%rbp), %r8
addq $0x1, %r8
movq -0x40(%rbp), %r9
addq $0x1, %r9
movl $0x400, %esi            # imm = 0x400
leaq 0x2a4cf(%rip), %rdx     # 0x43e13
movb $0x0, %al
callq 0xd250
leaq -0x460(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdx
callq 0x19530
movb %al, -0x470(%rbp)
movq %rdx, -0x468(%rbp)
testb $0x1, -0x470(%rbp)
jne 0x1997e
movb $0x0, -0x1(%rbp)
jmp 0x19adb
movq -0x468(%rbp), %rdi
callq 0xea70
movq %rax, -0x478(%rbp)
cmpq $0x0, -0x478(%rbp)
jg 0x199a4
movb $0x0, -0x1(%rbp)
jmp 0x19adb
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rdi
movq $0x0, -0x490(%rbp)
movq $0x0, -0x488(%rbp)
movq -0x58(%rbp), %rcx
movq -0x18(%rbp), %r8
addq $0x30, %r8
movq -0x18(%rbp), %rax
addq $0x30, %rax
movq -0x490(%rbp), %rsi
movq -0x488(%rbp), %rdx
xorl %r9d, %r9d
movq (%rax), %r10
movq %r10, (%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
callq 0x110a0
andb $0x1, %al
movb %al, -0x479(%rbp)
testb $0x1, -0x479(%rbp)
jne 0x19a3c
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x10(%rax), %rsi
leaq 0x2a38a(%rip), %rdi     # 0x43daa
movb $0x0, %al
callq 0xd8f0
movq -0x468(%rbp), %rdi
callq 0xd090
movb $0x0, -0x1(%rbp)
jmp 0x19adb
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x468(%rbp), %rsi
movq $0x0, -0x4a8(%rbp)
movq $0x0, -0x4a0(%rbp)
movq -0x18(%rbp), %r8
addq $0x30, %r8
movq -0x18(%rbp), %rax
addq $0x30, %rax
movq -0x4a8(%rbp), %rdx
movq -0x4a0(%rbp), %rcx
movl $0x1, %r9d
movq (%rax), %r10
movq %r10, (%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
callq 0x10da0
andb $0x1, %al
movb %al, -0x491(%rbp)
testb $0x1, -0x491(%rbp)
jne 0x19ad7
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x10(%rax), %rsi
leaq 0x2a326(%rip), %rdi     # 0x43de4
movb $0x0, %al
callq 0xd8f0
movq -0x468(%rbp), %rdi
callq 0xd090
movb $0x0, -0x1(%rbp)
jmp 0x19adb
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x4c0, %rsp            # imm = 0x4C0
popq %rbp
retq
nopl (%rax)