// File: /workspace/github_cpp_makefile_star2_O2/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, %rbx
movl %edi, %ebp
xorl %edi, %edi
callq 0x3140
movl %eax, %edi
callq 0x3150
movsd 0x4bb0(%rip), %xmm0     # 0x8008
movsd %xmm0, 0x28(%rsp)
cmpl $0x2, %ebp
jl 0x3486
movq 0x8(%rbx), %rdi
callq 0x3240
movl %eax, 0xc(%rsp)
cmpl $0x2, %ebp
je 0x348d
movq 0x10(%rbx), %rdi
callq 0x31d0
movsd %xmm0, 0x28(%rsp)
jmp 0x348d
pushq $0x64
popq %rax
movl %eax, 0xc(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movaps 0x4b84(%rip), %xmm1     # 0x8020
movaps %xmm1, 0x60(%rsp)
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
pushq $0x50
popq %rdi
callq 0x3170
movq %rax, %r14
movq %rax, %rdi
callq 0x670a
leaq 0x70(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x3bbc
pushq $0x50
popq %rdi
callq 0x3170
movq %rax, %r14
movq %rax, %rdi
callq 0x67ea
leaq 0x70(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x3bbc
pushq $0x50
popq %rdi
callq 0x3170
movq %rax, %r14
movq %rax, %rdi
callq 0x68bc
leaq 0x70(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x3bbc
pushq $0x50
popq %rdi
callq 0x3170
movq %rax, %r14
movq %rax, %rdi
callq 0x6ac4
leaq 0x70(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x3bbc
pushq $0x50
popq %rdi
callq 0x3170
movq %rax, %r14
movq %rax, %rdi
callq 0x6c3a
leaq 0x70(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x3bbc
pushq $0x50
popq %rdi
callq 0x3170
movq %rax, %r14
movq %rax, %rdi
callq 0x6d52
leaq 0x70(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x3bbc
pushq $0x50
popq %rdi
callq 0x3170
movq %rax, %r14
movq %rax, %rdi
callq 0x69ac
leaq 0x70(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x3bbc
pushq $0x50
popq %rdi
callq 0x3170
movq %rax, %r14
movq %rax, %rdi
callq 0x6f42
leaq 0x70(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x3bbc
leaq 0x1f8(%rsp), %rbx
leaq 0x50(%rsp), %rdx
movq %rbx, %rdi
movl 0xc(%rsp), %esi
callq 0x38c2
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rsi
movaps %xmm0, (%rsi)
andq $0x0, 0x10(%rsi)
movsd 0x28(%rsp), %xmm0
movq %rbx, %rdi
callq 0x3f02
leaq 0x90(%rsp), %rax
andq $0x0, -0x10(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, -0x20(%rax)
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0xc0(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x30(%rax)
andq $0x0, 0x40(%rax)
leaq 0x70(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movsd 0x28(%rsp), %xmm0
callq 0x482a
xorl %r14d, %r14d
leaq 0x108(%rsp), %r15
leaq 0x128(%rsp), %r13
leaq 0x148(%rsp), %rbx
leaq 0x188(%rsp), %r12
leaq 0x168(%rsp), %rbp
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r14, %rdx
jbe 0x378d
movq (%rax,%r14,8), %rdi
leaq 0x70(%rsp), %rsi
callq 0x65ea
movq %r15, %rdi
movl 0xc(%rsp), %esi
callq 0x7a3e
movq %r13, %rdi
leaq 0x4956(%rip), %rsi      # 0x8030
movq %r15, %rdx
callq 0x3943
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x4949(%rip), %rdx      # 0x8038
callq 0x3905
movq 0x10(%rsp), %rax
movq (%rax,%r14,8), %rdx
addq $0x8, %rdx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3924
movq %rbp, %rdi
movq %r12, %rsi
leaq 0x4921(%rip), %rdx      # 0x803a
callq 0x3905
movq %r12, %rdi
callq 0x30b0
movq %rbx, %rdi
callq 0x30b0
movq %r13, %rdi
callq 0x30b0
movq %r15, %rdi
callq 0x30b0
movq 0x10(%rsp), %rax
movq (%rax,%r14,8), %rdx
addq $0x28, %rdx
movq %r12, %rdi
movq %rbp, %rsi
leaq 0x50(%rsp), %rcx
movsd 0x48b2(%rip), %xmm0     # 0x8010
callq 0x766c
movq %r12, %rdi
leaq 0x70(%rsp), %rsi
pushq $0x1
popq %rcx
movl %ecx, %edx
callq 0x772a
movq %r12, %rdi
callq 0x770a
movq %rbp, %rdi
callq 0x30b0
incq %r14
jmp 0x3699
xorl %ebx, %ebx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rbx, %rdx
jbe 0x37bc
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x37b7
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
incq %rbx
jmp 0x378f
leaq 0x70(%rsp), %rdi
callq 0x3968
leaq 0x30(%rsp), %rdi
callq 0x3d38
leaq 0x10(%rsp), %rdi
callq 0x3b88
xorl %eax, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3855
movq %rax, %rbx
jmp 0x38a5
jmp 0x3806
jmp 0x3806
jmp 0x3806
jmp 0x3806
jmp 0x3806
jmp 0x3806
jmp 0x3806
movq %rax, %rbx
pushq $0x50
popq %rsi
movq %r14, %rdi
callq 0x3180
jmp 0x38af
jmp 0x3827
jmp 0x3827
jmp 0x3827
jmp 0x3827
jmp 0x3827
jmp 0x3827
jmp 0x3827
movq %rax, %rbx
jmp 0x38af
jmp 0x3855
movq %rax, %rbx
jmp 0x388e
movq %rax, %rbx
leaq 0x188(%rsp), %rdi
callq 0x770a
jmp 0x384b
movq %rax, %rbx
leaq 0x168(%rsp), %rdi
jmp 0x3896
movq %rax, %rbx
jmp 0x389b
movq %rax, %rbx
jmp 0x386f
movq %rax, %rbx
leaq 0x188(%rsp), %rdi
callq 0x30b0
leaq 0x148(%rsp), %rdi
callq 0x30b0
jmp 0x3881
movq %rax, %rbx
leaq 0x128(%rsp), %rdi
callq 0x30b0
leaq 0x108(%rsp), %rdi
callq 0x30b0
leaq 0x70(%rsp), %rdi
callq 0x3968
leaq 0x30(%rsp), %rdi
callq 0x3d38
leaq 0x10(%rsp), %rdi
callq 0x3b88
movq %rbx, %rdi
callq 0x3290
nop