// File: /workspace/github_cpp_makefile_star2_O2/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 $0xc8, %rsp
movl %edx, %ecx
movq %rsi, %r14
movq %rdi, 0x38(%rsp)
movq 0xc8(%rsi), %rdx
movq 0xd0(%rsi), %rbp
movq %rbp, 0x8(%rsp)
movq %rdx, %rbx
subq %rdx, %rbp
pushq $0x18
popq %rsi
movq %rbp, %rax
cqto
idivq %rsi
movq %rax, %r15
shlq $0x20, %rax
movl %ecx, 0x14(%rsp)
movl %ecx, %ecx
orq %rax, %rcx
leaq 0x60(%rsp), %r12
movq %rcx, (%r12)
movq %r15, %rax
sarq $0x2, %rax
testq %rax, %rax
jle 0x1b652
movq %rax, 0xa8(%rsp)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x1bdb6
testb %al, %al
jne 0x1b69d
movq %rbp, 0xa0(%rsp)
leaq 0x18(%rbx), %rbp
movq %r12, %rdi
movq %rbp, %rsi
callq 0x1bdb6
testb %al, %al
jne 0x1b6a0
leaq 0x30(%rbx), %rbp
movq %r12, %rdi
movq %rbp, %rsi
callq 0x1bdb6
testb %al, %al
jne 0x1b6a0
leaq 0x48(%rbx), %rbp
movq %r12, %r13
movq %r12, %rdi
movq %rbp, %rsi
callq 0x1bdb6
testb %al, %al
jne 0x1b6a0
addq $0x60, %rbx
movq 0xa8(%rsp), %rax
decq %rax
movq 0xa0(%rsp), %rbp
addq $-0x60, %rbp
movq %r13, %r12
jmp 0x1b5bf
movq %rbp, %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
cmpq $0x1, %rax
je 0x1b9e1
cmpq $0x2, %rax
je 0x1b688
cmpq $0x3, %rax
jne 0x1b6ae
leaq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0x1bdb6
testb %al, %al
jne 0x1b69d
addq $0x18, %rbx
leaq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0x1bdb6
testb %al, %al
je 0x1b9dd
movq %rbx, %rbp
movq 0x8(%rsp), %rax
cmpq %rax, %rbp
jne 0x1ba01
xorps %xmm0, %xmm0
leaq 0x60(%rsp), %rax
andq $0x0, 0x10(%rax)
leaq 0xb0(%rsp), %rcx
andq $0x0, 0x10(%rcx)
movaps %xmm0, (%rax)
movaps %xmm0, (%rcx)
movq 0xc8(%r14), %rbx
movq 0xd0(%r14), %rbp
leaq 0x40(%rsp), %r12
leaq 0x88(%rsp), %r13
cmpq %rbp, %rbx
je 0x1b7d4
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0x15d3a
movq 0x28(%rsp), %rsi
subq 0x20(%rsp), %rsi
sarq $0x3, %rsi
movq %r12, %rdi
movq %r13, %rdx
callq 0x17216
movq 0x28(%rsp), %rsi
subq 0x20(%rsp), %rsi
sarq $0x3, %rsi
movq %r13, %rdi
leaq 0x78(%rsp), %rdx
callq 0x17216
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
subq %rsi, %rdx
je 0x1b768
movq 0x40(%rsp), %rdi
callq 0x65c0
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
subq %rsi, %rdx
je 0x1b768
movq 0x88(%rsp), %rdi
callq 0x65c0
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x60(%r14), %rdx
callq 0x17270
movq 0x88(%rsp), %rdi
movq 0x90(%rsp), %rsi
movq 0x60(%r14), %rdx
callq 0x17270
leaq 0x60(%rsp), %rdi
movq %r12, %rsi
callq 0x1be00
leaq 0xb0(%rsp), %rdi
movq %r13, %rsi
callq 0x1be00
movq %r13, %rdi
callq 0x990e
movq %r12, %rdi
callq 0x990e
leaq 0x20(%rsp), %rdi
callq 0x990e
addq $0x18, %rbx
jmp 0x1b6e9
xorps %xmm0, %xmm0
movq 0x38(%rsp), %rax
movups %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq 0x20(%rsp), %rax
andq $0x0, 0x10(%rax)
leaq 0x40(%rsp), %rcx
andq $0x0, 0x10(%rcx)
movaps %xmm0, (%rax)
movaps %xmm0, (%rcx)
xorl %eax, %eax
leaq 0x88(%rsp), %rbp
leaq 0x78(%rsp), %rbx
pushq $0x2
popq %r12
leaq 0x1f(%rsp), %r13
movl %eax, 0x18(%rsp)
cmpl %r15d, %eax
jge 0x1b862
leaq 0x40(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x1be2c
andq $0x0, 0x78(%rsp)
movq %rbp, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x1be4a
leaq 0x20(%rsp), %rdi
movq %rbp, %rsi
callq 0x1c216
movq %rbp, %rdi
callq 0x1c0a0
movl 0x18(%rsp), %eax
incl %eax
jmp 0x1b816
xorl %ebp, %ebp
movl 0x14(%rsp), %eax
testl %eax, %eax
cmovlel %ebp, %eax
movl %eax, 0x14(%rsp)
leaq 0x40(%rsp), %rbx
leaq 0x88(%rsp), %r12
cmpl 0x14(%rsp), %ebp
je 0x1b99b
movq 0x20(%rsp), %rcx
movq 0xc8(%r14), %rsi
movl 0xc0(%r14), %edx
incl %edx
movl %edx, %eax
cltd
idivl %r15d
movl %edx, 0xc0(%r14)
movslq %edx, %rax
imulq $0x18, %rax, %rax
movq (%rcx,%rax), %rdi
movslq (%rdi), %rdi
movq 0x8(%rsi,%rax), %r8
subq (%rsi,%rax), %r8
sarq $0x3, %r8
cmpq %rdi, %r8
jbe 0x1b89b
movq 0x60(%r14), %rsi
movq %rbx, %rdi
callq 0x1baca
movslq 0xc0(%r14), %rcx
cmpl %ecx, %eax
je 0x1b8ca
movslq %eax, %rdx
movq 0x20(%rsp), %rax
imulq $0x18, %rdx, %r13
movq (%rax,%r13), %rdx
movslq 0x4(%rdx), %rdx
movq 0xc8(%r14), %rsi
movq 0x8(%rsi,%r13), %rdi
subq (%rsi,%r13), %rdi
sarq $0x3, %rdi
cmpq %rdx, %rdi
jbe 0x1b8ca
movq 0x60(%rsp), %rdx
imulq $0x18, %rcx, %rcx
movq (%rax,%rcx), %rsi
addq %r13, %rax
movslq (%rsi), %rsi
movq (%rdx,%rcx), %rcx
movq (%rcx,%rsi,8), %rcx
movq %rcx, 0x78(%rsp)
movq 0xb0(%rsp), %rcx
movq (%rax), %rax
movslq 0x4(%rax), %rax
movq (%rcx,%r13), %rcx
movq (%rcx,%rax,8), %rax
movq %rax, 0x80(%rsp)
movq %r12, %rdi
leaq 0x78(%rsp), %rsi
pushq $0x2
popq %rdx
leaq 0x18(%rsp), %rcx
callq 0x927a
movq 0x38(%rsp), %rdi
movq %r12, %rsi
callq 0x15146
movq %r12, %rdi
callq 0x990e
movslq 0xc0(%r14), %rax
movq 0x20(%rsp), %rcx
imulq $0x18, %rax, %rax
movq (%rcx,%rax), %rax
incl (%rax)
movq (%rcx,%r13), %rax
incl 0x4(%rax)
incl %ebp
jmp 0x1b87e
leaq 0x40(%rsp), %rdi
callq 0x1c0a0
leaq 0x20(%rsp), %rdi
callq 0x1be80
leaq 0xb0(%rsp), %rdi
callq 0x92ec
leaq 0x60(%rsp), %rdi
callq 0x92ec
movq 0x38(%rsp), %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x18, %rbx
leaq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0x1bdb6
testb %al, %al
movq 0x8(%rsp), %rax
cmoveq %rax, %rbx
movq %rbx, %rbp
jmp 0x1b6a5
movq 0x3e590(%rip), %rdi     # 0x59f98
leaq 0x20868(%rip), %rsi     # 0x3c277
callq 0x63a0
leaq 0x1eb48(%rip), %rsi     # 0x3a563
movq %rax, %rdi
callq 0x63a0
pushq $0x1
popq %rdi
callq 0x6450
jmp 0x1ba8a
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x990e
jmp 0x1ba8d
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x1c0a0
jmp 0x1ba8d
jmp 0x1ba8a
jmp 0x1ba8a
movq %rax, %rbx
jmp 0x1baab
movq %rax, %rbx
jmp 0x1ba7e
movq %rax, %rbx
jmp 0x1ba74
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x990e
leaq 0x40(%rsp), %rdi
callq 0x990e
leaq 0x20(%rsp), %rdi
callq 0x990e
jmp 0x1baab
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x1c0a0
leaq 0x20(%rsp), %rdi
callq 0x1be80
movq 0x38(%rsp), %rdi
callq 0x92ec
leaq 0xb0(%rsp), %rdi
callq 0x92ec
leaq 0x60(%rsp), %rdi
callq 0x92ec
movq %rbx, %rdi
callq 0x6650