// File: Kei18[P]pibt/./src/solver/cbs.cpp
// Function: CBS::invoke(CTNode*, std::vector<Agent*, std::allocator<Agent*>>&)
void CBS::invoke(CTNode* node, Agents& block) {
  // calc path
  if (node->c.empty()) {  // initail
    Paths paths;
    for (int i = 0; i < A.size(); ++i) paths.push_back({});
    for (auto a : block) {
      auto itr = std::find_if(A.begin(), A.end(),
                              [a](Agent* b) { return a == b; });
      paths[std::distance(A.begin(), itr)] = AstarSearch(a, node);
    }
    node->paths = paths;
  } else {
    Agent* a;
    for (auto c : node->c) {
      a = c->a;
      auto itr = std::find_if(A.begin(), A.end(),
                              [a](Agent* b) { return a == b; });
      node->paths[std::distance(A.begin(), itr)].clear();
    }
    for (auto c : node->c) {
      a = c->a;
      auto itr = std::find_if(A.begin(), A.end(),
                              [a](Agent* b) { return a == b; });
      node->paths[std::distance(A.begin(), itr)] = AstarSearch(a, node);
    }
  }
  if (!node->valid) return;
  calcCost(node, block);
  formalizePathAgents(node, block);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x190(%rbp)
movq -0x10(%rbp), %rdi
callq 0x62fa0
testb $0x1, %al
jne 0x5a134
jmp 0x5a374
leaq -0x30(%rbp), %rdi
callq 0xd9c0
movl $0x0, -0x34(%rbp)
movq -0x190(%rbp), %rdi
movslq -0x34(%rbp), %rax
movq %rax, -0x198(%rbp)
addq $0x20, %rdi
callq 0x383b0
movq %rax, %rcx
movq -0x198(%rbp), %rax
cmpq %rcx, %rax
jae 0x5a1cd
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
leaq -0x50(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x3e880
movq -0x1a0(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xd700
jmp 0x5a19f
leaq -0x50(%rbp), %rdi
callq 0xd7d0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x5a144
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xd7d0
jmp 0x5a366
movq -0x18(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0x39b60
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rdi
callq 0x399f0
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x51bd0
testb $0x1, %al
jne 0x5a205
jmp 0x5a345
leaq -0x70(%rbp), %rdi
callq 0x51c10
movq -0x190(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x80(%rbp)
addq $0x20, %rdi
movq %rdi, -0x1b0(%rbp)
callq 0x39b60
movq -0x1b0(%rbp), %rdi
movq %rax, -0x90(%rbp)
callq 0x399f0
movq %rax, -0x98(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x90(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq -0xa0(%rbp), %rdx
callq 0x5a6a0
movq %rax, -0x1a8(%rbp)
jmp 0x5a274
movq -0x190(%rbp), %rsi
movq -0x1a8(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq (%rsi), %rax
movq 0x28(%rax), %rax
leaq -0xb8(%rbp), %rdi
callq *%rax
jmp 0x5a2a3
movq -0x190(%rbp), %rdi
addq $0x20, %rdi
callq 0x39b60
movq %rax, -0xc0(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc0(%rbp), %rdi
movq -0xc8(%rbp), %rsi
callq 0x62750
movq %rax, -0x1b8(%rbp)
jmp 0x5a2e4
movq -0x1b8(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xda70
movq %rax, %rdi
leaq -0xb8(%rbp), %rsi
callq 0x3f230
leaq -0xb8(%rbp), %rdi
callq 0xd7d0
leaq -0x70(%rbp), %rdi
callq 0x51c30
jmp 0x5a1ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x5a366
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0xd7d0
jmp 0x5a366
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
leaq -0x30(%rbp), %rsi
callq 0x62fe0
jmp 0x5a358
leaq -0x30(%rbp), %rdi
callq 0xda10
jmp 0x5a651
leaq -0x30(%rbp), %rdi
callq 0xda10
jmp 0x5a68e
movq -0x10(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rdi
callq 0x63230
movq %rax, -0xe0(%rbp)
movq -0xd8(%rbp), %rdi
callq 0x63260
movq %rax, -0xe8(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x63290
testb $0x1, %al
jne 0x5a3c1
jmp 0x5a4b4
leaq -0xe0(%rbp), %rdi
callq 0x632d0
movq -0x190(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
addq $0x20, %rdi
callq 0x39b60
movq -0x190(%rbp), %rdi
movq %rax, -0x100(%rbp)
addq $0x20, %rdi
callq 0x399f0
movq %rax, -0x108(%rbp)
movq -0xd0(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x100(%rbp), %rdi
movq -0x108(%rbp), %rsi
movq -0x110(%rbp), %rdx
callq 0x5a700
movq -0x190(%rbp), %rdi
movq %rax, -0xf8(%rbp)
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x1c0(%rbp)
addq $0x20, %rdi
callq 0x39b60
movq %rax, -0x118(%rbp)
movq -0xf8(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x118(%rbp), %rdi
movq -0x120(%rbp), %rsi
callq 0x62750
movq -0x1c0(%rbp), %rdi
movq %rax, %rsi
callq 0xda70
movq %rax, %rdi
callq 0x3e9f0
leaq -0xe0(%rbp), %rdi
callq 0x632f0
jmp 0x5a3a5
movq -0x10(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rdi
callq 0x63230
movq %rax, -0x130(%rbp)
movq -0x128(%rbp), %rdi
callq 0x63260
movq %rax, -0x138(%rbp)
leaq -0x130(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x63290
testb $0x1, %al
jne 0x5a501
jmp 0x5a64f
leaq -0x130(%rbp), %rdi
callq 0x632d0
movq -0x190(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
addq $0x20, %rdi
movq %rdi, -0x1d8(%rbp)
callq 0x39b60
movq -0x1d8(%rbp), %rdi
movq %rax, -0x150(%rbp)
callq 0x399f0
movq %rax, -0x158(%rbp)
movq -0xd0(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x150(%rbp), %rdi
movq -0x158(%rbp), %rsi
movq -0x160(%rbp), %rdx
callq 0x5a760
movq -0x190(%rbp), %rsi
movq %rax, -0x148(%rbp)
movq -0xd0(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq (%rsi), %rax
movq 0x28(%rax), %rax
leaq -0x178(%rbp), %rdi
callq *%rax
movq -0x1d8(%rbp), %rdi
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x1d0(%rbp)
callq 0x39b60
movq %rax, -0x180(%rbp)
movq -0x148(%rbp), %rax
movq %rax, -0x188(%rbp)
movq -0x180(%rbp), %rdi
movq -0x188(%rbp), %rsi
callq 0x62750
movq %rax, -0x1c8(%rbp)
jmp 0x5a5f6
movq -0x1c8(%rbp), %rsi
movq -0x1d0(%rbp), %rdi
callq 0xda70
movq %rax, %rdi
leaq -0x178(%rbp), %rsi
callq 0x3f230
leaq -0x178(%rbp), %rdi
callq 0xd7d0
leaq -0x130(%rbp), %rdi
callq 0x632f0
jmp 0x5a4e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x178(%rbp), %rdi
callq 0xd7d0
jmp 0x5a68e
jmp 0x5a651
movq -0x10(%rbp), %rax
testb $0x1, 0x40(%rax)
jne 0x5a65d
jmp 0x5a685
movq -0x190(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x5a7c0
movq -0x190(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x5aa20
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x8880
nopw (%rax,%rax)