// File: /workspace/github_cpp_makefile_star2_O1/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
xorl %ebp, %ebp
movq 0x56a3(%rip), %rbx      # 0x7fd0
leaq 0x26dc(%rip), %r14      # 0x5010
movq 0x56a5(%rip), %r15      # 0x7fe0
leaq 0xc(%rsp), %r12
leaq 0x2707(%rip), %r13      # 0x504e
movl $0x3d, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2180
movq %r15, %rdi
movq %r12, %rsi
callq 0x20d0
movl 0xc(%rsp), %ecx
addl $-0x14, %ecx
movb $0x1, %al
cmpl $0x26fd, %ecx           # imm = 0x26FD
jb 0x2985
movl $0x6b, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2180
movl %ebp, %eax
movl %eax, %ebp
testb $0x1, %al
je 0x2947
cvtsi2sdl 0xc(%rsp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x29a1
sqrtsd %xmm0, %xmm0
jmp 0x29a6
callq 0x20f0
callq 0x2040
cvttsd2si %xmm0, %ebp
movq 0x561a(%rip), %rbx      # 0x7fd0
leaq 0x26fd(%rip), %rsi      # 0x50ba
movl $0x15, %edx
movq %rbx, %rdi
callq 0x2180
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2220
leaq 0x27ac(%rip), %rsi      # 0x5187
movl $0x1, %edx
movq %rax, %rdi
callq 0x2180
leaq 0x26e1(%rip), %rsi      # 0x50d0
movl $0x30, %edx
movq %rbx, %rdi
callq 0x2180
callq 0x2050
testl %eax, %eax
je 0x2c68
movl %eax, %ebx
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %ebp, %esi
callq 0x2d94
movq %r14, %rdi
movl $0x1, %esi
callq 0x2eb4
leaq 0x10(%rsp), %rdi
movl $0x1, %esi
movl $0x2, %edx
callq 0x2fea
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 0x5562(%rip), %rdi      # 0x7fd0
leaq 0x2699(%rip), %rsi      # 0x510e
movl $0x20, %edx
callq 0x2180
movq 0x554a(%rip), %rdi      # 0x7fd0
leaq 0x26a2(%rip), %rsi      # 0x512f
movl $0x3f, %edx
callq 0x2180
movq 0x5532(%rip), %rdi      # 0x7fd0
leaq 0x26d9(%rip), %rsi      # 0x517e
movl $0x1, %edx
callq 0x2180
movq 0x551a(%rip), %rdi      # 0x7fd0
movl %r14d, %esi
callq 0x2220
movq %rax, %rbp
leaq 0x26a7(%rip), %rsi      # 0x516f
movl $0x2, %edx
movq %rax, %rdi
callq 0x2180
movq %rbp, %rdi
movl %r12d, %esi
callq 0x2220
movq %rax, %rbp
leaq 0x2688(%rip), %rsi      # 0x5172
movl $0xd, %edx
movq %rax, %rdi
callq 0x2180
movq %rbp, %rdi
movl %r15d, %esi
callq 0x2220
movq %rax, %rbp
leaq 0x2663(%rip), %rsi      # 0x516f
movl $0x2, %edx
movq %rax, %rdi
callq 0x2180
movq %rbp, %rdi
movl %r13d, %esi
callq 0x2220
leaq 0x2655(%rip), %rsi      # 0x5180
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 0x23dc
movl %eax, %ebp
movq 0x5471(%rip), %rdi      # 0x7fd0
leaq 0x2623(%rip), %rsi      # 0x5189
movl $0x36, %edx
callq 0x2180
movq 0x5459(%rip), %rdi      # 0x7fd0
movl %ebp, %esi
callq 0x2220
leaq 0x263b(%rip), %rsi      # 0x51c0
movl $0x8, %edx
movq %rax, %rdi
callq 0x2180
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x27a3
movl %eax, %ebp
movq 0x5425(%rip), %rdi      # 0x7fd0
leaq 0x2617(%rip), %rsi      # 0x51c9
movl $0x15, %edx
callq 0x2180
movq 0x540d(%rip), %rdi      # 0x7fd0
movl %ebp, %esi
callq 0x2220
leaq 0x25ef(%rip), %rsi      # 0x51c0
movl $0x8, %edx
movq %rax, %rdi
callq 0x2180
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2848
movl %eax, %ebp
movq 0x53d9(%rip), %rdi      # 0x7fd0
leaq 0x25e1(%rip), %rsi      # 0x51df
movl $0x24, %edx
callq 0x2180
movq 0x53c1(%rip), %rdi      # 0x7fd0
movl %ebp, %esi
callq 0x2220
leaq 0x25a3(%rip), %rsi      # 0x51c0
movl $0x8, %edx
movq %rax, %rdi
callq 0x2180
movq 0x539f(%rip), %rdi      # 0x7fd0
leaq 0x25cc(%rip), %rsi      # 0x5204
movl $0x12, %edx
callq 0x2180
movl %ebx, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2100
leaq 0x10(%rsp), %rdi
callq 0x306e
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 0x2cf1
movq (%rbx), %rax
leaq 0x2480(%rip), %rdi      # 0x5101
leaq 0x10(%rsp), %rsi
movq %rdi, (%rsi)
movq %rax, 0x8(%rsi)
leaq 0x2471(%rip), %rax      # 0x5105
movq %rax, 0x10(%rsi)
movq %rax, 0x18(%rsi)
leaq 0x2464(%rip), %rax      # 0x5107
movq %rax, 0x20(%rsi)
leaq 0x245b(%rip), %rax      # 0x5109
movq %rax, 0x28(%rsi)
leaq 0x2452(%rip), %rax      # 0x510b
movq %rax, 0x30(%rsi)
movq $0x0, 0x38(%rsi)
callq 0x2120
movl $0x7f, %edi
callq 0x21b0
jmp 0x2cdc
jmp 0x2cdc
jmp 0x2cdc
jmp 0x2cdc
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x306e
movq %rbx, %rdi
callq 0x2240