// File: /workspace/github_c_makefile_star2_O1/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 0x1825c
movq 0x27f8(%rsi), %rax
movq 0x2818(%rsi), %rcx
movq 0x10(%rcx), %rdi
testq %rax, %rax
je 0x1823a
movq $0x0, 0x8(%rsp)
jmp 0x18251
movq 0x10(%rdi), %rcx
leaq 0x8(%rcx), %rdx
xorl %r8d, %r8d
cmpl $0x0, (%rcx)
cmoveq %rdx, %r8
movq %r8, 0x8(%rsp)
movl $0x3, %r13d
testq %rax, %rax
je 0x18271
movl %r13d, %eax
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2888(%rsi), %r12
xorl %r13d, %r13d
testq %r12, %r12
je 0x1825c
cmpq $0x0, 0x8(%r12)
je 0x1825c
movq %rdi, 0x10(%rsp)
movq 0x58(%r12), %rbx
movq 0x5f8(%rbx), %rcx
leaq 0x1(%rcx), %r13
leaq 0x2828(%rsi), %rax
movq %rax, 0x20(%rsp)
leaq 0x1a50(%rsi), %rax
movq %rax, 0x28(%rsp)
addq $0x20, %rsi
movq %rsi, 0x18(%rsp)
leaq 0x38(%rsp), %r15
movq %rcx, 0x30(%rsp)
movq %rcx, %rax
cmpq 0x8(%r12), %r13
jl 0x182de
testq %rax, %rax
je 0x18387
xorl %r13d, %r13d
movq (%r12), %rax
movq (%rax,%r13,8), %rsi
movq %r15, %rdi
callq 0x11fee
cmpq $0x0, 0x38(%rsp)
movl $0x4, %eax
js 0x18370
cmpq $0x0, 0x40(%rsp)
js 0x18370
movq %r12, %rdi
callq 0x11c40
movq %rax, %rbp
movq %r15, %r14
movq %r15, (%rsp)
movq 0x20(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x18(%rsp), %rcx
movl $0x1, %r8d
movq %rax, %r9
callq 0x13bb9
movq %rax, %r15
movq %rbp, %rdi
callq 0xd090
testq %r15, %r15
je 0x1836b
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x1f11e
testq %rax, %rax
je 0x1835d
movq %r13, 0x30(%rax)
movq %r13, 0x5f8(%rbx)
movl $0x2, %eax
jmp 0x1836d
xorl %eax, %eax
movq %r14, %r15
testb $0x3, %al
jne 0x18387
incq %r13
movq 0x5f8(%rbx), %rax
cmpq %rax, %r13
jne 0x182cb
xorl %r13d, %r13d
movq 0x30(%rsp), %rax
cmpq %rax, 0x5f8(%rbx)
jne 0x1825c
movq %rax, %r14
cmpq 0x8(%r12), %rax
jge 0x1825c
movq (%r12), %rax
movq (%rax,%r14,8), %rsi
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0x11fee
cmpq $0x0, (%rbx)
js 0x1825c
cmpq $0x0, 0x40(%rsp)
js 0x1825c
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x1f11e
testq %rax, %rax
je 0x183eb
movq %r14, 0x30(%rax)
movq %r12, %rdi
callq 0x11c40
movq %rax, %r15
movq %rbx, (%rsp)
movq 0x20(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x18(%rsp), %rcx
movl $0x1, %r8d
movq %rax, %r9
callq 0x13bb9
movq %r15, %rdi
callq 0xd090
jmp 0x1825c