// File: /workspace/github_cpp_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x13f8, %rsp           # imm = 0x13F8
movsd %xmm0, 0x8(%rsp)
movq %rdi, %rbx
movq 0x8(%rdi), %rax
subq (%rdi), %rax
movl %esi, %ebp
sarq $0x3, %rax
leaq 0x70(%rsp), %r14
movq $0x0, (%r14)
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rcx
movq %rax, %rsi
movq %r14, %rdx
callq 0x2196
movq $0x1571, (%r14)         # imm = 0x1571
movl $0x1, %eax
movl $0x1571, %ecx           # imm = 0x1571
movq %rcx, %rdx
shrq $0x1e, %rdx
xorl %ecx, %edx
imull $0x6c078965, %edx, %ecx # imm = 0x6C078965
addl %eax, %ecx
movq %rcx, 0x70(%rsp,%rax,8)
incq %rax
cmpq $0x270, %rax            # imm = 0x270
jne 0x1ee0
movq $0x270, 0x13f0(%rsp) # imm = 0x270
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq 0x3dba
leaq 0x60(%rsp), %r14
movq %r14, -0x10(%r14)
movabsq $0x54207972616e6942, %rax # imm = 0x54207972616E6942
movq %rax, (%r14)
movl $0x65657254, 0x7(%r14)  # imm = 0x65657254
movq $0xb, -0x8(%r14)
movb $0x0, 0xb(%r14)
movq 0x508c(%rip), %rdi      # 0x6fd8
movl $0xb, %edx
movq %r14, %rsi
callq 0x10f0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %esi
movq %r15, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1080
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0x1f9a
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x10e0
movslq %ebp, %rsi
movq (%rbx), %rax
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rax,%rsi,8)
leaq 0x28(%rsp), %rdi
callq 0x3f6c
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq %rcx, %rax
je 0x1fe4
xorl %edx, %edx
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
addsd (%rax), %xmm0
cvttsd2si %xmm0, %edx
addq $0x8, %rax
cmpq %rcx, %rax
jne 0x1fc3
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
jmp 0x1fe8
xorpd %xmm0, %xmm0
divsd 0x3020(%rip), %xmm0     # 0x5010
movsd %xmm0, 0x8(%rsp)
movl $0x186a0, %ebp          # imm = 0x186A0
leaq 0x28(%rsp), %r14
leaq 0x70(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x3eec
cltq
movq 0x10(%rsp), %rcx
movsd (%rcx,%rax,8), %xmm0
addsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rcx,%rax,8)
decl %ebp
jne 0x2005
movq 0x8(%rbx), %rax
cmpq (%rbx), %rax
je 0x20b3
xorl %r14d, %r14d
movq 0x4f9a(%rip), %r15      # 0x6fd8
leaq 0x3082(%rip), %r12      # 0x50c7
movq %r15, %rdi
movq %r14, %rsi
callq 0x1070
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x10f0
movq 0x10(%rsp), %rax
movsd (%rax,%r14,8), %xmm0
movq %r13, %rdi
callq 0x1110
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %esi
movq %r13, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1080
incq %r14
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x3, %rax
cmpq %rax, %r14
jb 0x2045
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x20ca
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x20e1
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
addq $0x13f8, %rsp           # imm = 0x13F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x2130
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0x2119
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x10e0
jmp 0x2119
jmp 0x2116
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x2130
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2147
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq %rbx, %rdi
callq 0x1140
nop