// File: /workspace/github_cpp_makefile_star2_O3/Kei18[P]pibt/./src/graph/station.cpp
// Function: Station::getRandomStartGoal(int)
Paths Station::getRandomStartGoal(int num) {
  int stNum = stations.size();
  if (std::any_of(stations.begin(), stations.end(),
                  [num, stNum] (Nodes st)
                  { return st.size() * stNum < num; })) {
    std::cout << "error@Station::getStartGoal, over node size" << "\n";
    std::exit(1);
  }

  // preparing shuffled one
  Paths tmpS, tmpG;
  for (auto st : stations) {
    Nodes areaS(st.size()), areaG(st.size());
    std::copy(st.begin(), st.end(), areaS.begin());
    std::copy(st.begin(), st.end(), areaG.begin());
    std::shuffle(areaS.begin(), areaS.end(), *MT);
    std::shuffle(areaG.begin(), areaG.end(), *MT);
    tmpS.push_back(areaS);
    tmpG.push_back(areaG);
  }

  Paths points;
  std::vector<std::vector<int>> indexes;
  std::vector<int> cands;  // choose goal station
  for (int i = 0; i < stNum; ++i) {
    cands.push_back(i);
    indexes.push_back({ 0, 0 });
  }
  int goalSt;

  for (int i = 0; i < num; ++i) {
    // choose start st
    do {
      ++startSt;
      startSt %= stNum;
    } while (indexes[startSt][0] >= stations[startSt].size());

    // choose goal st
    do {
      goalSt = randomChoose(cands, MT);
    } while (goalSt == startSt || indexes[goalSt][1] >= stations[goalSt].size());

    points.push_back({ tmpS[startSt][indexes[startSt][0]],
                       tmpG[goalSt][indexes[goalSt][1]]});
    indexes[startSt][0] += 1;
    indexes[goalSt][1]  += 1;
  }

  return points;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %r14
movq %rdi, 0x78(%rsp)
movq 0xc8(%rsi), %rbx
movq 0xd0(%rsi), %rbp
movq %rbp, 0x10(%rsp)
movq %rbp, %r12
subq %rbx, %r12
movq %r12, %r13
sarq $0x3, %r13
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %r13
movq %r13, %rax
shlq $0x20, %rax
movl %edx, 0x74(%rsp)
movl %edx, %ecx
orq %rax, %rcx
movq %rcx, 0x80(%rsp)
movq %r13, %rax
sarq $0x2, %rax
testq %rax, %rax
jle 0x2079d
incq %rax
leaq 0x80(%rsp), %rbp
movq %rax, 0xd0(%rsp)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x2134a
testb %al, %al
jne 0x207d5
movq %r12, 0xc8(%rsp)
leaq 0x18(%rbx), %r12
movq %rbp, %rdi
movq %r12, %rsi
callq 0x2134a
testb %al, %al
jne 0x207d8
leaq 0x30(%rbx), %r12
movq %rbp, %rdi
movq %r12, %rsi
callq 0x2134a
testb %al, %al
jne 0x207d8
leaq 0x48(%rbx), %r12
movq %rbp, %r15
movq %rbp, %rdi
movq %r12, %rsi
callq 0x2134a
testb %al, %al
jne 0x207d8
addq $0x60, %rbx
movq 0xd0(%rsp), %rax
decq %rax
movq 0xc8(%rsp), %r12
addq $-0x60, %r12
cmpq $0x1, %rax
movq %r15, %rbp
jg 0x20712
sarq $0x3, %r12
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %r12
cmpq $0x1, %r12
je 0x207df
cmpq $0x2, %r12
je 0x207ea
cmpq $0x3, %r12
jne 0x20829
leaq 0x80(%rsp), %rdi
movq %rbx, %rsi
callq 0x2134a
testb %al, %al
je 0x207e6
movq %rbx, %r12
movq 0x10(%rsp), %r15
jmp 0x20820
movq 0x10(%rsp), %r15
jmp 0x20807
addq $0x18, %rbx
movq 0x10(%rsp), %r15
leaq 0x80(%rsp), %rdi
movq %rbx, %rsi
callq 0x2134a
testb %al, %al
jne 0x2081d
addq $0x18, %rbx
leaq 0x80(%rsp), %rdi
movq %rbx, %rsi
callq 0x2134a
testb %al, %al
cmoveq %r15, %rbx
movq %rbx, %r12
cmpq %r15, %r12
jne 0x20c19
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
xorl %eax, %eax
movq %rax, 0x90(%rsp)
movq %rax, 0xc0(%rsp)
movaps %xmm0, 0xb0(%rsp)
movq 0xc8(%r14), %r15
movq 0xd0(%r14), %rbp
cmpq %rbp, %r15
je 0x2097d
leaq 0x20(%rsp), %r12
leaq 0x58(%rsp), %rbx
leaq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x19aae
movq 0x48(%rsp), %rsi
subq 0x40(%rsp), %rsi
sarq $0x3, %rsi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x1b5a2
movq 0x48(%rsp), %rsi
subq 0x40(%rsp), %rsi
sarq $0x3, %rsi
movq %rbx, %rdi
leaq 0xa0(%rsp), %rdx
callq 0x1b5a2
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
subq %rsi, %rdx
je 0x208e5
movq 0x20(%rsp), %rdi
callq 0x65b0
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
subq %rsi, %rdx
je 0x208e5
movq 0x58(%rsp), %rdi
callq 0x65b0
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x60(%r14), %rdx
callq 0x1b62f
movq 0x58(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0x60(%r14), %rdx
callq 0x1b62f
leaq 0x80(%rsp), %rdi
movq %r12, %rsi
callq 0x213a4
leaq 0xb0(%rsp), %rdi
movq %rbx, %rsi
callq 0x213a4
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x20942
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x20959
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x20970
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x18, %r15
cmpq %rbp, %r15
jne 0x2086f
movq 0x78(%rsp), %rcx
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
xorl %eax, %eax
movq %rax, 0x10(%rcx)
movq %rax, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movq %rax, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movl $0x0, 0xc(%rsp)
testl %r13d, %r13d
jle 0x20a42
leaq 0x58(%rsp), %r12
leaq 0xa0(%rsp), %r15
leaq 0x1f(%rsp), %rbp
leaq 0x40(%rsp), %rbx
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x209e3
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x209f2
leaq 0x20(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x21698
movq $0x0, 0xa0(%rsp)
movl $0x2, %edx
movq %r12, %rdi
movq %r15, %rsi
movq %rbp, %rcx
callq 0x213d0
movq %rbx, %rdi
movq %r12, %rsi
callq 0x217d4
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x20a33
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movl 0xc(%rsp), %eax
incl %eax
movl %eax, 0xc(%rsp)
cmpl %r13d, %eax
jl 0x209ca
cmpl $0x0, 0x74(%rsp)
jle 0x20bc7
xorl %ebp, %ebp
movq 0x40(%rsp), %rcx
leaq 0x58(%rsp), %rbx
leaq 0xc(%rsp), %r12
movq 0xc8(%r14), %rsi
movl 0xc0(%r14), %edx
incl %edx
movl %edx, %eax
cltd
idivl %r13d
movl %edx, 0xc0(%r14)
movslq %edx, %rax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rax
movq (%rcx,%rax), %rdi
movslq (%rdi), %rdi
movq 0x8(%rsi,%rax), %r8
subq (%rsi,%rax), %r8
sarq $0x3, %r8
cmpq %rdi, %r8
jbe 0x20a6c
movq 0x20(%rsp), %rcx
movq 0x60(%r14), %rsi
movq 0x28(%rsp), %rax
subq %rcx, %rax
shrq $0x2, %rax
decl %eax
movl $0x0, 0x58(%rsp)
movl %eax, 0x5c(%rsp)
movq %rbx, %rdi
movq %rbx, %rdx
callq 0x1fc82
cltq
movq 0x20(%rsp), %rcx
movslq (%rcx,%rax,4), %rax
movslq 0xc0(%r14), %rdx
cmpl %edx, %eax
je 0x20aa4
movq 0x40(%rsp), %rdi
leaq (,%rax,8), %rsi
leaq (%rsi,%rsi,2), %rsi
movq (%rdi,%rsi), %r8
movslq 0x4(%r8), %r8
movq 0xc8(%r14), %r9
movq 0x8(%r9,%rsi), %r10
subq (%r9,%rsi), %r10
sarq $0x3, %r10
cmpq %r8, %r10
jbe 0x20aa4
addq %rdi, %rsi
movq 0x80(%rsp), %rcx
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %rdx
movq (%rdi,%rdx), %rdi
movslq (%rdi), %rdi
movq (%rcx,%rdx), %rcx
movq (%rcx,%rdi,8), %rcx
movq %rcx, 0xa0(%rsp)
movq 0xb0(%rsp), %rcx
leaq (%rax,%rax,2), %r15
movq (%rsi), %rax
movslq 0x4(%rax), %rax
movq (%rcx,%r15,8), %rcx
movq (%rcx,%rax,8), %rax
movq %rax, 0xa8(%rsp)
movl $0x2, %edx
movq %rbx, %rdi
leaq 0xa0(%rsp), %rsi
movq %r12, %rcx
callq 0xb484
movq 0x78(%rsp), %rdi
movq %rbx, %rsi
callq 0x18c56
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x20b9e
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movslq 0xc0(%r14), %rax
movq 0x40(%rsp), %rcx
leaq (%rax,%rax,2), %rax
movq (%rcx,%rax,8), %rax
incl (%rax)
movq (%rcx,%r15,8), %rax
incl 0x4(%rax)
incl %ebp
cmpl 0x74(%rsp), %ebp
jne 0x20a5e
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x20bde
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
leaq 0x40(%rsp), %rdi
callq 0x21416
leaq 0xb0(%rsp), %rdi
callq 0xb508
leaq 0x80(%rsp), %rdi
callq 0xb508
movq 0x78(%rsp), %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x41388(%rip), %rdi     # 0x61fa8
leaq 0x295a8(%rip), %rsi     # 0x4a1cf
callq 0x6360
leaq 0x27930(%rip), %rsi     # 0x48563
movq %rax, %rdi
callq 0x6360
movl $0x1, %edi
callq 0x6440
jmp 0x20cc5
jmp 0x20c5d
jmp 0x20cc5
movq %rax, %rbx
jmp 0x20cf3
movq %rax, %rbx
jmp 0x20cac
movq %rax, %rbx
jmp 0x20c95
movq %rax, %rbx
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x20cc8
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x20cc8
jmp 0x20cc5
movq %rax, %rbx
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x20c95
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x20cac
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x20cf3
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x20cf3
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x20cdf
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
leaq 0x40(%rsp), %rdi
callq 0x21416
movq 0x78(%rsp), %rdi
callq 0xb508
leaq 0xb0(%rsp), %rdi
callq 0xb508
leaq 0x80(%rsp), %rdi
callq 0xb508
movq %rbx, %rdi
callq 0x6620
nop