// File: /workspace/github_cpp_makefile_star2_O2/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 $0x68, %rsp
movq %rdx, 0x28(%rsp)
movq %rdi, %r15
movq (%rsi), %rcx
movq %rsi, 0x8(%rsp)
movq 0x8(%rsi), %rsi
cmpq %rsi, %rcx
je 0x2591b
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x20(%rax), %rax
subq %rdi, %rax
pushq $0x18
popq %r8
cqto
idivq %r8
movq 0x28(%r15), %rdx
subq 0x20(%r15), %rdx
sarq $0x3, %rdx
cmpq %rdx, %rax
jne 0x25b68
cmpq %rsi, %rcx
je 0x257d8
movq (%rcx), %rax
movq (%rax), %r9
movq 0x20(%r15), %rax
movq 0x28(%r15), %r8
movq %r8, %r10
subq %rax, %r10
movq %r10, %r11
sarq $0x5, %r11
movq %rax, %rdx
testq %r11, %r11
jle 0x25761
cmpq %r9, (%rdx)
je 0x257a6
cmpq %r9, 0x8(%rdx)
je 0x25796
cmpq %r9, 0x10(%rdx)
je 0x2579c
cmpq %r9, 0x18(%rdx)
je 0x257a2
addq $0x20, %rdx
decq %r11
addq $-0x20, %r10
jmp 0x25738
sarq $0x3, %r10
cmpq $0x1, %r10
je 0x2578d
cmpq $0x2, %r10
je 0x25784
cmpq $0x3, %r10
jne 0x25b2e
cmpq %r9, (%rdx)
je 0x257a6
addq $0x8, %rdx
cmpq %r9, (%rdx)
je 0x257a6
addq $0x8, %rdx
cmpq %r9, (%rdx)
cmovneq %r8, %rdx
jmp 0x257a6
addq $0x8, %rdx
jmp 0x257a6
addq $0x10, %rdx
jmp 0x257a6
addq $0x18, %rdx
cmpq %r8, %rdx
je 0x25b2e
subq %rax, %rdx
shrq $0x3, %rdx
movslq %edx, %rax
imulq $0x18, %rax, %rax
movq (%rdi,%rax), %rdx
cmpq %rdx, 0x8(%rdi,%rax)
je 0x257cf
addq %rdi, %rax
movq %rdx, 0x8(%rax)
addq $0x8, %rcx
jmp 0x25711
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq 0x8(%rax), %rax
movq %rax, 0x18(%rsp)
leaq 0xb0(%r15), %rax
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %r13
cmpq 0x18(%rsp), %rdi
je 0x25acc
movq (%rdi), %rax
movq (%rax), %rbx
movq 0x20(%r15), %rax
movq 0x28(%r15), %rcx
movq %rcx, %rdx
subq %rax, %rdx
movq %rdx, %rsi
sarq $0x5, %rsi
movq %rax, %r12
testq %rsi, %rsi
jle 0x25850
cmpq %rbx, (%r12)
je 0x25898
cmpq %rbx, 0x8(%r12)
je 0x25888
cmpq %rbx, 0x10(%r12)
je 0x2588e
cmpq %rbx, 0x18(%r12)
je 0x25894
addq $0x20, %r12
decq %rsi
addq $-0x20, %rdx
jmp 0x25823
sarq $0x3, %rdx
cmpq $0x1, %rdx
je 0x2587e
cmpq $0x2, %rdx
je 0x25874
cmpq $0x3, %rdx
jne 0x25b3e
cmpq %rbx, (%r12)
je 0x25898
addq $0x8, %r12
cmpq %rbx, (%r12)
je 0x25898
addq $0x8, %r12
cmpq %rbx, (%r12)
cmovneq %rcx, %r12
jmp 0x25898
addq $0x8, %r12
jmp 0x25898
addq $0x10, %r12
jmp 0x25898
addq $0x18, %r12
cmpq %rcx, %r12
je 0x25b3e
subq %rax, %r12
movq (%r15), %rax
movq %r15, %rbp
leaq 0x50(%rsp), %r15
movq %rdi, 0x20(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq *0x28(%rax)
movq %r12, %r14
shlq $0x1d, %r14
shrq $0x3, %r12
movslq %r12d, %rax
imulq $0x18, %rax, %rdi
addq 0x18(%r13), %rdi
movq %r15, %rsi
callq 0x18466
movq %r15, %rdi
callq 0x990e
movl (%rbx), %eax
movl %eax, 0x50(%rsp)
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %rbp, %r15
callq 0x2769a
movq 0x20(%rsp), %rdi
movl (%rax), %eax
movq 0x48(%r13), %rcx
sarq $0x1e, %r14
movl %eax, (%rcx,%r14)
addq $0x8, %rdi
jmp 0x257fa
xorps %xmm0, %xmm0
leaq 0x50(%rsp), %rbx
andq $0x0, 0x10(%rbx)
movaps %xmm0, (%rbx)
movq 0x8(%rsp), %rax
leaq 0x48(%rax), %rbp
xorl %r12d, %r12d
leaq 0x30(%rsp), %r13
movq 0x28(%r15), %rax
subq 0x20(%r15), %rax
sarq $0x3, %rax
cmpq %r12, %rax
jbe 0x25983
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x15146
movq %r13, %rdi
callq 0x990e
andl $0x0, 0x30(%rsp)
movq %rbp, %rdi
movq %r13, %rsi
callq 0x1d402
incq %r12
jmp 0x2593c
movq 0x28(%rsp), %rax
movq (%rax), %r13
movq 0x8(%rax), %rax
movq %rax, 0x20(%rsp)
leaq 0xb0(%r15), %rax
movq %rax, 0x18(%rsp)
leaq 0x30(%rsp), %r14
movq %rbp, 0x10(%rsp)
cmpq 0x20(%rsp), %r13
je 0x25aa6
movq (%r13), %rbx
movq 0x20(%r15), %r12
movq 0x28(%r15), %rbp
movq %rbp, %rcx
subq %r12, %rcx
movq %rcx, %rdx
sarq $0x5, %rdx
movq %r12, %rax
testq %rdx, %rdx
jle 0x259fa
cmpq %rbx, (%rax)
je 0x25a3b
cmpq %rbx, 0x8(%rax)
je 0x25a2b
cmpq %rbx, 0x10(%rax)
je 0x25a31
cmpq %rbx, 0x18(%rax)
je 0x25a37
addq $0x20, %rax
decq %rdx
addq $-0x20, %rcx
jmp 0x259d1
sarq $0x3, %rcx
cmpq $0x1, %rcx
je 0x25a22
cmpq $0x2, %rcx
je 0x25a19
cmpq $0x3, %rcx
jne 0x25a3e
cmpq %rbx, (%rax)
je 0x25a3b
addq $0x8, %rax
cmpq %rbx, (%rax)
je 0x25a3b
addq $0x8, %rax
cmpq %rbx, (%rax)
cmoveq %rax, %rbp
jmp 0x25a3e
addq $0x8, %rax
jmp 0x25a3b
addq $0x10, %rax
jmp 0x25a3b
addq $0x18, %rax
movq %rax, %rbp
movq (%r15), %rax
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq 0x8(%rsp), %rcx
callq *0x28(%rax)
subq %r12, %rbp
shrq $0x3, %rbp
movslq %ebp, %r12
imulq $0x18, %r12, %rdi
addq 0x50(%rsp), %rdi
movq %r14, %rsi
callq 0x18466
movq %r14, %rdi
callq 0x990e
movl (%rbx), %eax
movl %eax, 0x30(%rsp)
movq 0x18(%rsp), %rdi
movq %r14, %rbx
movq %r14, %rsi
callq 0x2769a
movl (%rax), %eax
movq 0x10(%rsp), %rbp
movq (%rbp), %rcx
movl %eax, (%rcx,%r12,4)
addq $0x8, %r13
movq %rbx, %r14
jmp 0x259aa
movq 0x8(%rsp), %rax
leaq 0x18(%rax), %rdi
leaq 0x50(%rsp), %rsi
callq 0x22858
movq 0x8(%rsp), %rax
andl $0x0, 0x60(%rax)
leaq 0x50(%rsp), %rdi
callq 0x92ec
movq 0x8(%rsp), %rcx
movq 0x48(%rcx), %rax
movq 0x50(%rcx), %rcx
movq 0x8(%rsp), %rsi
cmpq %rcx, %rax
je 0x25aee
movl (%rax), %edx
addl %edx, 0x60(%rsi)
addq $0x4, %rax
jmp 0x25ade
movq 0x8(%rsp), %rax
cmpb $0x0, 0x40(%rax)
je 0x25b1f
movq %r15, %rdi
movq 0x8(%rsp), %r14
movq %r14, %rsi
movq 0x28(%rsp), %rbx
movq %rbx, %rdx
callq 0x2074e
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x20880
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x34463(%rip), %rdi     # 0x59f98
leaq 0x16a03(%rip), %rsi     # 0x3c53f
jmp 0x25b4c
movq 0x34453(%rip), %rdi     # 0x59f98
leaq 0x16a19(%rip), %rsi     # 0x3c565
callq 0x63a0
leaq 0x14a0b(%rip), %rsi     # 0x3a563
movq %rax, %rdi
callq 0x63a0
pushq $0x1
popq %rdi
callq 0x6450
movq 0x34429(%rip), %rdi     # 0x59f98
leaq 0x16988(%rip), %rsi     # 0x3c4fe
callq 0x63a0
leaq 0x16990(%rip), %rsi     # 0x3c512
movq %rax, %rdi
jmp 0x25b4c
jmp 0x25b8d
jmp 0x25b8d
jmp 0x25b8d
movq %rax, %rbx
jmp 0x25b9f
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x990e
leaq 0x50(%rsp), %rdi
callq 0x92ec
movq %rbx, %rdi
callq 0x6650
nop