// File: kaityo256[P]randomsampling/test.cpp
// Function: void test_with_update<binary_tree>(std::vector<double, std::allocator<double>>&, int, double)
void test_with_update(std::vector<double> &v, int ui, double uvalue) {
  std::vector<double> r(v.size(), 0.0);
  std::mt19937 mt;
  T s(v);
  std::cout << s.name() << std::endl;

  v[ui] = uvalue;
  s.update(ui, uvalue);
  const int N = 100000;
  double sum = std::accumulate(v.begin(), v.end(), 0);
  const double a = sum / N;
  for (int i = 0; i < N; i++) {
    int index = s.select(mt);
    r[index] += a;
  }
  for (size_t i = 0; i < v.size(); i++) {
    std::cout << i << ":" << r[i] << std::endl;
  }
}

// Assembly:
subq $0x14a8, %rsp           # imm = 0x14A8
movq %rdi, 0x14a0(%rsp)
movl %esi, 0x149c(%rsp)
movsd %xmm0, 0x1490(%rsp)
movq 0x14a0(%rsp), %rdi
callq 0x2640
movq %rax, 0x40(%rsp)
movq $0x0, 0x1470(%rsp)
leaq 0x146f(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x3400
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rcx
leaq 0x1478(%rsp), %rdi
leaq 0x1470(%rsp), %rdx
callq 0x36b0
jmp 0x30e0
leaq 0x146f(%rsp), %rdi
callq 0x34a0
leaq 0xd0(%rsp), %rdi
callq 0x3730
jmp 0x30fc
movq 0x14a0(%rsp), %rsi
leaq 0xa8(%rsp), %rdi
callq 0x9fe0
jmp 0x3113
leaq 0x88(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0xa1f0
jmp 0x312a
movq 0xcea7(%rip), %rdi      # 0xffd8
leaq 0x88(%rsp), %rsi
callq 0x2130
movq %rax, 0x38(%rsp)
jmp 0x3145
movq 0x38(%rsp), %rdi
movq 0xce77(%rip), %rsi      # 0xffc8
callq 0x2170
jmp 0x3158
leaq 0x88(%rsp), %rdi
callq 0x20b0
movsd 0x1490(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x14a0(%rsp), %rdi
movslq 0x149c(%rsp), %rsi
callq 0x2660
movsd 0x30(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x149c(%rsp), %esi
movsd 0x1490(%rsp), %xmm0
leaq 0xa8(%rsp), %rdi
callq 0xa6e0
jmp 0x31b2
movl $0x186a0, 0x84(%rsp) # imm = 0x186A0
movq 0x14a0(%rsp), %rdi
callq 0x3e70
movq %rax, 0x70(%rsp)
movq 0x14a0(%rsp), %rdi
callq 0x3ea0
movq %rax, 0x68(%rsp)
movq 0x70(%rsp), %rdi
movq 0x68(%rsp), %rsi
xorl %edx, %edx
callq 0x3e00
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0x78(%rsp), %xmm0
movsd 0x7e06(%rip), %xmm1     # 0xb010
divsd %xmm1, %xmm0
movsd %xmm0, 0x60(%rsp)
movl $0x0, 0x5c(%rsp)
cmpl $0x186a0, 0x5c(%rsp)    # imm = 0x186A0
jge 0x3304
leaq 0xa8(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0xa270
movl %eax, 0x2c(%rsp)
jmp 0x3245
movl 0x2c(%rsp), %eax
movl %eax, 0x58(%rsp)
movsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movslq 0x58(%rsp), %rsi
leaq 0x1478(%rsp), %rdi
callq 0x2660
movsd 0x20(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x321c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1460(%rsp)
movl %eax, 0x145c(%rsp)
leaq 0x146f(%rsp), %rdi
callq 0x34a0
jmp 0x33ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1460(%rsp)
movl %eax, 0x145c(%rsp)
jmp 0x33dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1460(%rsp)
movl %eax, 0x145c(%rsp)
jmp 0x33d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1460(%rsp)
movl %eax, 0x145c(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x20b0
jmp 0x33d0
movq $0x0, 0x50(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x14a0(%rsp), %rdi
callq 0x2640
movq %rax, %rcx
movq 0x18(%rsp), %rax
cmpq %rcx, %rax
jae 0x33ae
movq 0x50(%rsp), %rsi
movq 0xcc9b(%rip), %rdi      # 0xffd8
callq 0x2040
movq %rax, 0x10(%rsp)
jmp 0x3349
movq 0x10(%rsp), %rdi
leaq 0x7d0e(%rip), %rsi      # 0xb063
callq 0x2140
movq %rax, 0x8(%rsp)
jmp 0x3361
movq 0x50(%rsp), %rsi
leaq 0x1478(%rsp), %rdi
callq 0x2660
movq 0x8(%rsp), %rdi
movsd (%rax), %xmm0
callq 0x2250
movq %rax, (%rsp)
jmp 0x3387
movq (%rsp), %rdi
movq 0xcc36(%rip), %rsi      # 0xffc8
callq 0x2170
jmp 0x3399
jmp 0x339b
movq 0x50(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x50(%rsp)
jmp 0x330d
leaq 0xa8(%rsp), %rdi
callq 0xa3a0
leaq 0x1478(%rsp), %rdi
callq 0x34b0
addq $0x14a8, %rsp           # imm = 0x14A8
retq
leaq 0xa8(%rsp), %rdi
callq 0xa3a0
leaq 0x1478(%rsp), %rdi
callq 0x34b0
movq 0x1460(%rsp), %rdi
callq 0x2220
nopw (%rax,%rax)