// File: /workspace/github_cpp_makefile_star2_O3/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 0x2ddf6
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 0x2e0d2
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
testq %r11, %r11
jle 0x2dbf0
andq $-0x20, %r10
movq %r10, %r9
addq %rsi, %r9
incq %r11
leaq 0x10(%rsi), %r10
cmpq %r8, -0x10(%r10)
je 0x2dc2b
cmpq %r8, -0x8(%r10)
je 0x2dc31
cmpq %r8, (%r10)
je 0x2dc3b
cmpq %r8, 0x8(%r10)
je 0x2dc37
decq %r11
addq $0x20, %r10
cmpq $0x1, %r11
jg 0x2dbc4
movq %rdi, %r10
subq %r9, %r10
jmp 0x2dbf3
movq %rsi, %r9
sarq $0x3, %r10
cmpq $0x1, %r10
je 0x2dc1f
cmpq $0x2, %r10
je 0x2dc16
cmpq $0x3, %r10
jne 0x2e07e
cmpq %r8, (%r9)
je 0x2dc26
addq $0x8, %r9
cmpq %r8, (%r9)
je 0x2dc26
addq $0x8, %r9
cmpq %r8, (%r9)
cmovneq %rdi, %r9
movq %r9, %r10
jmp 0x2dc3b
addq $-0x10, %r10
jmp 0x2dc3b
addq $-0x8, %r10
jmp 0x2dc3b
addq $0x8, %r10
cmpq %rdi, %r10
je 0x2e07e
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 0x2dc65
leaq (%rdx,%rdi,8), %rdi
movq %rsi, 0x8(%rdi)
addq $0x8, %rax
cmpq %rcx, %rax
jne 0x2db93
movq (%r14), %rbx
movq 0x8(%r14), %r13
cmpq %r13, %rbx
je 0x2e027
leaq 0xb0(%r15), %rax
movq %rax, 0x40(%rsp)
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
testq %rsi, %rsi
jle 0x2dcef
andq $-0x20, %rdi
movq %rdi, %rdx
addq %rax, %rdx
incq %rsi
leaq 0x10(%rax), %r12
cmpq %rbp, -0x10(%r12)
je 0x2dd2a
cmpq %rbp, -0x8(%r12)
je 0x2dd30
cmpq %rbp, (%r12)
je 0x2dd3a
cmpq %rbp, 0x8(%r12)
je 0x2dd36
decq %rsi
addq $0x20, %r12
cmpq $0x1, %rsi
jg 0x2dcbf
movq %rcx, %rdi
subq %rdx, %rdi
jmp 0x2dcf2
movq %rax, %rdx
sarq $0x3, %rdi
cmpq $0x1, %rdi
je 0x2dd1e
cmpq $0x2, %rdi
je 0x2dd15
cmpq $0x3, %rdi
jne 0x2e08e
cmpq %rbp, (%rdx)
je 0x2dd25
addq $0x8, %rdx
cmpq %rbp, (%rdx)
je 0x2dd25
addq $0x8, %rdx
cmpq %rbp, (%rdx)
cmovneq %rcx, %rdx
movq %rdx, %r12
jmp 0x2dd3a
addq $-0x10, %r12
jmp 0x2dd3a
addq $-0x8, %r12
jmp 0x2dd3a
addq $0x8, %r12
cmpq %rcx, %r12
je 0x2e08e
subq %rax, %r12
movq (%r15), %rax
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq *0x28(%rax)
shrq $0x3, %r12
movslq %r12d, %r12
movq 0x18(%r14), %rax
leaq (%r12,%r12,2), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x10(%rax,%rcx,8), %rsi
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rax,%rcx,8)
movq 0x30(%rsp), %rdx
movq %rdx, 0x10(%rax,%rcx,8)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
testq %rdi, %rdi
je 0x2ddba
subq %rdi, %rsi
callq 0x6380
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x2ddba
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movl (%rbp), %eax
movl %eax, 0x20(%rsp)
movq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x3023a
testq %rax, %rax
je 0x2e0ba
movl 0xc(%rax), %eax
movq 0x48(%r14), %rcx
movl %eax, (%rcx,%r12,4)
addq $0x8, %rbx
cmpq %r13, %rbx
jne 0x2dc8e
jmp 0x2e027
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x28(%r15), %rax
cmpq 0x20(%r15), %rax
je 0x2de90
leaq 0x48(%r14), %r12
xorl %ebx, %ebx
leaq 0x20(%rsp), %r13
movq %rsp, %rbp
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x18c56
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x2de50
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movl $0x0, (%rsp)
movq 0x50(%r14), %rsi
cmpq 0x58(%r14), %rsi
je 0x2de71
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x50(%r14)
jmp 0x2de7c
movq %r12, %rdi
movq %rbp, %rdx
callq 0x23392
incq %rbx
movq 0x28(%r15), %rax
subq 0x20(%r15), %rax
sarq $0x3, %rax
cmpq %rbx, %rax
ja 0x2de1f
movq 0x48(%rsp), %rax
movq (%rax), %rbx
movq 0x8(%rax), %rax
movq %rax, 0x40(%rsp)
cmpq %rax, %rbx
je 0x2e007
leaq 0xb0(%r15), %rax
movq %rax, 0x50(%rsp)
movq (%rbx), %rbp
movq 0x20(%r15), %r12
movq 0x28(%r15), %rax
movq %rax, %rsi
subq %r12, %rsi
movq %rsi, %rdx
sarq $0x5, %rdx
testq %rdx, %rdx
jle 0x2df12
andq $-0x20, %rsi
movq %rsi, %rcx
addq %r12, %rcx
incq %rdx
leaq 0x10(%r12), %r13
cmpq %rbp, -0x10(%r13)
je 0x2df49
cmpq %rbp, -0x8(%r13)
je 0x2df4f
cmpq %rbp, (%r13)
je 0x2df5e
cmpq %rbp, 0x8(%r13)
je 0x2df5a
decq %rdx
addq $0x20, %r13
cmpq $0x1, %rdx
jg 0x2dee5
movq %rax, %rsi
subq %rcx, %rsi
jmp 0x2df15
movq %r12, %rcx
sarq $0x3, %rsi
cmpq $0x1, %rsi
je 0x2df3d
cmpq $0x2, %rsi
je 0x2df34
cmpq $0x3, %rsi
jne 0x2df44
cmpq %rbp, (%rcx)
je 0x2df55
addq $0x8, %rcx
cmpq %rbp, (%rcx)
je 0x2df55
addq $0x8, %rcx
cmpq %rbp, (%rcx)
cmoveq %rcx, %rax
movq %rax, %r13
jmp 0x2df5e
addq $-0x10, %r13
jmp 0x2df5e
addq $-0x8, %r13
jmp 0x2df5e
movq %rcx, %r13
jmp 0x2df5e
addq $0x8, %r13
movq (%r15), %rax
movq %rsp, %rdi
movq %r15, %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq *0x28(%rax)
subq %r12, %r13
shrq $0x3, %r13
movslq %r13d, %r12
movq 0x20(%rsp), %rax
leaq (%r12,%r12,2), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x10(%rax,%rcx,8), %rsi
movaps (%rsp), %xmm0
movups %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rdx
movq %rdx, 0x10(%rax,%rcx,8)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
testq %rdi, %rdi
je 0x2dfd1
subq %rdi, %rsi
callq 0x6380
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x2dfd1
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movl (%rbp), %eax
movl %eax, (%rsp)
movq 0x50(%rsp), %rdi
movq %rsp, %rsi
callq 0x3023a
testq %rax, %rax
je 0x2e0c6
movl 0xc(%rax), %eax
movq 0x48(%r14), %rcx
movl %eax, (%rcx,%r12,4)
addq $0x8, %rbx
cmpq 0x40(%rsp), %rbx
jne 0x2deb6
leaq 0x18(%r14), %rdi
leaq 0x20(%rsp), %rsi
callq 0x2ab9c
movl $0x0, 0x60(%r14)
leaq 0x20(%rsp), %rdi
callq 0xb508
movq 0x48(%r14), %rax
movq 0x50(%r14), %rcx
cmpq %rcx, %rax
je 0x2e047
movl 0x60(%r14), %edx
addl (%rax), %edx
movl %edx, 0x60(%r14)
addq $0x4, %rax
cmpq %rcx, %rax
jne 0x2e038
cmpb $0x0, 0x40(%r14)
je 0x2e06f
movq %r15, %rdi
movq %r14, %rsi
movq 0x48(%rsp), %rbx
movq %rbx, %rdx
callq 0x27adc
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x27c5a
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x33f23(%rip), %rdi     # 0x61fa8
leaq 0x1c403(%rip), %rsi     # 0x4a48f
jmp 0x2e09c
movq 0x33f13(%rip), %rdi     # 0x61fa8
leaq 0x1c419(%rip), %rsi     # 0x4a4b5
callq 0x6360
leaq 0x1a4bb(%rip), %rsi     # 0x48563
movq %rax, %rdi
callq 0x6360
movl $0x1, %edi
callq 0x6440
leaq 0x1c45a(%rip), %rdi     # 0x4a51b
callq 0x6520
leaq 0x1c44e(%rip), %rdi     # 0x4a51b
callq 0x6520
movq 0x33ecf(%rip), %rdi     # 0x61fa8
leaq 0x1c36e(%rip), %rsi     # 0x4a44e
callq 0x6360
leaq 0x1c376(%rip), %rsi     # 0x4a462
movq %rax, %rdi
jmp 0x2e09c
jmp 0x2e0f9
jmp 0x2e0f9
jmp 0x2e0f9
jmp 0x2e0f9
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xb508
movq %rbx, %rdi
callq 0x6620
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x2e0fc
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x2e0fc
nop