// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
movq %rdi, %r15
movq (%rsi), %rax
movq 0x8(%rsi), %rcx
cmpq %rcx, %rax
movq %rdx, 0x40(%rsp)
je 0x279a0
movq 0x18(%r14), %rdx
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 0x2781b
andq $-0x20, %r10
movq %r10, %r9
addq %rsi, %r9
incq %r11
leaq 0x10(%rsi), %r10
cmpq %r8, -0x10(%r10)
je 0x27855
cmpq %r8, -0x8(%r10)
je 0x2785b
cmpq %r8, (%r10)
je 0x2786a
cmpq %r8, 0x8(%r10)
je 0x27866
decq %r11
addq $0x20, %r10
cmpq $0x1, %r11
jg 0x277f7
movq %rdi, %r10
subq %r9, %r10
sarq $0x3, %r10
cmpq $0x1, %r10
je 0x27849
cmpq $0x2, %r10
je 0x27840
cmpq $0x3, %r10
jne 0x27850
cmpq %r8, (%r9)
je 0x27861
addq $0x8, %r9
cmpq %r8, (%r9)
je 0x27861
addq $0x8, %r9
cmpq %r8, (%r9)
cmoveq %r9, %rdi
movq %rdi, %r10
jmp 0x2786a
addq $-0x10, %r10
jmp 0x2786a
addq $-0x8, %r10
jmp 0x2786a
movq %r9, %r10
jmp 0x2786a
addq $0x8, %r10
subq %rsi, %r10
shrq $0x3, %r10
leaq (%r10,%r10,2), %rdi
movq (%rdx,%rdi,8), %rsi
cmpq %rsi, 0x8(%rdx,%rdi,8)
je 0x27888
leaq (%rdx,%rdi,8), %rdi
movq %rsi, 0x8(%rdi)
addq $0x8, %rax
cmpq %rcx, %rax
jne 0x277c3
movq (%r14), %r13
movq 0x8(%r14), %rbp
cmpq %rbp, %r13
je 0x27b27
leaq 0x20(%rsp), %r12
movq (%r13), %rax
movq (%rax), %rdx
movq 0x20(%r15), %rbx
movq 0x28(%r15), %rax
movq %rax, %rcx
subq %rbx, %rcx
movq %rcx, %rsi
sarq $0x5, %rsi
testq %rsi, %rsi
jle 0x27900
andq $-0x20, %rcx
addq %rbx, %rcx
incq %rsi
addq $0x10, %rbx
cmpq %rdx, -0x10(%rbx)
je 0x27937
cmpq %rdx, -0x8(%rbx)
je 0x2793d
cmpq %rdx, (%rbx)
je 0x2794c
cmpq %rdx, 0x8(%rbx)
je 0x27948
decq %rsi
addq $0x20, %rbx
cmpq $0x1, %rsi
jg 0x278d9
movq %rcx, %rbx
movq %rax, %rcx
subq %rbx, %rcx
sarq $0x3, %rcx
cmpq $0x1, %rcx
je 0x2792e
cmpq $0x2, %rcx
je 0x27925
cmpq $0x3, %rcx
jne 0x27943
cmpq %rdx, (%rbx)
je 0x2794c
addq $0x8, %rbx
cmpq %rdx, (%rbx)
je 0x2794c
addq $0x8, %rbx
cmpq %rdx, (%rbx)
cmovneq %rax, %rbx
jmp 0x2794c
addq $-0x10, %rbx
jmp 0x2794c
addq $-0x8, %rbx
jmp 0x2794c
movq %rax, %rbx
jmp 0x2794c
addq $0x8, %rbx
movq (%r15), %rax
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rcx
callq *0x28(%rax)
subq 0x20(%r15), %rbx
shrq $0x3, %rbx
leaq (%rbx,%rbx,2), %rdi
shlq $0x3, %rdi
addq 0x18(%r14), %rdi
movq %r12, %rsi
callq 0x21552
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x2798e
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x8, %r13
cmpq %rbp, %r13
jne 0x278aa
jmp 0x27b27
movq %rdx, %rbp
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x28(%r15), %rax
cmpq 0x20(%r15), %rax
je 0x27a0d
xorl %ebx, %ebx
leaq 0x20(%rsp), %r12
movq %rsp, %r13
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x18be6
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x279f9
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
incq %rbx
movq 0x28(%r15), %rax
subq 0x20(%r15), %rax
sarq $0x3, %rax
cmpq %rbx, %rax
ja 0x279c8
movq (%rbp), %r13
movq 0x8(%rbp), %rbp
cmpq %rbp, %r13
je 0x27b0f
movq %rsp, %r12
movq (%r13), %rdx
movq 0x20(%r15), %rbx
movq 0x28(%r15), %rax
movq %rax, %rcx
subq %rbx, %rcx
movq %rcx, %rsi
sarq $0x5, %rsi
testq %rsi, %rsi
jle 0x27a74
andq $-0x20, %rcx
addq %rbx, %rcx
incq %rsi
addq $0x10, %rbx
cmpq %rdx, -0x10(%rbx)
je 0x27aab
cmpq %rdx, -0x8(%rbx)
je 0x27ab1
cmpq %rdx, (%rbx)
je 0x27ac0
cmpq %rdx, 0x8(%rbx)
je 0x27abc
decq %rsi
addq $0x20, %rbx
cmpq $0x1, %rsi
jg 0x27a4d
movq %rcx, %rbx
movq %rax, %rcx
subq %rbx, %rcx
sarq $0x3, %rcx
cmpq $0x1, %rcx
je 0x27aa2
cmpq $0x2, %rcx
je 0x27a99
cmpq $0x3, %rcx
jne 0x27ab7
cmpq %rdx, (%rbx)
je 0x27ac0
addq $0x8, %rbx
cmpq %rdx, (%rbx)
je 0x27ac0
addq $0x8, %rbx
cmpq %rdx, (%rbx)
cmovneq %rax, %rbx
jmp 0x27ac0
addq $-0x10, %rbx
jmp 0x27ac0
addq $-0x8, %rbx
jmp 0x27ac0
movq %rax, %rbx
jmp 0x27ac0
addq $0x8, %rbx
movq (%r15), %rax
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rcx
callq *0x28(%rax)
subq 0x20(%r15), %rbx
shrq $0x3, %rbx
leaq (%rbx,%rbx,2), %rdi
shlq $0x3, %rdi
addq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x21552
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x27b02
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x8, %r13
cmpq %rbp, %r13
jne 0x27a21
leaq 0x18(%r14), %rdi
leaq 0x20(%rsp), %rsi
callq 0x2ac96
leaq 0x20(%rsp), %rdi
callq 0xb4ce
cmpb $0x1, 0x40(%r14)
jne 0x27b4f
movq %r15, %rdi
movq %r14, %rsi
movq 0x40(%rsp), %rbx
movq %rbx, %rdx
callq 0x27b90
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x27d08
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x27b60
movq %rax, %rbx
jmp 0x27b7e
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x27b7e
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
leaq 0x20(%rsp), %rdi
callq 0xb4ce
movq %rbx, %rdi
callq 0x6620