// File: /workspace/github_cpp_makefile_star2_O1/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, -0xa0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movaps %xmm0, -0xc0(%rbp)
movaps %xmm0, -0xd0(%rbp)
movaps %xmm0, -0xe0(%rbp)
movaps %xmm0, -0xf0(%rbp)
movq $0x4, -0x90(%rbp)
movq $0x5, -0x88(%rbp)
leaq -0x60(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1901(%rip), %rsi      # 0xb4f5
leaq 0x1909(%rip), %rdx      # 0xb504
leaq -0x70(%rbp), %rdi
callq 0xa7de
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movaps %xmm0, -0x50(%rbp)
movl $0x18, %edi
callq 0x21e0
movq $0x1, (%rax)
movq $0x3e8, 0x8(%rax)       # imm = 0x3E8
movq $0x2a, 0x10(%rax)
leaq -0x50(%rbp), %rcx
movq %rax, (%rcx)
leaq 0x110c(%rip), %rax      # 0xad4a
movq %rax, 0x18(%rcx)
leaq 0x1115(%rip), %rax      # 0xad5e
movq %rax, 0x10(%rcx)
xorl %r15d, %r15d
cmpq $0x0, -0x40(%rbp)
je 0x9eed
leaq -0x50(%rbp), %rdi
callq *-0x38(%rbp)
movq %rax, %r12
movq -0x68(%rbp), %rbx
cmpq $0x2, %rbx
jb 0x9ca7
movq -0x70(%rbp), %r13
movl $0x1, %r14d
callq 0x2070
cltq
leaq 0x1(%r14), %rcx
cqto
idivq %rcx
cmpq %rdx, %r14
je 0x9c9f
addq %r13, %r14
addq %r13, %rdx
movb (%r14), %al
movb (%rdx), %sil
movb %sil, (%r14)
movb %al, (%rdx)
movq %rcx, %r14
cmpq %rcx, %rbx
jne 0x9c79
leaq -0x100(%rbp), %r14
movq %r14, -0x110(%rbp)
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
addq %rsi, %rdx
leaq -0x110(%rbp), %rbx
movq %rbx, %rdi
callq 0x4742
leaq -0xf0(%rbp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x259c
movq -0x110(%rbp), %rdi
cmpq %r14, %rdi
je 0x9cf2
callq 0x21c0
incq %r15
cmpq $0x117, %r15            # imm = 0x117
jne 0x9c50
leaq -0x1e0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x47dc
leaq -0x1c0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0xa5ea
leaq -0x1a8(%rbp), %r14
leaq -0xb8(%rbp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa66a
movaps -0xa0(%rbp), %xmm0
movaps -0x90(%rbp), %xmm1
leaq -0x1e0(%rbp), %rsi
movups %xmm1, 0x60(%rsi)
movups %xmm0, 0x50(%rsi)
leaq -0x170(%rbp), %rdi
movl $0xc350, %edx           # imm = 0xC350
callq 0x4056
movq %r14, %rdi
callq 0xa5b6
movq -0x1c0(%rbp), %rdi
testq %rdi, %rdi
je 0x9d88
callq 0x21c0
movq -0x1d0(%rbp), %rax
testq %rax, %rax
je 0x9da5
leaq -0x1e0(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq -0x140(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x3d54
leaq -0x170(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x3edc
movsd %xmm0, -0x80(%rbp)
leaq -0x140(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x3edc
movsd %xmm0, -0x78(%rbp)
movq 0x6201(%rip), %rdi      # 0xfff0
leaq 0x16dd(%rip), %rsi      # 0xb4d3
movl $0x10, %edx
callq 0x2200
movq 0x61e9(%rip), %rdi      # 0xfff0
movsd -0x80(%rbp), %xmm0
callq 0x2260
leaq 0x1754(%rip), %rsi      # 0xb56c
movl $0x1, %edx
movq %rax, %rdi
callq 0x2200
movq 0x61c4(%rip), %rdi      # 0xfff0
leaq 0x16b1(%rip), %rsi      # 0xb4e4
movl $0x10, %edx
callq 0x2200
movq 0x61ac(%rip), %rdi      # 0xfff0
movsd -0x78(%rbp), %xmm0
callq 0x2260
leaq 0x1717(%rip), %rsi      # 0xb56c
movl $0x1, %edx
movq %rax, %rdi
callq 0x2200
leaq -0x140(%rbp), %rdi
callq 0x52c6
leaq -0x170(%rbp), %rdi
callq 0x52c6
movq -0x40(%rbp), %rax
testq %rax, %rax
je 0x9e91
leaq -0x50(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x9ea3
callq 0x21c0
movq %rbx, %rdi
callq 0xa5b6
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0x9ebc
callq 0x21c0
movq -0xe0(%rbp), %rax
testq %rax, %rax
je 0x9ed9
leaq -0xf0(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movb $0x1, %al
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x20b0
jmp 0x9fda
jmp 0x9fda
jmp 0x9fda
jmp 0x9f65
movq %rax, %rbx
jmp 0x9f74
movq %rax, %rbx
leaq -0x1e0(%rbp), %rdi
callq 0xa43c
jmp 0x9f9d
movq %rax, %rbx
movq -0x1c0(%rbp), %rdi
testq %rdi, %rdi
je 0x9f35
callq 0x21c0
jmp 0x9f35
movq %rax, %rbx
movq -0x1d0(%rbp), %rax
testq %rax, %rax
je 0x9f9d
leaq -0x1e0(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x9f9d
jmp 0x9fda
jmp 0x9f9a
movq %rax, %rbx
jmp 0x9fb4
movq %rax, %rbx
jmp 0x9fc6
movq %rax, %rbx
leaq -0x140(%rbp), %rdi
callq 0x52c6
leaq -0x170(%rbp), %rdi
callq 0x52c6
jmp 0x9f9d
movq %rax, %rbx
movq -0x110(%rbp), %rdi
cmpq %r14, %rdi
je 0x9f9d
callq 0x21c0
jmp 0x9f9d
jmp 0x9f9a
movq %rax, %rbx
movq -0x40(%rbp), %rax
testq %rax, %rax
je 0x9fb4
leaq -0x50(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x9fc6
callq 0x21c0
leaq -0xf0(%rbp), %rdi
callq 0xa43c
movq %rbx, %rdi
callq 0x22b0
movq %rax, %rdi
callq 0x4733