// File: /workspace/github_cpp_makefile_star2_O1/Kei18[P]pibt/./src/solver/ecbs.cpp
// Function: ECBS::invoke(CTNode*, std::vector<Agent*, std::allocator<Agent*>>&)
void ECBS::invoke(CTNode* node, Agents& block) {
  int d;
  // calc path
  if (node->c.empty()) {  // initail
    Paths paths;
    for (int i = 0; i < A.size(); ++i) {
      paths.push_back({});
      node->fmins.push_back(0);
    }
    for (auto a : block) {
      auto itr = std::find_if(A.begin(), A.end(),
                              [a](Agent* b) { return a == b; });
      int d = std::distance(A.begin(), itr);
      paths[d] = AstarSearch(a, node);
      node->fmins[d] = table_fmin.at(a->getId());
    }
    node->paths = paths;
    node->LB = 0;
  } else {
    Agent* a;
    // error check
    if (node->paths.size() != A.size()) {
      std::cout << "error@ECBS@invoke, "
                << "path size is not equal to the size of agents" << "\n";
      std::exit(1);
    }

    for (auto c : node->c) {
      a = c->a;
      auto itr = std::find_if(A.begin(), A.end(),
                              [a](Agent* b) { return a == b; });
      if (itr == A.end()) {
        std::cout << "error@ECBS@invoke, cannot find1 agent" << "\n";
        std::exit(1);
      }
      d = std::distance(A.begin(), itr);
      node->paths[d].clear();
    }

    for (auto c : node->c) {
      a = c->a;
      auto itr = std::find_if(A.begin(), A.end(),
                              [a](Agent* b) { return a == b; });
      if (itr == A.end()) {
        std::cout << "error@ECBS@invoke, cannot find2 agent" << "\n";
        std::exit(1);
      }
      d = std::distance(A.begin(), itr);
      node->paths[d] = AstarSearch(a, node);
      node->fmins[d] = table_fmin.at(a->getId());
    }
  }
  for (auto i : node->fmins) node->LB += i;

  if (!node->valid) return;
  calcCost(node, block);
  formalizePathAgents(node, block);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, 0x48(%rsp)
movq %rsi, %r14
movq %rdi, %r15
movq (%rsi), %rax
movq 0x8(%rsi), %rcx
cmpq %rcx, %rax
je 0x2df95
movq 0x18(%r14), %rdx
movq 0x20(%r14), %rsi
subq %rdx, %rsi
sarq $0x3, %rsi
movabsq $-0x5555555555555555, %rdi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rsi, %rdi
movq 0x28(%r15), %rsi
subq 0x20(%r15), %rsi
sarq $0x3, %rsi
cmpq %rsi, %rdi
jne 0x2e23d
cmpq %rcx, %rax
je 0x2de44
movq (%rax), %rsi
movq (%rsi), %r8
movq 0x20(%r15), %rsi
movq 0x28(%r15), %rdi
movq %rdi, %r10
subq %rsi, %r10
movq %r10, %r11
sarq $0x5, %r11
movq %rsi, %r9
testq %r11, %r11
jle 0x2ddc4
andq $-0x20, %r10
movq %r10, %r9
addq %rsi, %r9
incq %r11
leaq 0x10(%rsi), %r10
cmpq %r8, -0x10(%r10)
je 0x2de01
cmpq %r8, -0x8(%r10)
je 0x2de07
cmpq %r8, (%r10)
je 0x2de11
cmpq %r8, 0x8(%r10)
je 0x2de0d
decq %r11
addq $0x20, %r10
cmpq $0x1, %r11
jg 0x2dda0
movq %rdi, %r11
subq %r9, %r11
sarq $0x3, %r11
cmpq $0x1, %r11
je 0x2ddf5
cmpq $0x2, %r11
je 0x2ddec
movq %rdi, %r10
cmpq $0x3, %r11
jne 0x2de11
cmpq %r8, (%r9)
je 0x2ddfc
addq $0x8, %r9
cmpq %r8, (%r9)
je 0x2ddfc
addq $0x8, %r9
cmpq %r8, (%r9)
cmovneq %rdi, %r9
movq %r9, %r10
jmp 0x2de11
addq $-0x10, %r10
jmp 0x2de11
addq $-0x8, %r10
jmp 0x2de11
addq $0x8, %r10
cmpq %rdi, %r10
je 0x2e201
subq %rsi, %r10
shrq $0x3, %r10
movslq %r10d, %rsi
leaq (%rsi,%rsi,2), %rdi
movq (%rdx,%rdi,8), %rsi
cmpq %rsi, 0x8(%rdx,%rdi,8)
je 0x2de3b
leaq (%rdx,%rdi,8), %rdi
movq %rsi, 0x8(%rdi)
addq $0x8, %rax
jmp 0x2dd63
movq (%r14), %rbx
movq 0x8(%r14), %rax
movq %rax, 0x8(%rsp)
cmpq %rax, %rbx
je 0x2e1aa
leaq 0xb0(%r15), %rax
movq %rax, 0x28(%rsp)
leaq 0x30(%rsp), %r13
movq (%rbx), %rax
movq (%rax), %rbp
movq 0x20(%r15), %rax
movq 0x28(%r15), %rcx
movq %rcx, %rdi
subq %rax, %rdi
movq %rdi, %rsi
sarq $0x5, %rsi
movq %rax, %rdx
testq %rsi, %rsi
jle 0x2dec6
andq $-0x20, %rdi
movq %rdi, %rdx
addq %rax, %rdx
incq %rsi
leaq 0x10(%rax), %r12
cmpq %rbp, -0x10(%r12)
je 0x2df03
cmpq %rbp, -0x8(%r12)
je 0x2df09
cmpq %rbp, (%r12)
je 0x2df13
cmpq %rbp, 0x8(%r12)
je 0x2df0f
decq %rsi
addq $0x20, %r12
cmpq $0x1, %rsi
jg 0x2de9e
movq %rcx, %rsi
subq %rdx, %rsi
sarq $0x3, %rsi
cmpq $0x1, %rsi
je 0x2def7
cmpq $0x2, %rsi
je 0x2deee
movq %rcx, %r12
cmpq $0x3, %rsi
jne 0x2df13
cmpq %rbp, (%rdx)
je 0x2defe
addq $0x8, %rdx
cmpq %rbp, (%rdx)
je 0x2defe
addq $0x8, %rdx
cmpq %rbp, (%rdx)
cmovneq %rcx, %rdx
movq %rdx, %r12
jmp 0x2df13
addq $-0x10, %r12
jmp 0x2df13
addq $-0x8, %r12
jmp 0x2df13
addq $0x8, %r12
cmpq %rcx, %r12
je 0x2e211
subq %rax, %r12
movq (%r15), %rax
movq %r13, %rdi
movq %r15, %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq *0x28(%rax)
shrq $0x3, %r12
movslq %r12d, %r12
leaq (%r12,%r12,2), %rdi
shlq $0x3, %rdi
addq 0x18(%r14), %rdi
movq %r13, %rsi
callq 0x21552
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2df63
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movl (%rbp), %eax
movl %eax, 0x30(%rsp)
movq 0x28(%rsp), %rdi
movq %r13, %rsi
callq 0x303b4
movl (%rax), %eax
movq 0x48(%r14), %rcx
movl %eax, (%rcx,%r12,4)
addq $0x8, %rbx
cmpq 0x8(%rsp), %rbx
jne 0x2de6a
jmp 0x2e1aa
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x28(%r15), %rax
cmpq 0x20(%r15), %rax
je 0x2e038
leaq 0x48(%r14), %r12
xorl %ebx, %ebx
leaq 0x30(%rsp), %r13
leaq 0x10(%rsp), %rbp
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x18be6
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2dff7
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movl $0x0, 0x10(%rsp)
movq 0x50(%r14), %rsi
cmpq 0x58(%r14), %rsi
je 0x2e019
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x50(%r14)
jmp 0x2e024
movq %r12, %rdi
movq %rbp, %rdx
callq 0x233f8
incq %rbx
movq 0x28(%r15), %rax
subq 0x20(%r15), %rax
sarq $0x3, %rax
cmpq %rbx, %rax
ja 0x2dfc4
movq 0x48(%rsp), %rax
movq (%rax), %rbx
movq 0x8(%rax), %rax
movq %rax, 0x28(%rsp)
cmpq %rax, %rbx
je 0x2e18a
leaq 0xb0(%r15), %rax
movq %rax, 0x50(%rsp)
movq %r14, 0x8(%rsp)
movq (%rbx), %rbp
movq 0x20(%r15), %r12
movq 0x28(%r15), %rax
movq %rax, %rsi
subq %r12, %rsi
movq %rsi, %rdx
sarq $0x5, %rdx
movq %r12, %rcx
testq %rdx, %rdx
jle 0x2e0ba
andq $-0x20, %rsi
movq %rsi, %rcx
addq %r12, %rcx
incq %rdx
leaq 0x10(%r12), %r13
cmpq %rbp, -0x10(%r13)
je 0x2e0f4
cmpq %rbp, -0x8(%r13)
je 0x2e0fa
cmpq %rbp, (%r13)
je 0x2e109
cmpq %rbp, 0x8(%r13)
je 0x2e105
decq %rdx
addq $0x20, %r13
cmpq $0x1, %rdx
jg 0x2e095
movq %rax, %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rdx
je 0x2e0e8
cmpq $0x2, %rdx
je 0x2e0df
cmpq $0x3, %rdx
jne 0x2e0ef
cmpq %rbp, (%rcx)
je 0x2e100
addq $0x8, %rcx
cmpq %rbp, (%rcx)
je 0x2e100
addq $0x8, %rcx
cmpq %rbp, (%rcx)
cmoveq %rcx, %rax
movq %rax, %r13
jmp 0x2e109
addq $-0x10, %r13
jmp 0x2e109
addq $-0x8, %r13
jmp 0x2e109
movq %rcx, %r13
jmp 0x2e109
addq $0x8, %r13
movq (%r15), %rax
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq %rbp, %rdx
movq 0x8(%rsp), %rcx
callq *0x28(%rax)
subq %r12, %r13
shrq $0x3, %r13
movslq %r13d, %r12
leaq (%r12,%r12,2), %rdi
shlq $0x3, %rdi
addq 0x30(%rsp), %rdi
movq %r14, %rsi
callq 0x21552
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2e158
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movl (%rbp), %eax
movl %eax, 0x10(%rsp)
movq 0x50(%rsp), %rdi
movq %r14, %rsi
callq 0x303b4
movl (%rax), %eax
movq 0x8(%rsp), %r14
movq 0x48(%r14), %rcx
movl %eax, (%rcx,%r12,4)
addq $0x8, %rbx
cmpq 0x28(%rsp), %rbx
jne 0x2e063
leaq 0x18(%r14), %rdi
leaq 0x30(%rsp), %rsi
callq 0x2ac96
movl $0x0, 0x60(%r14)
leaq 0x30(%rsp), %rdi
callq 0xb4ce
movq 0x48(%r14), %rax
movq 0x50(%r14), %rcx
cmpq %rcx, %rax
je 0x2e1ca
movl 0x60(%r14), %edx
addl (%rax), %edx
movl %edx, 0x60(%r14)
addq $0x4, %rax
cmpq %rcx, %rax
jne 0x2e1bb
cmpb $0x0, 0x40(%r14)
je 0x2e1f2
movq %r15, %rdi
movq %r14, %rsi
movq 0x48(%rsp), %rbx
movq %rbx, %rdx
callq 0x27b90
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x27d08
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x33da0(%rip), %rdi     # 0x61fa8
leaq 0x1c240(%rip), %rsi     # 0x4a44f
jmp 0x2e21f
movq 0x33d90(%rip), %rdi     # 0x61fa8
leaq 0x1c256(%rip), %rsi     # 0x4a475
callq 0x6360
leaq 0x1a338(%rip), %rsi     # 0x48563
movq %rax, %rdi
callq 0x6360
movl $0x1, %edi
callq 0x6440
movq 0x33d64(%rip), %rdi     # 0x61fa8
leaq 0x1c1c3(%rip), %rsi     # 0x4a40e
callq 0x6360
leaq 0x1c1cb(%rip), %rsi     # 0x4a422
movq %rax, %rdi
jmp 0x2e21f
jmp 0x2e262
jmp 0x2e262
jmp 0x2e262
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xb4ce
movq %rbx, %rdi
callq 0x6620
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2e265
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x2e265
nop