// File: Kei18[P]pibt/./src/solver/winpibt.cpp
// Function: winPIBT::solve()
bool winPIBT::solve() {
  solveStart();

  int t = 0;
  int t_sup = 0;
  int i, _w;

  while (!P->isSolved()) {
    allocate();
    updatePriority();
    std::vector<int> U(A.size());
    std::iota(U.begin(), U.end(), 0);
    std::sort(U.begin(), U.end(),
              [this] (int i, int j)
              {return this->priority[i] > this->priority[j];} );

    for (int j = 0; j < U.size(); ++j) {
      i = U[j];
      if (ell(i) <= t) {

        if (A[i]->hasTask()) {
          _w = w;
        } else {
          _w = 1;
        }

        if (j == 0) {
          winpibt(A[i], t + _w, softmode);
        } else {
          winpibt(A[i], std::min(t + _w, t_sup), softmode);
        }
      }

      if (j == 0) {
        t_sup = ell(i);
      } else {
        t_sup = std::min(t_sup, ell(i));
      }
    }

    // update path
    for (int i = 0; i < A.size(); ++i) A[i]->setNode(PATHS[i][t+1]);

    P->update();
    if (P->getTimestep() >= P->getTimestepLimit()) break;

    ++t;
  }

  solveEnd();
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x90(%rbp)
movq (%rdi), %rax
callq *(%rax)
movl $0x0, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movq -0x90(%rbp), %rax
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
xorb $-0x1, %al
testb $0x1, %al
jne 0xad409
jmp 0xad80f
movq -0x90(%rbp), %rdi
callq 0xad840
movq -0x90(%rbp), %rdi
callq 0xada50
movq -0x90(%rbp), %rdi
addq $0x20, %rdi
callq 0x383b0
movq %rax, -0xa0(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x4e8c0
movq -0xa0(%rbp), %rsi
movq -0x98(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0xb1120
jmp 0xad461
leaq -0x31(%rbp), %rdi
callq 0x4e9c0
leaq -0x30(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x4f9b0
movq -0xa8(%rbp), %rdi
movq %rax, -0x50(%rbp)
callq 0x4f840
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
xorl %edx, %edx
callq 0xb1190
jmp 0xad49f
leaq -0x30(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x4f9b0
movq -0xb0(%rbp), %rdi
movq %rax, -0x60(%rbp)
callq 0x4f840
movq %rax, %rcx
movq -0x90(%rbp), %rax
movq %rcx, -0x68(%rbp)
movq %rax, -0x70(%rbp)
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x70(%rbp), %rdx
callq 0xadbe0
jmp 0xad4e4
movl $0x0, -0x74(%rbp)
movslq -0x74(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4fab0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
cmpq %rcx, %rax
jae 0xad6ea
movslq -0x74(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x4ea00
movq -0x90(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %esi
callq 0xadc30
movl %eax, -0xbc(%rbp)
jmp 0xad53b
movl -0xbc(%rbp), %eax
cmpl -0xc(%rbp), %eax
jg 0xad670
movq -0x90(%rbp), %rdi
addq $0x20, %rdi
movslq -0x14(%rbp), %rsi
callq 0x53720
movq (%rax), %rdi
callq 0x3ae30
movb %al, -0xbd(%rbp)
jmp 0xad56e
movb -0xbd(%rbp), %al
testb $0x1, %al
jne 0xad57a
jmp 0xad5bd
movq -0x90(%rbp), %rax
movl 0x68(%rax), %eax
movl %eax, -0x18(%rbp)
jmp 0xad5c4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x4e9c0
jmp 0xad829
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4e960
jmp 0xad829
movl $0x1, -0x18(%rbp)
cmpl $0x0, -0x74(%rbp)
jne 0xad604
movq -0x90(%rbp), %rdi
addq $0x20, %rdi
movslq -0x14(%rbp), %rsi
callq 0x53720
movq -0x90(%rbp), %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %edx
movl -0x18(%rbp), %eax
addl %eax, %edx
movq (%rdi), %rax
movq 0x20(%rax), %rax
movzbl 0x6c(%rdi), %ecx
andl $0x1, %ecx
callq *%rax
jmp 0xad602
jmp 0xad66e
movq -0x90(%rbp), %rdi
addq $0x20, %rdi
movslq -0x14(%rbp), %rsi
callq 0x53720
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
movl -0xc(%rbp), %eax
movl -0x18(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x78(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0xac5b0
movq %rax, -0xc8(%rbp)
jmp 0xad643
movq -0xd0(%rbp), %rsi
movq -0x90(%rbp), %rdi
movq -0xc8(%rbp), %rax
movl (%rax), %edx
movq (%rdi), %rax
movq 0x20(%rax), %rax
movzbl 0x6c(%rdi), %ecx
andl $0x1, %ecx
callq *%rax
jmp 0xad66c
jmp 0xad66e
jmp 0xad670
cmpl $0x0, -0x74(%rbp)
jne 0xad698
movq -0x90(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0xadc30
movl %eax, -0xd4(%rbp)
jmp 0xad68d
movl -0xd4(%rbp), %eax
movl %eax, -0x10(%rbp)
jmp 0xad6da
movq -0x90(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0xadc30
movl %eax, -0xd8(%rbp)
jmp 0xad6af
movl -0xd8(%rbp), %eax
movl %eax, -0x7c(%rbp)
leaq -0x10(%rbp), %rdi
leaq -0x7c(%rbp), %rsi
callq 0xac5b0
movq %rax, -0xe0(%rbp)
jmp 0xad6ce
movq -0xe0(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x10(%rbp)
jmp 0xad6dc
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0xad4eb
movl $0x0, -0x80(%rbp)
movq -0x90(%rbp), %rdi
movslq -0x80(%rbp), %rax
movq %rax, -0xe8(%rbp)
addq $0x20, %rdi
callq 0x383b0
movq %rax, %rcx
movq -0xe8(%rbp), %rax
cmpq %rcx, %rax
jae 0xad77e
movq -0x90(%rbp), %rdi
addq $0x20, %rdi
movslq -0x80(%rbp), %rsi
callq 0x53720
movq -0x90(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0xf0(%rbp)
addq $0x70, %rdi
movslq -0x80(%rbp), %rsi
callq 0xda70
movq %rax, %rdi
movl -0xc(%rbp), %eax
incl %eax
movslq %eax, %rsi
callq 0xda90
movq -0xf0(%rbp), %rdi
movq (%rax), %rsi
callq 0x3a480
jmp 0xad76e
jmp 0xad770
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0xad6f1
movq -0x90(%rbp), %rax
movq 0x10(%rax), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
jmp 0xad794
movq -0x90(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x622f0
movl %eax, -0xf4(%rbp)
jmp 0xad7ac
movq -0x90(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x62310
movl %eax, -0xf8(%rbp)
jmp 0xad7c4
movl -0xf4(%rbp), %eax
movl -0xf8(%rbp), %ecx
cmpl %ecx, %eax
jl 0xad7e0
movl $0x3, -0x84(%rbp)
jmp 0xad7f3
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movl $0x0, -0x84(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4e960
movl -0x84(%rbp), %eax
testl %eax, %eax
je 0xad80a
jmp 0xad808
jmp 0xad80f
jmp 0xad3ed
movq -0x90(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movb $0x1, %al
andb $0x1, %al
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x8880
nopw %cs:(%rax,%rax)