// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce_app.c
// Function: ce_view_switch_buffer
void ce_view_switch_buffer(CeView_t* view, CeBuffer_t* buffer, CeVim_t* vim,
                           CeConfigOptions_t* config_options, bool insert_into_jump_list){
     CeAppViewData_t* view_data = view->user_data;
     CeJumpList_t* jump_list = &view_data->jump_list;

     if(view_data->prev_buffer != view->buffer) view_data->prev_buffer = view->buffer;

     // if the old buffer is not in the jump list, then add it
     if(insert_into_jump_list){
          bool add_current = false;
          CeDestination_t* current_destination = ce_jump_list_current(jump_list);
          if(current_destination){
               if(!ce_destination_in_view(current_destination, view)){
                    add_current = true;
               }
          }else{
               add_current = true;
          }

          CeDestination_t destination = {};

          if(add_current){
               destination.point = view->cursor;
               strncpy(destination.filepath, view->buffer->name, MAX_PATH_LEN);
               ce_jump_list_insert(jump_list, destination);
          }
     }

     // save the cursor on the old buffer
     view->buffer->cursor_save = view->cursor;
     view->buffer->scroll_save = view->scroll;

     // update new buffer, using the buffer's cursor
     view->buffer = buffer;
     view->cursor = buffer->cursor_save;
     view->scroll = buffer->scroll_save;

     ce_view_follow_cursor(view, config_options->horizontal_scroll_off, config_options->vertical_scroll_off, config_options->tab_width);

     // add to the jump list
     if(insert_into_jump_list){
          CeDestination_t destination = {};
          destination.point = view->cursor;
          strncpy(destination.filepath, view->buffer->name, MAX_PATH_LEN);
          ce_jump_list_insert(jump_list, destination);
     }

     vim->mode = CE_VIM_MODE_NORMAL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x828, %rsp            # imm = 0x828
movl %r8d, %ebp
movq %rcx, %r12
movq %rdx, %rbx
movq %rsi, %r13
movq %rdi, %r15
movq 0x40(%rdi), %rax
movq 0x48(%rdi), %r14
cmpq %rax, 0x4118(%r14)
je 0x10c01
movq %rax, 0x4118(%r14)
testb %bpl, %bpl
je 0x10c6c
cmpq $0x0, 0x4100(%r14)
je 0x10c2e
imulq $0x410, 0x4110(%r14), %rdi # imm = 0x410
addq %r14, %rdi
movq %r15, %rsi
callq 0x10d0b
testb %al, %al
jne 0x10c68
movq 0x40(%r15), %rax
movups 0x30(%r15), %xmm0
leaq 0x420(%rsp), %rdi
movaps %xmm0, -0x10(%rdi)
movq 0x10(%rax), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0xd0b0
leaq 0x410(%rsp), %rsi
movl $0x82, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x10a8e
movq 0x40(%r15), %rax
movups 0x30(%r15), %xmm0
movups %xmm0, 0x20(%rax)
movq 0x40(%r15), %rax
movups 0x20(%r15), %xmm0
movups %xmm0, 0x30(%rax)
movq %r13, 0x40(%r15)
movups 0x20(%r13), %xmm0
movups %xmm0, 0x30(%r15)
movups 0x30(%r13), %xmm0
movups %xmm0, 0x20(%r15)
movq 0x8(%r12), %rcx
movq 0x10(%r12), %rsi
movq 0x18(%r12), %rdx
movq %r15, %rdi
callq 0xfa67
testb %bpl, %bpl
je 0x10cf6
leaq 0x30(%r15), %rax
movups (%rax), %xmm0
leaq 0x420(%rsp), %rdi
movaps %xmm0, -0x10(%rdi)
movq 0x40(%r15), %rax
movq 0x10(%rax), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0xd0b0
leaq 0x410(%rsp), %rsi
movl $0x82, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x10a8e
andl $0x0, (%rbx)
addq $0x828, %rsp            # imm = 0x828
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq