// File: /workspace/github_cpp_makefile_star2_O3/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, -0xc0(%rbp)
movaps %xmm0, -0xd0(%rbp)
movaps %xmm0, -0xe0(%rbp)
movaps %xmm0, -0xf0(%rbp)
movaps %xmm0, -0x100(%rbp)
movaps %xmm0, -0x110(%rbp)
movq $0x4, -0xb0(%rbp)
movq $0x5, -0xa8(%rbp)
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1d79(%rip), %rsi      # 0xb4f5
leaq 0x1d81(%rip), %rdx      # 0xb504
leaq -0x48(%rbp), %rdi
callq 0xa378
movq $0x0, -0x60(%rbp)
movl $0x18, %edi
callq 0x21e0
movq $0x1, (%rax)
movq $0x3e8, 0x8(%rax)       # imm = 0x3E8
movq $0x2a, 0x10(%rax)
leaq -0x68(%rbp), %r14
movq %rax, (%r14)
leaq 0x111f(%rip), %rax      # 0xa8e2
movq %rax, 0x18(%r14)
leaq 0x1128(%rip), %rax      # 0xa8f6
movq %rax, 0x10(%r14)
xorl %ebx, %ebx
movq %r14, %rdi
callq *-0x50(%rbp)
movq %rax, %r12
movq -0x48(%rbp), %r13
movq -0x40(%rbp), %r15
cmpq $0x2, %r15
jb 0x982b
movl $0x1, %r14d
callq 0x2070
cltq
leaq 0x1(%r14), %rcx
cqto
idivq %rcx
cmpq %rdx, %r14
je 0x9817
addq %r13, %r14
addq %r13, %rdx
movb (%r14), %al
movb (%rdx), %sil
movb %sil, (%r14)
movb %al, (%rdx)
movq %rcx, %r14
cmpq %rcx, %r15
jne 0x97f1
movq -0x48(%rbp), %r13
movq -0x40(%rbp), %r15
leaq -0x68(%rbp), %r14
leaq -0x88(%rbp), %rax
movq %rax, -0x98(%rbp)
addq %r13, %r15
leaq -0x98(%rbp), %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x4420
leaq -0x110(%rbp), %rdi
leaq -0x98(%rbp), %rsi
movq %r12, %rdx
callq 0x259c
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x987c
callq 0x21c0
incq %rbx
cmpq $0x117, %rbx            # imm = 0x117
je 0x9898
cmpq $0x0, -0x58(%rbp)
jne 0x97d4
callq 0x20b0
leaq -0x1e0(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x44be
leaq -0x1c0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0xa184
leaq -0x1a8(%rbp), %r14
leaq -0xd8(%rbp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa204
movaps -0xc0(%rbp), %xmm0
movaps -0xb0(%rbp), %xmm1
leaq -0x1e0(%rbp), %rsi
movups %xmm1, 0x60(%rsi)
movups %xmm0, 0x50(%rsi)
leaq -0x170(%rbp), %rdi
movl $0xc350, %edx           # imm = 0xC350
callq 0x3c20
movq %r14, %rdi
callq 0xa150
movq -0x1c0(%rbp), %rdi
testq %rdi, %rdi
je 0x991e
callq 0x21c0
movq -0x1d0(%rbp), %rax
testq %rax, %rax
je 0x993b
leaq -0x1e0(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq -0x140(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x391c
leaq -0x170(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x3aa4
movsd %xmm0, -0x78(%rbp)
leaq -0x140(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x3aa4
movsd %xmm0, -0x70(%rbp)
movq 0x666b(%rip), %rdi      # 0xfff0
leaq 0x1b47(%rip), %rsi      # 0xb4d3
movl $0x10, %edx
callq 0x2200
movq 0x6653(%rip), %rdi      # 0xfff0
movsd -0x78(%rbp), %xmm0
callq 0x2260
leaq 0x1bbe(%rip), %rsi      # 0xb56c
movl $0x1, %edx
movq %rax, %rdi
callq 0x2200
movq 0x662e(%rip), %rdi      # 0xfff0
leaq 0x1b1b(%rip), %rsi      # 0xb4e4
movl $0x10, %edx
callq 0x2200
movq 0x6616(%rip), %rdi      # 0xfff0
movsd -0x70(%rbp), %xmm0
callq 0x2260
leaq 0x1b81(%rip), %rsi      # 0xb56c
movl $0x1, %edx
movq %rax, %rdi
callq 0x2200
leaq -0x140(%rbp), %rdi
callq 0x4ee0
leaq -0x170(%rbp), %rdi
callq 0x4ee0
movq -0x58(%rbp), %rax
testq %rax, %rax
je 0x9a27
leaq -0x68(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x9a39
callq 0x21c0
movq %rbx, %rdi
callq 0xa150
movq -0xf0(%rbp), %rdi
testq %rdi, %rdi
je 0x9a52
callq 0x21c0
movq -0x100(%rbp), %rax
testq %rax, %rax
je 0x9a6f
leaq -0x110(%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
jmp 0x9b72
jmp 0x9b72
jmp 0x9b72
jmp 0x9af6
movq %rax, %r14
jmp 0x9b05
movq %rax, %r14
leaq -0x1e0(%rbp), %rdi
callq 0x9fd6
jmp 0x9b35
movq %rax, %r14
movq -0x1c0(%rbp), %rdi
testq %rdi, %rdi
je 0x9ac6
callq 0x21c0
jmp 0x9ac6
movq %rax, %r14
movq -0x1d0(%rbp), %rax
testq %rax, %rax
je 0x9b35
leaq -0x1e0(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x9b35
jmp 0x9b72
jmp 0x9b32
movq %rax, %r14
jmp 0x9b4c
movq %rax, %r14
jmp 0x9b5e
movq %rax, %r14
leaq -0x140(%rbp), %rdi
callq 0x4ee0
leaq -0x170(%rbp), %rdi
callq 0x4ee0
jmp 0x9b35
jmp 0x9b32
movq %rax, %r14
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x9b35
callq 0x21c0
jmp 0x9b35
movq %rax, %r14
movq -0x58(%rbp), %rax
testq %rax, %rax
je 0x9b4c
leaq -0x68(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x9b5e
callq 0x21c0
leaq -0x110(%rbp), %rdi
callq 0x9fd6
movq %r14, %rdi
callq 0x22b0
movq %rax, %rdi
callq 0x4411