// File: /workspace/github_c_makefile_star2_O3/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 $0x838, %rsp            # imm = 0x838
movl %r8d, %ebx
movq %rcx, %r12
movq %rdx, %rbp
movq %rsi, %r13
movq %rdi, %r15
movq 0x40(%rdi), %rax
movq 0x48(%rdi), %r14
cmpq %rax, 0x4118(%r14)
je 0x1116d
movq %rax, 0x4118(%r14)
testb %bl, %bl
je 0x11293
movl %ebx, 0x4(%rsp)
movq 0x4100(%r14), %rbx
testq %rbx, %rbx
je 0x111b2
imulq $0x410, 0x4110(%r14), %rdi # imm = 0x410
addq %r14, %rdi
movq %r15, %rsi
callq 0x113d5
testb %al, %al
movl 0x4(%rsp), %ebx
jne 0x1128f
movq 0x40(%r15), %rax
movq 0x4100(%r14), %rbx
movups 0x30(%r15), %xmm0
leaq 0x20(%rsp), %rdi
movaps %xmm0, -0x10(%rdi)
movq 0x10(%rax), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0xd0b0
leaq 0x428(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl $0x410, %edx            # imm = 0x410
callq 0xd420
cmpq $0x10, %rbx
jge 0x1122e
movq 0x4108(%r14), %rax
testq %rbx, %rbx
jle 0x11208
incq %rax
movq %rax, 0x4108(%r14)
movq %rax, 0x4110(%r14)
movl 0x4(%rsp), %ebx
imulq $0x410, %rax, %rdi      # imm = 0x410
addq %r14, %rdi
leaq 0x10(%rsp), %rsi
movl $0x410, %edx            # imm = 0x410
callq 0xd580
incq 0x4100(%r14)
jmp 0x1128f
movq %rbp, 0x8(%rsp)
movq 0x4108(%r14), %rax
testq %rax, %rax
jle 0x1126a
xorl %ebp, %ebp
movq %r14, %rdi
leaq 0x410(%rdi), %rbx
movl $0x410, %edx            # imm = 0x410
movq %rbx, %rsi
callq 0xd420
movq 0x4108(%r14), %rax
incq %rbp
movq %rbx, %rdi
cmpq %rbp, %rax
jg 0x11244
imulq $0x410, %rax, %rdi      # imm = 0x410
addq %r14, %rdi
leaq 0x428(%rsp), %rsi
movl $0x410, %edx            # imm = 0x410
callq 0xd420
movq 0x8(%rsp), %rbp
movl 0x4(%rsp), %ebx
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 0xfdb4
testb %bl, %bl
je 0x113bc
leaq 0x30(%r15), %rax
movups (%rax), %xmm0
leaq 0x20(%rsp), %rdi
movaps %xmm0, -0x10(%rdi)
movq 0x40(%r15), %rax
movq 0x10(%rax), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0xd0b0
leaq 0x428(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl $0x410, %edx            # imm = 0x410
callq 0xd420
movq 0x4100(%r14), %rcx
cmpq $0x10, %rcx
jge 0x11365
movq 0x4108(%r14), %rax
testq %rcx, %rcx
jle 0x11343
incq %rax
movq %rax, 0x4108(%r14)
movq %rax, 0x4110(%r14)
imulq $0x410, %rax, %rdi      # imm = 0x410
addq %r14, %rdi
leaq 0x10(%rsp), %rsi
movl $0x410, %edx            # imm = 0x410
callq 0xd580
incq 0x4100(%r14)
jmp 0x113bc
movq 0x4108(%r14), %rax
testq %rax, %rax
jle 0x1139d
xorl %r15d, %r15d
movq %r14, %rdi
leaq 0x410(%rdi), %rbx
movl $0x410, %edx            # imm = 0x410
movq %rbx, %rsi
callq 0xd420
movq 0x4108(%r14), %rax
incq %r15
movq %rbx, %rdi
cmpq %r15, %rax
jg 0x11377
imulq $0x410, %rax, %rax      # imm = 0x410
addq %rax, %r14
leaq 0x428(%rsp), %rsi
movl $0x410, %edx            # imm = 0x410
movq %r14, %rdi
callq 0xd420
movl $0x0, (%rbp)
addq $0x838, %rsp            # imm = 0x838
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq