// File: /workspace/github_cpp_makefile_star2_O3/roornelas[P]small-world/test_graph.cpp
// Function: main
int main() {

  int side, people;
  bool right_size = false;

  while (!right_size) {
    std::cout << "How many people are in the network? In the range 20 - 10,000\n";
    std::cin >> people;
    if (people >= 20 && people <= 10000) {
      right_size = true;
    } else {
      std::cout << "The number of people has to be in the range 20 - 10,000 so your graph can be built in less than 20 seconds\n";
    }
  }
  side = ceil(sqrt(people));
  std::cout << "Side length of grid: " << side << "\n";
  std::cout << "Building a custom randomized graph just for you\n" ;
  pid_t pid = fork();
  
  if (pid == 0) {
    std::string s = std::to_string(side);
    char *pchar = (char*)s.c_str();
    char *argv[] = {"gui", pchar, "1", "1", "2", "5", "20", NULL};
    execv("gui", argv);
    exit(127);
  }
  else {
    Graph s(side);
    s.set_p(1);
    s.set_q_r(1, 2);

    pair<int, int> start = make_pair(rand() % side, rand() % side);
    pair<int, int> end = make_pair(rand() % side, rand() % side);
    std::cout << "Done! Let us run the algorithms\n" ;
    std::cout << "The number of people it took to transmit a message from person " <<
              "(" << start.first << ", " << start.second << ") to person " "(" << end.first << ", " << end.second << ") is: \n\n" ;
    int bfs = searchBFS(&s, start, end);
    std::cout << "Optimal possible result (Using breadth first search): " << bfs << " steps\n\n";
    int rw = searchRW(&s, start, end);
    std::cout << "Using a Random Walk: " << rw << " steps\n\n";
    int greedy = searchGreedy(&s, start, end);
    std::cout << "Using Kleinberg's simple algorithm: " << greedy << " steps\n\n";

    std::cout << "All tests passed!\n";
    waitpid(pid, 0, 0);
  }
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq 0x5612(%rip), %rdi      # 0x7fd0
leaq 0x2673(%rip), %rsi      # 0x5038
movl $0x3d, %edx
callq 0x2180
movq 0x560a(%rip), %rdi      # 0x7fe0
leaq 0xc(%rsp), %rbx
movq %rbx, %rsi
callq 0x20d0
movl (%rbx), %eax
addl $-0x14, %eax
cmpl $0x26fd, %eax           # imm = 0x26FD
jb 0x2a49
movq 0x55da(%rip), %rbx      # 0x7fd0
leaq 0x2679(%rip), %r14      # 0x5076
leaq 0x2634(%rip), %r15      # 0x5038
movq 0x55d5(%rip), %r12      # 0x7fe0
leaq 0xc(%rsp), %r13
movl $0x6b, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2180
movl $0x3d, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2180
movq %r12, %rdi
movq %r13, %rsi
callq 0x20d0
movl 0xc(%rsp), %eax
addl $-0x14, %eax
cmpl $0x26fc, %eax           # imm = 0x26FC
ja 0x2a10
cvtsi2sdl 0xc(%rsp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x2a5f
sqrtsd %xmm0, %xmm0
jmp 0x2a64
callq 0x20f0
callq 0x2040
cvttsd2si %xmm0, %ebp
movq 0x555c(%rip), %rbx      # 0x7fd0
leaq 0x2667(%rip), %rsi      # 0x50e2
movl $0x15, %edx
movq %rbx, %rdi
callq 0x2180
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2220
leaq 0x2716(%rip), %rsi      # 0x51af
movl $0x1, %edx
movq %rax, %rdi
callq 0x2180
leaq 0x264b(%rip), %rsi      # 0x50f8
movl $0x30, %edx
movq %rbx, %rdi
callq 0x2180
callq 0x2050
testl %eax, %eax
je 0x2d26
movl %eax, %ebx
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %ebp, %esi
callq 0x2e52
movq %r14, %rdi
movl $0x1, %esi
callq 0x2f72
leaq 0x10(%rsp), %rdi
movl $0x1, %esi
movl $0x2, %edx
callq 0x309c
callq 0x2060
cltd
idivl %ebp
movl %edx, %r14d
callq 0x2060
cltd
idivl %ebp
movl %edx, %r12d
callq 0x2060
cltd
idivl %ebp
movl %edx, %r15d
callq 0x2060
cltd
idivl %ebp
movl %edx, %r13d
movq 0x54a4(%rip), %rdi      # 0x7fd0
leaq 0x2603(%rip), %rsi      # 0x5136
movl $0x20, %edx
callq 0x2180
movq 0x548c(%rip), %rdi      # 0x7fd0
leaq 0x260c(%rip), %rsi      # 0x5157
movl $0x3f, %edx
callq 0x2180
movq 0x5474(%rip), %rdi      # 0x7fd0
leaq 0x2643(%rip), %rsi      # 0x51a6
movl $0x1, %edx
callq 0x2180
movq 0x545c(%rip), %rdi      # 0x7fd0
movl %r14d, %esi
callq 0x2220
movq %rax, %rbp
leaq 0x2611(%rip), %rsi      # 0x5197
movl $0x2, %edx
movq %rax, %rdi
callq 0x2180
movq %rbp, %rdi
movl %r12d, %esi
callq 0x2220
movq %rax, %rbp
leaq 0x25f2(%rip), %rsi      # 0x519a
movl $0xd, %edx
movq %rax, %rdi
callq 0x2180
movq %rbp, %rdi
movl %r15d, %esi
callq 0x2220
movq %rax, %rbp
leaq 0x25cd(%rip), %rsi      # 0x5197
movl $0x2, %edx
movq %rax, %rdi
callq 0x2180
movq %rbp, %rdi
movl %r13d, %esi
callq 0x2220
leaq 0x25bf(%rip), %rsi      # 0x51a8
movl $0x8, %edx
movq %rax, %rdi
callq 0x2180
shlq $0x20, %r12
orq %r12, %r14
shlq $0x20, %r13
orq %r13, %r15
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x240c
movl %eax, %ebp
movq 0x53b3(%rip), %rdi      # 0x7fd0
leaq 0x258d(%rip), %rsi      # 0x51b1
movl $0x36, %edx
callq 0x2180
movq 0x539b(%rip), %rdi      # 0x7fd0
movl %ebp, %esi
callq 0x2220
leaq 0x25a5(%rip), %rsi      # 0x51e8
movl $0x8, %edx
movq %rax, %rdi
callq 0x2180
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2836
movl %eax, %ebp
movq 0x5367(%rip), %rdi      # 0x7fd0
leaq 0x2581(%rip), %rsi      # 0x51f1
movl $0x15, %edx
callq 0x2180
movq 0x534f(%rip), %rdi      # 0x7fd0
movl %ebp, %esi
callq 0x2220
leaq 0x2559(%rip), %rsi      # 0x51e8
movl $0x8, %edx
movq %rax, %rdi
callq 0x2180
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x28db
movl %eax, %ebp
movq 0x531b(%rip), %rdi      # 0x7fd0
leaq 0x254b(%rip), %rsi      # 0x5207
movl $0x24, %edx
callq 0x2180
movq 0x5303(%rip), %rdi      # 0x7fd0
movl %ebp, %esi
callq 0x2220
leaq 0x250d(%rip), %rsi      # 0x51e8
movl $0x8, %edx
movq %rax, %rdi
callq 0x2180
movq 0x52e1(%rip), %rdi      # 0x7fd0
leaq 0x2536(%rip), %rsi      # 0x522c
movl $0x12, %edx
callq 0x2180
movl %ebx, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2100
leaq 0x10(%rsp), %rdi
callq 0x311c
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x58(%rsp), %rbx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2daf
movq (%rbx), %rax
leaq 0x23ea(%rip), %rdi      # 0x5129
leaq 0x10(%rsp), %rsi
movq %rdi, (%rsi)
movq %rax, 0x8(%rsi)
leaq 0x23db(%rip), %rax      # 0x512d
movq %rax, 0x10(%rsi)
movq %rax, 0x18(%rsi)
leaq 0x23ce(%rip), %rax      # 0x512f
movq %rax, 0x20(%rsi)
leaq 0x23c5(%rip), %rax      # 0x5131
movq %rax, 0x28(%rsi)
leaq 0x23bc(%rip), %rax      # 0x5133
movq %rax, 0x30(%rsi)
movq $0x0, 0x38(%rsi)
callq 0x2120
movl $0x7f, %edi
callq 0x21b0
jmp 0x2d9a
jmp 0x2d9a
jmp 0x2d9a
jmp 0x2d9a
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x311c
movq %rbx, %rdi
callq 0x2240