// File: /workspace/github_c_makefile_star2_O1/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 0x11317
movq %rax, 0x4118(%r14)
testb %bl, %bl
je 0x1146a
cmpq $0x0, 0x4100(%r14)
je 0x11339
imulq $0x410, 0x4110(%r14), %rdi # imm = 0x410
addq %r14, %rdi
jmp 0x1133b
xorl %edi, %edi
testq %rdi, %rdi
movq %rbp, 0x8(%rsp)
je 0x11372
movq %r15, %rsi
callq 0x115c8
movl %ebx, %ebp
movl %eax, %ebx
leaq 0x10(%rsp), %rdi
movl $0x410, %edx            # imm = 0x410
xorl %esi, %esi
callq 0xd2a0
testb %bl, %bl
movl %ebp, %ebx
movq 0x8(%rsp), %rbp
je 0x11383
jmp 0x1146a
leaq 0x10(%rsp), %rdi
movl $0x410, %edx            # imm = 0x410
xorl %esi, %esi
callq 0xd2a0
movups 0x30(%r15), %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), %rax
cmpq $0x10, %rax
jge 0x1140a
testq %rax, %rax
jle 0x113e4
movq 0x4108(%r14), %rax
incq %rax
movq %rax, 0x4108(%r14)
movq %rax, 0x4110(%r14)
imulq $0x410, 0x4108(%r14), %rdi # imm = 0x410
addq %r14, %rdi
leaq 0x10(%rsp), %rsi
movl $0x410, %edx            # imm = 0x410
callq 0xd580
incq 0x4100(%r14)
jmp 0x1146a
movl %ebx, 0x4(%rsp)
movq 0x4108(%r14), %rax
testq %rax, %rax
jle 0x11445
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 0x1141f
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 0xff34
testb %bl, %bl
je 0x115af
leaq 0x30(%r15), %r12
leaq 0x20(%rsp), %rbx
movl $0x400, %edx            # imm = 0x400
movq %rbx, %rdi
xorl %esi, %esi
callq 0xd2a0
movups (%r12), %xmm0
movaps %xmm0, -0x10(%rbx)
movq 0x40(%r15), %rax
movq 0x10(%rax), %rsi
movl $0x400, %edx            # imm = 0x400
movq %rbx, %rdi
callq 0xd0b0
leaq 0x428(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl $0x410, %edx            # imm = 0x410
callq 0xd420
movq 0x4100(%r14), %rax
cmpq $0x10, %rax
jge 0x11558
testq %rax, %rax
jle 0x11532
movq 0x4108(%r14), %rax
incq %rax
movq %rax, 0x4108(%r14)
movq %rax, 0x4110(%r14)
imulq $0x410, 0x4108(%r14), %rdi # imm = 0x410
addq %r14, %rdi
leaq 0x10(%rsp), %rsi
movl $0x410, %edx            # imm = 0x410
callq 0xd580
incq 0x4100(%r14)
jmp 0x115af
movq 0x4108(%r14), %rax
testq %rax, %rax
jle 0x11590
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 0x1156a
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