// File: xukmin[P]rase/calculate-routing-metrics.cc
// Function: main
int main(int argc, char** argv) {
  std::srand(std::time(NULL));

  // Disable buffering of stdout.
  std::setbuf(stdout, NULL);

  SimulationOptions options;

  options.num_sensors = 100;
  options.times = 20;

  options.lower_communication_range = 25.0;
  options.upper_communication_range = 50.0;
  options.communication_range_step = 0.1;

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

  options.builders.push_back(new EarliestFirstRoutingBuilder());
  options.builders.push_back(new SecondEarliestFirstRoutingBuilder());
  options.builders.push_back(new LatestFirstRoutingBuilder());
  options.builders.push_back(new NearestFirstRoutingBuilder());
  options.builders.push_back(new SecondNearestFirstRoutingBuilder());
  options.builders.push_back(new FarthestFirstRoutingBuilder());
  options.builders.push_back(new RandomizedRoutingBuilder());
  options.builders.push_back(new WeightedRandomizedRoutingBuilder());

  options.calculators.push_back(new NodeDegreeVarianceCalculator());
  options.calculators.push_back(new RobustnessCalculator());
  options.calculators.push_back(new ChannelQualityCalculator());
  options.calculators.push_back(new DataAggregationCalculator());
  options.calculators.push_back(new LatencyCalculator());

  if (argc > 1) {
    options.num_sensors = std::atoi(argv[1]);
  }
  if (argc > 2) {
    options.times = std::atoi(argv[2]);
  }
  if (argc > 4) {
    options.lower_communication_range = std::atof(argv[3]);
    options.upper_communication_range = std::atof(argv[4]);
  }
  if (argc > 5) {
    options.communication_range_step = std::atof(argv[5]);
  }

  PrintSimulationOptions(options);

  // Build example routing networks and save as SVG images. These example
  // routing networks are only for demonstration purposes but not for the
  // following simulations.
  BuildExampleRoutingNetworks(options);

  RoutingMetrics metrics(options);
  CalculateMetrics(options, &metrics);
  SaveMetrics(options, metrics);

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

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
xorl %eax, %eax
movl %eax, %edi
movq %rdi, -0x1b8(%rbp)
callq 0x31e0
movl %eax, %edi
callq 0x31f0
movq -0x1b8(%rbp), %rsi
movq 0x2ad6a(%rip), %rax     # 0x2efb8
movq (%rax), %rdi
callq 0x3320
leaq -0x80(%rbp), %rdi
callq 0x50b0
movl $0x64, -0x80(%rbp)
movl $0x14, -0x7c(%rbp)
movabsq $0x4039000000000000, %rax # imm = 0x4039000000000000
movq %rax, -0x58(%rbp)
movabsq $0x4049000000000000, %rax # imm = 0x4049000000000000
movq %rax, -0x50(%rbp)
movabsq $0x3fb999999999999a, %rax # imm = 0x3FB999999999999A
movq %rax, -0x48(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x70(%rbp)
movabsq $0x4059000000000000, %rax # imm = 0x4059000000000000
movq %rax, -0x68(%rbp)
movq %rax, -0x60(%rbp)
leaq -0x40(%rbp), %rax
movq %rax, -0x1b0(%rbp)
movl $0x50, %edi
callq 0x3220
movq %rax, -0x1a8(%rbp)
jmp 0x42d7
movq -0x1a8(%rbp), %rdi
callq 0x157b0
jmp 0x42e5
movq -0x1b0(%rbp), %rdi
movq -0x1a8(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x88(%rbp), %rsi
callq 0x50e0
jmp 0x4308
leaq -0x40(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movl $0x50, %edi
callq 0x3220
movq %rax, -0x1c0(%rbp)
jmp 0x4326
movq -0x1c0(%rbp), %rdi
callq 0x15980
jmp 0x4334
movq -0x1c8(%rbp), %rdi
movq -0x1c0(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq -0xa0(%rbp), %rsi
callq 0x50e0
jmp 0x4357
leaq -0x40(%rbp), %rax
movq %rax, -0x1d8(%rbp)
movl $0x50, %edi
callq 0x3220
movq %rax, -0x1d0(%rbp)
jmp 0x4375
movq -0x1d0(%rbp), %rdi
callq 0x15b20
jmp 0x4383
movq -0x1d8(%rbp), %rdi
movq -0x1d0(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0xa8(%rbp), %rsi
callq 0x50e0
jmp 0x43a6
leaq -0x40(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movl $0x50, %edi
callq 0x3220
movq %rax, -0x1e0(%rbp)
jmp 0x43c4
movq -0x1e0(%rbp), %rdi
callq 0x15f40
jmp 0x43d2
movq -0x1e8(%rbp), %rdi
movq -0x1e0(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq -0xb0(%rbp), %rsi
callq 0x50e0
jmp 0x43f5
leaq -0x40(%rbp), %rax
movq %rax, -0x1f8(%rbp)
movl $0x50, %edi
callq 0x3220
movq %rax, -0x1f0(%rbp)
jmp 0x4413
movq -0x1f0(%rbp), %rdi
callq 0x16250
jmp 0x4421
movq -0x1f8(%rbp), %rdi
movq -0x1f0(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq -0xb8(%rbp), %rsi
callq 0x50e0
jmp 0x4444
leaq -0x40(%rbp), %rax
movq %rax, -0x208(%rbp)
movl $0x50, %edi
callq 0x3220
movq %rax, -0x200(%rbp)
jmp 0x4462
movq -0x200(%rbp), %rdi
callq 0x16490
jmp 0x4470
movq -0x208(%rbp), %rdi
movq -0x200(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0xc0(%rbp), %rsi
callq 0x50e0
jmp 0x4493
leaq -0x40(%rbp), %rax
movq %rax, -0x218(%rbp)
movl $0x50, %edi
callq 0x3220
movq %rax, -0x210(%rbp)
jmp 0x44b1
movq -0x210(%rbp), %rdi
callq 0x15cf0
jmp 0x44bf
movq -0x218(%rbp), %rdi
movq -0x210(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq -0xc8(%rbp), %rsi
callq 0x50e0
jmp 0x44e2
leaq -0x40(%rbp), %rax
movq %rax, -0x228(%rbp)
movl $0x50, %edi
callq 0x3220
movq %rax, -0x220(%rbp)
jmp 0x4500
movq -0x220(%rbp), %rdi
callq 0x16870
jmp 0x450e
movq -0x228(%rbp), %rdi
movq -0x220(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq -0xd0(%rbp), %rsi
callq 0x50e0
jmp 0x4531
leaq -0x28(%rbp), %rax
movq %rax, -0x238(%rbp)
movl $0x28, %edi
callq 0x3220
movq %rax, -0x230(%rbp)
jmp 0x454f
movq -0x230(%rbp), %rdi
callq 0x5140
jmp 0x455d
movq -0x238(%rbp), %rdi
movq -0x230(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0xd8(%rbp), %rsi
callq 0x5110
jmp 0x4580
leaq -0x28(%rbp), %rax
movq %rax, -0x248(%rbp)
movl $0x28, %edi
callq 0x3220
movq %rax, -0x240(%rbp)
jmp 0x459e
movq -0x240(%rbp), %rdi
callq 0x51f0
jmp 0x45ac
movq -0x248(%rbp), %rdi
movq -0x240(%rbp), %rax
movq %rax, -0xe0(%rbp)
leaq -0xe0(%rbp), %rsi
callq 0x5110
jmp 0x45cf
leaq -0x28(%rbp), %rax
movq %rax, -0x258(%rbp)
movl $0x28, %edi
callq 0x3220
movq %rax, -0x250(%rbp)
jmp 0x45ed
movq -0x250(%rbp), %rdi
callq 0x52a0
jmp 0x45fb
movq -0x258(%rbp), %rdi
movq -0x250(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0xe8(%rbp), %rsi
callq 0x5110
jmp 0x461e
leaq -0x28(%rbp), %rax
movq %rax, -0x268(%rbp)
movl $0x28, %edi
callq 0x3220
movq %rax, -0x260(%rbp)
jmp 0x463c
movq -0x260(%rbp), %rdi
callq 0x5350
jmp 0x464a
movq -0x268(%rbp), %rdi
movq -0x260(%rbp), %rax
movq %rax, -0xf0(%rbp)
leaq -0xf0(%rbp), %rsi
callq 0x5110
jmp 0x466d
leaq -0x28(%rbp), %rax
movq %rax, -0x278(%rbp)
movl $0x28, %edi
callq 0x3220
movq %rax, -0x270(%rbp)
jmp 0x468b
movq -0x270(%rbp), %rdi
callq 0x5400
jmp 0x4699
movq -0x278(%rbp), %rdi
movq -0x270(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq -0xf8(%rbp), %rsi
callq 0x5110
jmp 0x46bc
cmpl $0x1, -0x8(%rbp)
jle 0x48fa
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x3370
movl %eax, -0x80(%rbp)
jmp 0x48fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x4ad2
movq -0x1a8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
movl $0x50, %esi
callq 0x3230
jmp 0x4ad2
movq -0x1c0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
movl $0x50, %esi
callq 0x3230
jmp 0x4ad2
movq -0x1d0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
movl $0x50, %esi
callq 0x3230
jmp 0x4ad2
movq -0x1e0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
movl $0x50, %esi
callq 0x3230
jmp 0x4ad2
movq -0x1f0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
movl $0x50, %esi
callq 0x3230
jmp 0x4ad2
movq -0x200(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
movl $0x50, %esi
callq 0x3230
jmp 0x4ad2
movq -0x210(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
movl $0x50, %esi
callq 0x3230
jmp 0x4ad2
movq -0x220(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
movl $0x50, %esi
callq 0x3230
jmp 0x4ad2
movq -0x230(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
movl $0x28, %esi
callq 0x3230
jmp 0x4ad2
movq -0x240(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
movl $0x28, %esi
callq 0x3230
jmp 0x4ad2
movq -0x250(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
movl $0x28, %esi
callq 0x3230
jmp 0x4ad2
movq -0x260(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
movl $0x28, %esi
callq 0x3230
jmp 0x4ad2
movq -0x270(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
movl $0x28, %esi
callq 0x3230
jmp 0x4ad2
cmpl $0x2, -0x8(%rbp)
jle 0x4910
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x3370
movl %eax, -0x7c(%rbp)
cmpl $0x4, -0x8(%rbp)
jle 0x493a
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x3300
movsd %xmm0, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x3300
movsd %xmm0, -0x50(%rbp)
cmpl $0x5, -0x8(%rbp)
jle 0x4952
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x3300
movsd %xmm0, -0x48(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x3600
jmp 0x495d
leaq -0x80(%rbp), %rdi
callq 0x37f0
jmp 0x4968
leaq -0x198(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x54b0
jmp 0x497a
leaq -0x80(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x3b70
jmp 0x498c
leaq -0x80(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x3e70
jmp 0x499e
movl $0x0, -0x19c(%rbp)
movslq -0x19c(%rbp), %rax
movq %rax, -0x280(%rbp)
leaq -0x80(%rbp), %rdi
addq $0x58, %rdi
callq 0x4b50
movq %rax, %rcx
movq -0x280(%rbp), %rax
cmpq %rcx, %rax
jae 0x4a39
leaq -0x80(%rbp), %rdi
addq $0x58, %rdi
movslq -0x19c(%rbp), %rsi
callq 0x54f0
movq (%rax), %rax
movq %rax, -0x288(%rbp)
cmpq $0x0, %rax
je 0x4a03
movq -0x288(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x4a05
movl -0x19c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x19c(%rbp)
jmp 0x49a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x5530
jmp 0x4ad2
movl $0x0, -0x1a0(%rbp)
movslq -0x1a0(%rbp), %rax
movq %rax, -0x290(%rbp)
leaq -0x80(%rbp), %rdi
addq $0x40, %rdi
callq 0x4af0
movq %rax, %rcx
movq -0x290(%rbp), %rax
cmpq %rcx, %rax
jae 0x4ab1
leaq -0x80(%rbp), %rdi
addq $0x40, %rdi
movslq -0x1a0(%rbp), %rsi
callq 0x5510
movq (%rax), %rax
movq %rax, -0x298(%rbp)
cmpq $0x0, %rax
je 0x4a9e
movq -0x298(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x4aa0
movl -0x1a0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1a0(%rbp)
jmp 0x4a43
leaq -0x198(%rbp), %rdi
callq 0x5530
leaq -0x80(%rbp), %rdi
callq 0x5560
movl -0x4(%rbp), %eax
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
leaq -0x80(%rbp), %rdi
callq 0x5560
movq -0x90(%rbp), %rdi
callq 0x33d0
nopw (%rax,%rax)