// File: /workspace/github_cpp_makefile_star2_O3/xukmin[P]rase/build-routings.cc
// Function: main
int main(int argc, char** argv) {
  std::srand(std::time(NULL));

  int num_sensors = 100;
  double communication_range = 20.0;
  double scale = 6.0;

  if (argc > 1) {
    num_sensors = std::atoi(argv[1]);
  }
  if (argc > 2) {
    communication_range = std::atof(argv[2]);
  }

  Region region;
  region.min_x = 0.0;
  region.min_y = 0.0;
  region.max_x = 100.0;
  region.max_y = 100.0;

  std::vector<RoutingBuilder*> builders;
  builders.push_back(new EarliestFirstRoutingBuilder());
  builders.push_back(new SecondEarliestFirstRoutingBuilder());
  builders.push_back(new LatestFirstRoutingBuilder());
  builders.push_back(new NearestFirstRoutingBuilder());
  builders.push_back(new SecondNearestFirstRoutingBuilder());
  builders.push_back(new FarthestFirstRoutingBuilder());
  builders.push_back(new RandomizedRoutingBuilder());
  builders.push_back(new WeightedRandomizedRoutingBuilder());

  RandomizedSensorPlacer placer(num_sensors, region);
  std::vector<Position> positions;
  GeneratePositionsThatCanBeConnected(communication_range, &placer, &positions);

  SensorNetwork network;
  network.DeploySensors(positions, communication_range);

  for (int i = 0; i < builders.size(); i++) {
    builders[i]->BuildRouting(&network);

    const std::string filename = "routings-" + IntToString(num_sensors) + "-" +
                                 builders[i]->name() + ".svg";
    SvgPrinter printer(filename, builders[i]->title(), region, scale);
    printer.PrintNetwork(network);
  }

  for (int i = 0; i < builders.size(); i++) {
    delete builders[i];
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movq %rsi, %r14
movl %edi, %ebp
xorl %edi, %edi
callq 0x3130
movl %eax, %edi
callq 0x3140
movsd 0x5a90(%rip), %xmm0     # 0x9008
movsd %xmm0, 0x28(%rsp)
movl $0x64, 0xc(%rsp)
cmpl $0x2, %ebp
jl 0x35ac
movq 0x8(%r14), %rdi
callq 0x3220
movl %eax, 0xc(%rsp)
cmpl $0x2, %ebp
je 0x35ac
movq 0x10(%r14), %rdi
callq 0x31d0
movsd %xmm0, 0x28(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
movaps 0x5a62(%rip), %xmm1     # 0x9020
movaps %xmm1, 0xe0(%rsp)
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x50, %edi
callq 0x3160
movq %rax, %r14
movq %rax, %rdi
callq 0x6b86
leaq 0xf0(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x3e38
movl $0x50, %edi
callq 0x3160
movq %rax, %r14
movq %rax, %rdi
callq 0x6cb4
leaq 0xf0(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x3e38
movl $0x50, %edi
callq 0x3160
movq %rax, %r14
movq %rax, %rdi
callq 0x6dd4
leaq 0xf0(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x3e38
movl $0x50, %edi
callq 0x3160
movq %rax, %r14
movq %rax, %rdi
callq 0x7080
leaq 0xf0(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x3e38
movl $0x50, %edi
callq 0x3160
movq %rax, %r14
movq %rax, %rdi
callq 0x7252
leaq 0xf0(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x3e38
movl $0x50, %edi
callq 0x3160
movq %rax, %r14
movq %rax, %rdi
callq 0x73c0
leaq 0xf0(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x3e38
movl $0x50, %edi
callq 0x3160
movq %rax, %r14
movq %rax, %rdi
callq 0x6f12
leaq 0xf0(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x3e38
movl $0x50, %edi
callq 0x3160
movq %rax, %r14
movq %rax, %rdi
callq 0x7622
leaq 0xf0(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x3e38
leaq 0xa1f5(%rip), %rax      # 0xd920
addq $0x10, %rax
movq %rax, 0x188(%rsp)
movl 0xc(%rsp), %eax
movl %eax, 0x190(%rsp)
movaps 0xd0(%rsp), %xmm0
movaps 0xe0(%rsp), %xmm1
movups %xmm0, 0x198(%rsp)
movups %xmm1, 0x1a8(%rsp)
testl %eax, %eax
jle 0x3b68
xorps %xmm0, %xmm0
leaq 0x90(%rsp), %rsi
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
leaq 0x188(%rsp), %rdi
movsd 0x28(%rsp), %xmm0
callq 0x41a7
leaq 0x110(%rsp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, -0x20(%rax)
xorl %ecx, %ecx
movq %rcx, -0x10(%rax)
movl %ecx, (%rax)
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
leaq 0x140(%rsp), %rax
movl %ecx, (%rax)
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x30(%rax)
movq %rcx, 0x40(%rax)
leaq 0xf0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
movsd 0x28(%rsp), %xmm0
callq 0x4c56
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
cmpq %rax, %rcx
je 0x3aba
leaq 0x60(%rsp), %r13
leaq 0x1c8(%rsp), %r12
leaq 0x80(%rsp), %rbx
xorl %r14d, %r14d
leaq 0xb0(%rsp), %r15
leaq 0x1b8(%rsp), %rbp
movq (%rax,%r14,8), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x6a40
movq %r15, %rdi
movl 0xc(%rsp), %esi
callq 0x826d
movl $0x9, %r8d
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x57cd(%rip), %rcx      # 0x9030
callq 0x3190
leaq 0x40(%rsp), %rsi
movq %rsi, 0x30(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x3890
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x3896
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x38(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x30(%rsp), %rdi
leaq 0x577e(%rip), %rsi      # 0x9038
callq 0x3290
movq %r13, 0x50(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x38e2
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x38ea
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rdx, 0x58(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x10(%rsp), %rax
movq (%rax,%r14,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
leaq 0x50(%rsp), %rdi
callq 0x3060
movq %r12, 0x1b8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x3949
movq %rdx, 0x1b8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x1c8(%rsp)
jmp 0x3951
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x1c0(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rbp, %rdi
leaq 0x56c4(%rip), %rsi      # 0x903a
callq 0x3290
movq %rbx, 0x70(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x39a1
movq %rdx, 0x70(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x80(%rsp)
jmp 0x39a7
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rax), %rdx
movq %rdx, 0x78(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x1b8(%rsp), %rdi
cmpq %r12, %rdi
je 0x39dc
movq 0x1c8(%rsp), %rsi
incq %rsi
callq 0x3170
movq 0x50(%rsp), %rdi
cmpq %r13, %rdi
je 0x39f3
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x3170
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x3a0f
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3170
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x3a34
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x3170
movq 0x10(%rsp), %rax
movq (%rax,%r14,8), %rdx
addq $0x28, %rdx
movq %rbp, %rdi
leaq 0x70(%rsp), %rsi
leaq 0xd0(%rsp), %rcx
movsd 0x55b7(%rip), %xmm0     # 0x9010
callq 0x7df0
movq %rbp, %rdi
leaq 0xf0(%rsp), %rsi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x7ee0
movq %rbp, %rdi
callq 0x7ea0
movq 0x70(%rsp), %rdi
cmpq %rbx, %rdi
je 0x3a9a
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x3170
incq %r14
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r14, %rdx
ja 0x3832
cmpq %rax, %rcx
je 0x3aec
xorl %ebx, %ebx
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x3ada
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
incq %rbx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rbx, %rdx
ja 0x3ac1
leaq 0x168(%rsp), %rdi
callq 0x3cfc
leaq 0x138(%rsp), %rdi
callq 0x3d98
leaq 0x108(%rsp), %rdi
callq 0x3d98
leaq 0xf0(%rsp), %rdi
callq 0x3d50
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x3b3d
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3170
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3b54
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3170
xorl %eax, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x54d0(%rip), %rdi      # 0x903f
leaq 0x54d9(%rip), %rsi      # 0x904f
leaq 0x54e5(%rip), %rcx      # 0x9062
movl $0x1a, %edx
callq 0x30e0
jmp 0x3bc7
movq %rax, %r15
jmp 0x3c8c
jmp 0x3b9f
jmp 0x3b9f
jmp 0x3b9f
jmp 0x3b9f
jmp 0x3b9f
jmp 0x3b9f
jmp 0x3b9f
movq %rax, %r15
movl $0x50, %esi
movq %r14, %rdi
jmp 0x3ca4
jmp 0x3bbd
jmp 0x3bbd
jmp 0x3bbd
jmp 0x3bbd
jmp 0x3bbd
jmp 0x3bbd
jmp 0x3bbd
movq %rax, %r15
jmp 0x3ca9
jmp 0x3bc7
movq %rax, %r15
jmp 0x3c7f
movq %rax, %r15
jmp 0x3c31
movq %rax, %r15
jmp 0x3c15
movq %rax, %r15
jmp 0x3bfe
movq %rax, %r15
movq 0x1b8(%rsp), %rdi
cmpq %r12, %rdi
je 0x3bfe
movq 0x1c8(%rsp), %rsi
incq %rsi
callq 0x3170
movq 0x50(%rsp), %rdi
cmpq %r13, %rdi
je 0x3c15
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x3170
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x3c31
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3170
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x3c7f
movq 0xc0(%rsp), %rsi
jmp 0x3c77
movq %rax, %r15
jmp 0x3c65
movq %rax, %r15
leaq 0x1b8(%rsp), %rdi
callq 0x7ea0
movq 0x70(%rsp), %rdi
cmpq %rbx, %rdi
je 0x3c7f
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x3170
leaq 0xf0(%rsp), %rdi
callq 0x3cc8
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x3ca9
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3170
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3cc0
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3170
movq %r15, %rdi
callq 0x3270