// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce_commands.c
// Function: command_goto_next_destination
CeCommandStatus_t command_goto_next_destination(CeCommand_t* command, void* user_data){
     if(command->arg_count != 0) return CE_COMMAND_PRINT_HELP;
     CeApp_t* app = user_data;
     CommandContext_t command_context = {};

     if(!get_command_context(app, &command_context)) return CE_COMMAND_NO_ACTION;

     CeBuffer_t* buffer = app->last_goto_buffer;
     if(!buffer || buffer->line_count == 0) return CE_COMMAND_SUCCESS;

     CeAppBufferData_t* buffer_data = buffer->app_data;

     int64_t save_destination = buffer_data->last_goto_destination;
     for(int64_t i = buffer_data->last_goto_destination + 1; i != buffer_data->last_goto_destination; i++){
          if(i >= buffer->line_count){
               i = 0;
               if(i == buffer_data->last_goto_destination) break;
          }

          CeDestination_t destination = scan_line_for_destination(buffer->lines[i]);
          if(destination.point.x < 0 || destination.point.y < 0) continue;

          char* base_directory = buffer_base_directory(buffer);
          CeBuffer_t* loaded_buffer = load_destination_into_view(&app->buffer_node_head, command_context.view,
                                                                 &app->config_options, &app->vim,
                                                                 true, base_directory, &destination);
          free(base_directory);
          if(loaded_buffer){
               CeLayout_t* layout = ce_layout_buffer_in_view(command_context.tab_layout, buffer);
               if(layout) layout->view.scroll.y = i;
               buffer_data->last_goto_destination = i;
               break;
          }
     }

     // we didn't find anything, and since the user asked for a destination, find this one
     if(buffer_data->last_goto_destination == save_destination && save_destination < buffer->line_count){
          CeDestination_t destination = scan_line_for_destination(buffer->lines[save_destination]);
          if(destination.point.x >= 0 && destination.point.y >= 0){
               CeLayout_t* layout = ce_layout_buffer_in_view(command_context.tab_layout, buffer);
               if(layout) layout->view.scroll.y = save_destination;
               char* base_directory = buffer_base_directory(buffer);
               load_destination_into_view(&app->buffer_node_head, command_context.view, &app->config_options, &app->vim,
                                          true, base_directory, &destination);
               free(base_directory);
          }
     }

     return CE_COMMAND_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x468, %rsp            # imm = 0x468
cmpq $0x0, 0x208(%rdi)
je 0x17337
pushq $0x2
jmp 0x1745f
movq %rsi, %r13
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rsi
movaps %xmm0, (%rsi)
movq %r13, %rdi
callq 0x15be9
testb %al, %al
je 0x1745d
movq 0x2888(%r13), %rbx
xorl %ebp, %ebp
testq %rbx, %rbx
je 0x17460
cmpq $0x0, 0x8(%rbx)
je 0x17460
movq 0x58(%rbx), %r15
movq 0x5f8(%r15), %rbp
leaq 0x2828(%r13), %rax
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x1a50(%r13), %rax
movq %rax, 0x18(%rsp)
addq $0x20, %r13
leaq 0x58(%rsp), %r12
movq $0x0, 0x10(%rsp)
movq %rbp, %rax
movq %rbp, 0x48(%rsp)
movq %rbx, 0x50(%rsp)
incq %rbp
cmpq %rax, %rbp
je 0x17474
cmpq 0x8(%rbx), %rbp
jl 0x173de
movl $0x0, %ebp
testq %rax, %rax
je 0x1749d
movq (%rbx), %rax
movq (%rax,%rbp,8), %rsi
movq %r12, %rdi
callq 0x116bb
cmpq $0x0, 0x58(%rsp)
js 0x17451
cmpq $0x0, 0x60(%rsp)
js 0x17451
movq %rbx, %rdi
callq 0x1132c
movq %r15, %rbx
movq %rax, %r15
movq %r12, (%rsp)
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r13, %rcx
pushq $0x1
popq %r8
movq %rax, %r9
callq 0x1316f
movq %r13, %r14
movq %r12, %r13
movq %rax, %r12
movq %r15, %rdi
movq %rbx, %r15
movq 0x50(%rsp), %rbx
callq 0xd090
testq %r12, %r12
movq %r13, %r12
movq %r14, %r13
jne 0x1747b
movq 0x5f8(%r15), %rax
jmp 0x173be
pushq $0x3
popq %rbp
movl %ebp, %eax
addq $0x468, %rsp            # imm = 0x468
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, 0x10(%rsp)
jmp 0x1749d
movq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x1d33e
testq %rax, %rax
je 0x17491
movq %rbp, 0x30(%rax)
movq %rbp, 0x5f8(%r15)
movq %rbp, 0x10(%rsp)
xorl %ebp, %ebp
movq 0x48(%rsp), %r15
cmpq %r15, 0x10(%rsp)
jne 0x17460
cmpq 0x8(%rbx), %r15
jge 0x17460
movq (%rbx), %rax
movq (%rax,%r15,8), %rsi
leaq 0x58(%rsp), %r12
movq %r12, %rdi
callq 0x116bb
cmpq $0x0, (%r12)
js 0x17460
cmpq $0x0, 0x60(%rsp)
js 0x17460
movq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x1d33e
testq %rax, %rax
je 0x174ea
movq %r15, 0x30(%rax)
movq %rbx, %rdi
callq 0x1132c
movq %rax, %r14
movq %r12, (%rsp)
pushq $0x1
popq %r8
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r13, %rcx
movq %rax, %r9
callq 0x1316f
movq %r14, %rdi
callq 0xd090
jmp 0x17460