// File: xukmin[P]rase/calculate-routing-metrics.cc
// Function: CalculateMetrics(SimulationOptions const&, RoutingMetrics*)
void CalculateMetrics(const SimulationOptions& options, RoutingMetrics* metrics) {
  RandomizedSensorPlacer placer(options.num_sensors, options.region);

  for (double range = options.lower_communication_range;
       range < options.upper_communication_range;
       range += options.communication_range_step) {
    if (int(range * 10) % 10 == 0) {
      printf("\nrange = %.1f", range);
    } else {
      printf(" %.1f", range);
    }

    metrics->AddRange(range);
    for (int i = 0; i < options.times; i++) {
      std::vector<Position> positions;
      GeneratePositionsThatCanBeConnected(range, &placer, &positions);

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

      for (int b = 0; b < options.builders.size(); b++) {
        options.builders[b]->BuildRouting(&network);
        for (int c = 0; c < options.calculators.size(); c++) {
          double metric = options.calculators[c]->CalculateMetric(network);
          if (metric > 0.0) {
            metrics->AddData(range, b, c, metric);
          }
        }
      }
    }
  }
  printf("\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %esi
movq -0x8(%rbp), %rdx
addq $0x8, %rdx
leaq -0x40(%rbp), %rdi
callq 0x4bb0
movq -0x8(%rbp), %rax
movsd 0x28(%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm1
movq -0x8(%rbp), %rax
movsd 0x30(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x3e39
movsd 0x1a448(%rip), %xmm0    # 0x1e010
mulsd -0x48(%rbp), %xmm0
cvttsd2si %xmm0, %eax
movl $0xa, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x3c06
movsd -0x48(%rbp), %xmm0
leaq 0x1a54e(%rip), %rdi     # 0x1e138
movb $0x1, %al
callq 0x3030
jmp 0x3bf3
jmp 0x3c1d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x3e5b
movsd -0x48(%rbp), %xmm0
leaq 0x1a52e(%rip), %rdi     # 0x1e140
movb $0x1, %al
callq 0x3030
jmp 0x3c1b
jmp 0x3c1d
movq -0x10(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
callq 0x4ea0
jmp 0x3c2d
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x3e1f
leaq -0x70(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x4c40
movq -0x120(%rbp), %rsi
movsd -0x48(%rbp), %xmm0
leaq -0x40(%rbp), %rdi
callq 0xc0c0
jmp 0x3c6b
leaq -0x108(%rbp), %rdi
callq 0x4c60
jmp 0x3c79
movsd -0x48(%rbp), %xmm0
leaq -0x108(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0xd6c0
jmp 0x3c90
movl $0x0, -0x10c(%rbp)
movslq -0x10c(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
callq 0x4af0
movq %rax, %rcx
movq -0x128(%rbp), %rax
cmpq %rcx, %rax
jae 0x3df1
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
movslq -0x10c(%rbp), %rsi
callq 0x4b10
movq (%rax), %rdi
leaq -0x108(%rbp), %rsi
callq 0x155e0
jmp 0x3ced
movl $0x0, -0x110(%rbp)
movslq -0x110(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0x8(%rbp), %rdi
addq $0x58, %rdi
callq 0x4b50
movq %rax, %rcx
movq -0x130(%rbp), %rax
cmpq %rcx, %rax
jae 0x3ddb
movq -0x8(%rbp), %rdi
addq $0x58, %rdi
movslq -0x110(%rbp), %rsi
callq 0x4b70
movq (%rax), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
leaq -0x108(%rbp), %rsi
callq *%rax
movsd %xmm0, -0x138(%rbp)
jmp 0x3d56
movsd -0x138(%rbp), %xmm0
movsd %xmm0, -0x118(%rbp)
movsd -0x118(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x3dc5
movq -0x10(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
movl -0x10c(%rbp), %esi
movl -0x110(%rbp), %edx
movsd -0x118(%rbp), %xmm1
callq 0x4f60
jmp 0x3d9b
jmp 0x3dc5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x3e14
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x4dd0
jmp 0x3e14
jmp 0x3dc7
movl -0x110(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x110(%rbp)
jmp 0x3cf7
jmp 0x3ddd
movl -0x10c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10c(%rbp)
jmp 0x3c9a
leaq -0x108(%rbp), %rdi
callq 0x4dd0
leaq -0x70(%rbp), %rdi
callq 0x4e20
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x3c34
leaq -0x70(%rbp), %rdi
callq 0x4e20
jmp 0x3e5b
jmp 0x3e21
movq -0x8(%rbp), %rax
movsd 0x38(%rax), %xmm0
addsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0x3ba8
leaq 0x1a5dc(%rip), %rdi     # 0x1e41c
xorl %eax, %eax
callq 0x3030
jmp 0x3e49
leaq -0x40(%rbp), %rdi
callq 0x4e80
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
leaq -0x40(%rbp), %rdi
callq 0x4e80
movq -0x50(%rbp), %rdi
callq 0x33d0
nopl (%rax)