// File: /workspace/github_cpp_makefile_star2_O2/cegme[P]vose/test.cc
// Function: test::test6()
bool test::test6() {

  VoseTree tree;
  tree.set_max_marbles(4);
  tree.set_max_bags(5);

  // Generate a set of label names.
  std::string labels = "red yellow blue";

  // Make a random number generator for marble weights
  std::default_random_engine weight_generator(VoseUtil::RANDOM_SEED); 
  std::uniform_int_distribution<long>
    weight_distribution(1, 1000);
  std::function<long()> random_weight =
    std::bind(weight_distribution, weight_generator);

  // FIXME why does 280 node work? Where is the error, need more stats
  for(size_t i = 0; i != 279; ++i) {
    // Get a random marble with random label and random weight.
    size_t weight = random_weight();
    //std::cerr << "label_idx: " << label_idx << ", " << labels[label_idx] << "\n";
    //std::cerr << " weight: " << weight << "\n";
    std::random_shuffle(labels.begin(), labels.end());
    tree.add(labels, weight);
    //std::cerr << tree.toString();
  }

  // Generate a histogram.
  auto hist = VoseTree::histogram(tree, 50000L);

  // Get the real probabilities
  auto prob = tree.probabilities();

  // Compare the results
  double kl1 = VoseTree::kl(hist, prob);
  double kl2 = VoseTree::kl(prob, hist);
  std::cerr << "kl(hist, prob): " << kl1 << "\n";
  std::cerr << "kl(prob, hist): " << kl2 << "\n";
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
xorps %xmm0, %xmm0
movaps %xmm0, -0xd0(%rbp)
movaps %xmm0, -0xe0(%rbp)
movaps %xmm0, -0xf0(%rbp)
movaps %xmm0, -0x100(%rbp)
movaps %xmm0, -0x110(%rbp)
movaps %xmm0, -0x120(%rbp)
movq $0x4, -0xc0(%rbp)
movq $0x5, -0xb8(%rbp)
leaq 0x22ff(%rip), %rsi      # 0xa4b5
leaq -0x58(%rbp), %rdi
leaq -0x88(%rbp), %rdx
callq 0x20b0
leaq -0x88(%rbp), %rsi
movq $0x1, (%rsi)
movq $0x3e8, 0x8(%rsi)       # imm = 0x3E8
movq $0x2a, 0x10(%rsi)
leaq -0xa8(%rbp), %rdi
callq 0x87fa
movl $0x117, %ebx            # imm = 0x117
leaq -0x170(%rbp), %r14
leaq -0x58(%rbp), %r15
leaq -0x120(%rbp), %r12
subq $0x1, %rbx
jb 0x824f
leaq -0xa8(%rbp), %rdi
callq 0x8856
movq %rax, %r13
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rsi
addq %rdi, %rsi
callq 0x88d9
movq %r14, %rdi
movq %r15, %rsi
callq 0x2240
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x247c
movq %r14, %rdi
callq 0x20d0
jmp 0x8207
leaq -0x1e0(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x886a
leaq -0x88(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
movl $0xc350, %edx           # imm = 0xC350
callq 0x3088
leaq -0x1e0(%rbp), %rdi
callq 0x8788
leaq -0x150(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x2e58
leaq -0x88(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x2f78
movsd %xmm0, -0x38(%rbp)
leaq -0x150(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x2f78
movsd %xmm0, -0x30(%rbp)
movq 0x7d20(%rip), %rdi      # 0xfff0
leaq 0x21bc(%rip), %rsi      # 0xa493
callq 0x21e0
movq %rax, %rdi
movsd -0x38(%rbp), %xmm0
callq 0x2280
leaq 0x223c(%rip), %rsi      # 0xa52c
movq %rax, %rdi
callq 0x21e0
movq 0x7cf1(%rip), %rdi      # 0xfff0
leaq 0x219e(%rip), %rsi      # 0xa4a4
callq 0x21e0
movq %rax, %rdi
movsd -0x30(%rbp), %xmm0
callq 0x2280
leaq 0x220d(%rip), %rsi      # 0xa52c
movq %rax, %rdi
callq 0x21e0
leaq -0x150(%rbp), %rdi
callq 0x4290
leaq -0x88(%rbp), %rdi
callq 0x4290
leaq -0xa8(%rbp), %rdi
callq 0x3892
leaq -0x58(%rbp), %rdi
callq 0x20d0
leaq -0x120(%rbp), %rdi
callq 0x8788
movb $0x1, %al
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8398
movq %rax, %rbx
jmp 0x83a7
movq %rax, %rbx
leaq -0x1e0(%rbp), %rdi
callq 0x8788
jmp 0x83c9
jmp 0x83c6
movq %rax, %rbx
jmp 0x83d5
movq %rax, %rbx
jmp 0x83de
movq %rax, %rbx
leaq -0x150(%rbp), %rdi
callq 0x4290
leaq -0x88(%rbp), %rdi
callq 0x4290
jmp 0x83c9
movq %rax, %rbx
leaq -0x170(%rbp), %rdi
callq 0x20d0
jmp 0x83c9
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x3892
leaq -0x58(%rbp), %rdi
callq 0x20d0
leaq -0x120(%rbp), %rdi
callq 0x8788
movq %rbx, %rdi
callq 0x22d0