// File: /workspace/github_cpp_makefile_star2_O1/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 0x3140
movl %eax, %edi
callq 0x3150
movl $0x64, 0x24(%rsp)
cmpl $0x2, %ebp
jl 0x359a
movq 0x8(%r14), %rdi
callq 0x3230
movl %eax, 0x24(%rsp)
cmpl $0x3, %ebp
jl 0x35aa
movq 0x10(%r14), %rdi
callq 0x31e0
jmp 0x35b2
movsd 0x5a56(%rip), %xmm0     # 0x9008
movsd %xmm0, 0x28(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
movabsq $0x4059000000000000, %rax # imm = 0x4059000000000000
movq %rax, 0xe0(%rsp)
movq %rax, 0xe8(%rsp)
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movl $0x50, %edi
callq 0x3170
movq %rax, %r14
movq %rax, %rdi
callq 0x6ad0
leaq 0xf0(%rsp), %rsi
movq %r14, (%rsi)
movq %rsp, %rdi
callq 0x3e28
movl $0x50, %edi
callq 0x3170
movq %rax, %r14
movq %rax, %rdi
callq 0x6bfe
leaq 0xf0(%rsp), %rsi
movq %r14, (%rsi)
movq %rsp, %rdi
callq 0x3e28
movl $0x50, %edi
callq 0x3170
movq %rax, %r14
movq %rax, %rdi
callq 0x6d1e
leaq 0xf0(%rsp), %rsi
movq %r14, (%rsi)
movq %rsp, %rdi
callq 0x3e28
movl $0x50, %edi
callq 0x3170
movq %rax, %r14
movq %rax, %rdi
callq 0x6fca
leaq 0xf0(%rsp), %rsi
movq %r14, (%rsi)
movq %rsp, %rdi
callq 0x3e28
movl $0x50, %edi
callq 0x3170
movq %rax, %r14
movq %rax, %rdi
callq 0x719c
leaq 0xf0(%rsp), %rsi
movq %r14, (%rsi)
movq %rsp, %rdi
callq 0x3e28
movl $0x50, %edi
callq 0x3170
movq %rax, %r14
movq %rax, %rdi
callq 0x730a
leaq 0xf0(%rsp), %rsi
movq %r14, (%rsi)
movq %rsp, %rdi
callq 0x3e28
movl $0x50, %edi
callq 0x3170
movq %rax, %r14
movq %rax, %rdi
callq 0x6e5c
leaq 0xf0(%rsp), %rsi
movq %r14, (%rsi)
movq %rsp, %rdi
callq 0x3e28
movl $0x50, %edi
callq 0x3170
movq %rax, %r14
movq %rax, %rdi
callq 0x759c
leaq 0xf0(%rsp), %rsi
movq %r14, (%rsi)
movq %rsp, %rdi
callq 0x3e28
leaq 0xa1ef(%rip), %rax      # 0xd920
addq $0x10, %rax
movq %rax, 0x188(%rsp)
movl 0x24(%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 0x3b65
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 0x4c46
movq (%rsp), %rax
cmpq %rax, 0x8(%rsp)
je 0x3ab6
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 0x698a
movq %r15, %rdi
movl 0x24(%rsp), %esi
callq 0x81c9
movl $0x9, %r8d
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x57b3(%rip), %rcx      # 0x9018
callq 0x31a0
leaq 0x40(%rsp), %rsi
movq %rsi, 0x30(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x3892
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x3898
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 0x5764(%rip), %rsi      # 0x9020
callq 0x32a0
movq %r13, 0x50(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x38e4
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x38ec
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 (%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 0x394a
movq %rdx, 0x1b8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x1c8(%rsp)
jmp 0x3952
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 0x56ab(%rip), %rsi      # 0x9022
callq 0x32a0
movq %rbx, 0x70(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x39a2
movq %rdx, 0x70(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x80(%rsp)
jmp 0x39a8
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 0x39dd
movq 0x1c8(%rsp), %rsi
incq %rsi
callq 0x3180
movq 0x50(%rsp), %rdi
cmpq %r13, %rdi
je 0x39f4
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x3180
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x3a10
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3180
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x3a35
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x3180
movq (%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 0x7d50
movq %rbp, %rdi
leaq 0xf0(%rsp), %rsi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x7e40
movq %rbp, %rdi
callq 0x7e00
movq 0x70(%rsp), %rdi
cmpq %rbx, %rdi
je 0x3a9a
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x3180
incq %r14
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r14, %rcx
ja 0x3834
movq (%rsp), %rax
cmpq %rax, 0x8(%rsp)
je 0x3aea
xorl %ebx, %ebx
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x3ad2
movq (%rdi), %rax
callq *0x8(%rax)
incq %rbx
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbx, %rcx
ja 0x3ac3
leaq 0x168(%rsp), %rdi
callq 0x3cf8
leaq 0x138(%rsp), %rdi
callq 0x3d88
leaq 0x108(%rsp), %rdi
callq 0x3d88
leaq 0xf0(%rsp), %rdi
callq 0x3d46
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x3b3b
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3180
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x3b51
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x3180
xorl %eax, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x54bb(%rip), %rdi      # 0x9027
leaq 0x54c4(%rip), %rsi      # 0x9037
leaq 0x54d0(%rip), %rcx      # 0x904a
movl $0x1a, %edx
callq 0x30e0
jmp 0x3bc4
movq %rax, %r15
jmp 0x3c89
jmp 0x3b9c
jmp 0x3b9c
jmp 0x3b9c
jmp 0x3b9c
jmp 0x3b9c
jmp 0x3b9c
jmp 0x3b9c
movq %rax, %r15
movl $0x50, %esi
movq %r14, %rdi
jmp 0x3ca1
jmp 0x3bba
jmp 0x3bba
jmp 0x3bba
jmp 0x3bba
jmp 0x3bba
jmp 0x3bba
jmp 0x3bba
movq %rax, %r15
jmp 0x3ca6
jmp 0x3bc4
movq %rax, %r15
jmp 0x3c7c
movq %rax, %r15
jmp 0x3c2e
movq %rax, %r15
jmp 0x3c12
movq %rax, %r15
jmp 0x3bfb
movq %rax, %r15
movq 0x1b8(%rsp), %rdi
cmpq %r12, %rdi
je 0x3bfb
movq 0x1c8(%rsp), %rsi
incq %rsi
callq 0x3180
movq 0x50(%rsp), %rdi
cmpq %r13, %rdi
je 0x3c12
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x3180
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x3c2e
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3180
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x3c7c
movq 0xc0(%rsp), %rsi
jmp 0x3c74
movq %rax, %r15
jmp 0x3c62
movq %rax, %r15
leaq 0x1b8(%rsp), %rdi
callq 0x7e00
movq 0x70(%rsp), %rdi
cmpq %rbx, %rdi
je 0x3c7c
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x3180
leaq 0xf0(%rsp), %rdi
callq 0x3cc4
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x3ca6
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3180
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x3cbc
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x3180
movq %r15, %rdi
callq 0x3280