// File: 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
movq %rsp, %rbp
subq $0x2b0, %rsp            # imm = 0x2B0
movq %rdi, -0x218(%rbp)
movq %rdi, %rax
movq %rax, -0x210(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x208(%rbp)
addq $0xc8, %rdi
callq 0x37930
movq -0x208(%rbp), %rdi
movl %eax, -0x18(%rbp)
addq $0xc8, %rdi
callq 0x377e0
movq -0x208(%rbp), %rdi
movq %rax, -0x20(%rbp)
addq $0xc8, %rdi
callq 0x37500
movq %rax, -0x28(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x4dc90
testb $0x1, %al
jne 0x4d3b2
jmp 0x4d3de
movq 0xb3bdf(%rip), %rdi     # 0x100f98
leaq 0x680f4(%rip), %rsi     # 0xb54b4
callq 0x84d0
movq %rax, %rdi
leaq 0x661e8(%rip), %rsi     # 0xb35b7
callq 0x84d0
movl $0x1, %edi
callq 0x85d0
leaq -0x48(%rbp), %rdi
callq 0xd9c0
leaq -0x60(%rbp), %rdi
callq 0xd9c0
movq -0x208(%rbp), %rax
addq $0xc8, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0x377e0
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rdi
callq 0x37500
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x4e640
testb $0x1, %al
jne 0x4d431
jmp 0x4d751
leaq -0x70(%rbp), %rdi
callq 0x37d00
movq %rax, %rsi
leaq -0x90(%rbp), %rdi
callq 0x3aff0
jmp 0x4d44b
leaq -0x90(%rbp), %rdi
callq 0x3b0e0
movq %rax, -0x228(%rbp)
leaq -0xb9(%rbp), %rdi
movq %rdi, -0x220(%rbp)
callq 0xd730
movq -0x228(%rbp), %rsi
movq -0x220(%rbp), %rdx
leaq -0xb8(%rbp), %rdi
callq 0x3f6c0
jmp 0x4d48d
leaq -0xb9(%rbp), %rdi
callq 0xd830
leaq -0x90(%rbp), %rdi
callq 0x3b0e0
movq %rax, -0x238(%rbp)
leaq -0xd9(%rbp), %rdi
movq %rdi, -0x230(%rbp)
callq 0xd730
movq -0x238(%rbp), %rsi
movq -0x230(%rbp), %rdx
leaq -0xd8(%rbp), %rdi
callq 0x3f6c0
jmp 0x4d4db
leaq -0xd9(%rbp), %rdi
callq 0xd830
leaq -0x90(%rbp), %rdi
movq %rdi, -0x248(%rbp)
callq 0x3b730
movq -0x248(%rbp), %rdi
movq %rax, -0xe8(%rbp)
callq 0x3b760
movq %rax, -0xf0(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x3b730
movq %rax, -0xf8(%rbp)
movq -0xe8(%rbp), %rdi
movq -0xf0(%rbp), %rsi
movq -0xf8(%rbp), %rdx
callq 0x3f730
movq %rax, -0x240(%rbp)
jmp 0x4d54a
movq -0x240(%rbp), %rax
movq %rax, -0x100(%rbp)
leaq -0x90(%rbp), %rdi
movq %rdi, -0x258(%rbp)
callq 0x3b730
movq -0x258(%rbp), %rdi
movq %rax, -0x108(%rbp)
callq 0x3b760
movq %rax, -0x110(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x3b730
movq %rax, -0x118(%rbp)
movq -0x108(%rbp), %rdi
movq -0x110(%rbp), %rsi
movq -0x118(%rbp), %rdx
callq 0x3f730
movq %rax, -0x250(%rbp)
jmp 0x4d5bb
movq -0x250(%rbp), %rax
movq %rax, -0x120(%rbp)
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x260(%rbp)
callq 0x3b730
movq -0x260(%rbp), %rdi
movq %rax, -0x128(%rbp)
callq 0x3b760
movq %rax, %rcx
movq -0x208(%rbp), %rax
movq %rcx, -0x130(%rbp)
movq 0x60(%rax), %rdx
movq -0x128(%rbp), %rdi
movq -0x130(%rbp), %rsi
callq 0x3f7c0
jmp 0x4d619
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x268(%rbp)
callq 0x3b730
movq -0x268(%rbp), %rdi
movq %rax, -0x138(%rbp)
callq 0x3b760
movq %rax, %rcx
movq -0x208(%rbp), %rax
movq %rcx, -0x140(%rbp)
movq 0x60(%rax), %rdx
movq -0x138(%rbp), %rdi
movq -0x140(%rbp), %rsi
callq 0x3f7c0
jmp 0x4d669
leaq -0x48(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x4e770
jmp 0x4d67b
leaq -0x60(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x4e770
jmp 0x4d68d
leaq -0xd8(%rbp), %rdi
callq 0xd7d0
leaq -0xb8(%rbp), %rdi
callq 0xd7d0
leaq -0x90(%rbp), %rdi
callq 0xd7d0
leaq -0x70(%rbp), %rdi
callq 0x4e750
jmp 0x4d41b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x4dc70
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0xb9(%rbp), %rdi
callq 0xd830
jmp 0x4d740
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0xd9(%rbp), %rdi
callq 0xd830
jmp 0x4d734
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0xd7d0
leaq -0xb8(%rbp), %rdi
callq 0xd7d0
leaq -0x90(%rbp), %rdi
callq 0xd7d0
jmp 0x4dc70
movq -0x218(%rbp), %rdi
movb $0x0, -0x141(%rbp)
callq 0xd9c0
leaq -0x160(%rbp), %rdi
callq 0x4e7e0
leaq -0x178(%rbp), %rdi
callq 0x4e800
movl $0x0, -0x17c(%rbp)
movl -0x17c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x4d8a8
leaq -0x178(%rbp), %rdi
leaq -0x17c(%rbp), %rsi
callq 0x4e820
jmp 0x4d7aa
movl $0x0, -0x1b0(%rbp)
movl $0x0, -0x1ac(%rbp)
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movq $0x2, -0x1a0(%rbp)
leaq -0x1b1(%rbp), %rdi
movq %rdi, -0x270(%rbp)
callq 0x4e8c0
movq -0x270(%rbp), %rcx
movq -0x1a8(%rbp), %rsi
movq -0x1a0(%rbp), %rdx
leaq -0x198(%rbp), %rdi
callq 0x4e8e0
jmp 0x4d80d
leaq -0x160(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x4e890
jmp 0x4d822
leaq -0x198(%rbp), %rdi
callq 0x4e960
leaq -0x1b1(%rbp), %rdi
callq 0x4e9c0
movl -0x17c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x17c(%rbp)
jmp 0x4d786
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x4dc1c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x4d897
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x4e960
leaq -0x1b1(%rbp), %rdi
callq 0x4e9c0
jmp 0x4dc1c
movl $0x0, -0x1bc(%rbp)
movl -0x1bc(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x4dbf2
jmp 0x4d8c3
movq -0x208(%rbp), %rax
movl 0xc0(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc0(%rax)
movl -0x18(%rbp), %ecx
movl 0xc0(%rax), %eax
cltd
idivl %ecx
movq -0x208(%rbp), %rax
movl %edx, 0xc0(%rax)
movq -0x208(%rbp), %rax
movslq 0xc0(%rax), %rsi
leaq -0x160(%rbp), %rdi
callq 0x4e9e0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4ea00
movq %rax, %rcx
movq -0x208(%rbp), %rax
movslq (%rcx), %rcx
movq %rcx, -0x278(%rbp)
movq %rax, %rdi
addq $0xc8, %rdi
movslq 0xc0(%rax), %rsi
callq 0xda70
movq %rax, %rdi
callq 0x3b0e0
movq %rax, %rcx
movq -0x278(%rbp), %rax
cmpq %rcx, %rax
jae 0x4d8c3
jmp 0x4d95f
movq -0x208(%rbp), %rax
movq 0x60(%rax), %rsi
leaq -0x178(%rbp), %rdi
callq 0x4dce0
movl %eax, -0x27c(%rbp)
jmp 0x4d97e
movl -0x27c(%rbp), %eax
movl %eax, -0x1b8(%rbp)
movq -0x208(%rbp), %rdx
movl -0x1b8(%rbp), %ecx
movb $0x1, %al
cmpl 0xc0(%rdx), %ecx
movb %al, -0x27d(%rbp)
je 0x4da09
movslq -0x1b8(%rbp), %rsi
leaq -0x160(%rbp), %rdi
callq 0x4e9e0
movq %rax, %rdi
movl $0x1, %esi
callq 0x4ea00
movq -0x208(%rbp), %rdi
movslq (%rax), %rax
movq %rax, -0x288(%rbp)
addq $0xc8, %rdi
movslq -0x1b8(%rbp), %rsi
callq 0xda70
movq %rax, %rdi
callq 0x3b0e0
movq %rax, %rcx
movq -0x288(%rbp), %rax
cmpq %rcx, %rax
setae %al
movb %al, -0x27d(%rbp)
movb -0x27d(%rbp), %al
testb $0x1, %al
jne 0x4d95f
movq -0x208(%rbp), %rax
movslq 0xc0(%rax), %rsi
leaq -0x48(%rbp), %rdi
callq 0xda70
movq %rax, %rcx
movq -0x208(%rbp), %rax
movq %rcx, -0x2a8(%rbp)
movslq 0xc0(%rax), %rsi
leaq -0x160(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x4e9e0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4ea00
movq -0x2a8(%rbp), %rdi
movslq (%rax), %rsi
callq 0xda90
movq (%rax), %rax
movq %rax, -0x1f8(%rbp)
movslq -0x1b8(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0xda70
movq -0x2a0(%rbp), %rdi
movq %rax, -0x298(%rbp)
movslq -0x1b8(%rbp), %rsi
callq 0x4e9e0
movq %rax, %rdi
movl $0x1, %esi
callq 0x4ea00
movq -0x298(%rbp), %rdi
movslq (%rax), %rsi
callq 0xda90
movq (%rax), %rax
movq %rax, -0x1f0(%rbp)
leaq -0x1f8(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq $0x2, -0x1e0(%rbp)
leaq -0x1f9(%rbp), %rdi
movq %rdi, -0x290(%rbp)
callq 0xd730
movq -0x290(%rbp), %rcx
movq -0x1e8(%rbp), %rsi
movq -0x1e0(%rbp), %rdx
leaq -0x1d8(%rbp), %rdi
callq 0xd750
jmp 0x4db1d
movq -0x218(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0xd700
jmp 0x4db32
leaq -0x1d8(%rbp), %rdi
callq 0xd7d0
leaq -0x1f9(%rbp), %rdi
callq 0xd830
movq -0x208(%rbp), %rax
movslq 0xc0(%rax), %rsi
leaq -0x160(%rbp), %rdi
callq 0x4e9e0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4ea00
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movslq -0x1b8(%rbp), %rsi
leaq -0x160(%rbp), %rdi
callq 0x4e9e0
movq %rax, %rdi
movl $0x1, %esi
callq 0x4ea00
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0x1bc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1bc(%rbp)
jmp 0x4d8b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x4dbe4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0xd7d0
leaq -0x1f9(%rbp), %rdi
callq 0xd830
jmp 0x4dc1c
movb $0x1, -0x141(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x4e960
leaq -0x160(%rbp), %rdi
callq 0x4ea20
testb $0x1, -0x141(%rbp)
jne 0x4dc4e
jmp 0x4dc42
leaq -0x178(%rbp), %rdi
callq 0x4e960
leaq -0x160(%rbp), %rdi
callq 0x4ea20
movq -0x218(%rbp), %rdi
callq 0xda10
jmp 0x4dc70
movq -0x218(%rbp), %rdi
callq 0xda10
leaq -0x60(%rbp), %rdi
callq 0xda10
leaq -0x48(%rbp), %rdi
callq 0xda10
movq -0x210(%rbp), %rax
addq $0x2b0, %rsp            # imm = 0x2B0
popq %rbp
retq
leaq -0x60(%rbp), %rdi
callq 0xda10
leaq -0x48(%rbp), %rdi
callq 0xda10
movq -0x98(%rbp), %rdi
callq 0x8880
nop