// File: /workspace/github_c_makefile_star2_O3/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 $0x448, %rsp            # imm = 0x448
movl $0x2, %r13d
cmpq $0x0, 0x208(%rdi)
jne 0x17def
movq %rsi, %rbx
movl $0x3, %r13d
cmpq $0x0, 0x27f8(%rsi)
je 0x17e04
movl %r13d, %eax
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2818(%rbx), %rax
movq 0x10(%rax), %rdx
movq 0x10(%rdx), %rax
leaq 0x8(%rax), %rcx
xorl %r13d, %r13d
cmpl $0x0, (%rax)
cmovneq %r13, %rcx
movq %rcx, 0x20(%rsp)
movq 0x2888(%rbx), %r15
testq %r15, %r15
je 0x17def
cmpq $0x0, 0x8(%r15)
je 0x17def
movq %rdx, 0x8(%rsp)
movq 0x58(%r15), %r14
movq 0x5f8(%r14), %rcx
leaq 0x1(%rcx), %r13
leaq 0x2828(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x1a50(%rbx), %rax
movq %rax, 0x18(%rsp)
addq $0x20, %rbx
leaq 0x38(%rsp), %rbp
movq %rcx, 0x28(%rsp)
movq %rcx, %rax
movq %r15, 0x30(%rsp)
cmpq 0x8(%r15), %r13
jl 0x17e95
movl $0x0, %r13d
testq %rax, %rax
movl $0x0, %eax
je 0x17f3f
movq (%r15), %rax
movq (%rax,%r13,8), %rsi
movq %rbp, %rdi
callq 0x11dde
cmpq $0x0, 0x38(%rsp)
js 0x17f0a
cmpq $0x0, 0x40(%rsp)
js 0x17f0a
movq %r15, %rdi
callq 0x11a2b
movq %rax, %r12
movq %rbp, (%rsp)
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rbx, %rcx
movl $0x1, %r8d
movq %rax, %r9
callq 0x139a8
movq %rbx, %r15
movq %r14, %rbx
movq %rbp, %r14
movq %rax, %rbp
movq %r12, %rdi
callq 0xd090
testq %rbp, %rbp
movq %r14, %rbp
movq %rbx, %r14
movq %r15, %rbx
movq 0x30(%rsp), %r15
jne 0x17f1f
movq 0x5f8(%r14), %rax
incq %r13
cmpq %rax, %r13
jne 0x17e7b
jmp 0x17f3f
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x1f0d9
testq %rax, %rax
je 0x17f35
movq %r13, 0x30(%rax)
movq %r13, 0x5f8(%r14)
movq %r13, %rax
xorl %r13d, %r13d
movq 0x28(%rsp), %r14
cmpq %r14, %rax
jne 0x17def
cmpq 0x8(%r15), %r14
jge 0x17def
movq (%r15), %rax
movq (%rax,%r14,8), %rsi
leaq 0x38(%rsp), %r12
movq %r12, %rdi
callq 0x11dde
cmpq $0x0, (%r12)
js 0x17def
cmpq $0x0, 0x40(%rsp)
js 0x17def
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x1f0d9
testq %rax, %rax
je 0x17f9b
movq %r14, 0x30(%rax)
movq %r15, %rdi
callq 0x11a2b
movq %rax, %r15
movq %r12, (%rsp)
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rbx, %rcx
movl $0x1, %r8d
movq %rax, %r9
callq 0x139a8
movq %r15, %rdi
callq 0xd090
jmp 0x17def