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

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

  // Generate a set of label names.
  std::string labels[7] = {"red", "yellow", "pink", "green", "purple", 
                           "orange", "blue"};

  // Make a random number generator for marble labels
  std::default_random_engine label_generator(VoseUtil::RANDOM_SEED); 
  std::uniform_int_distribution<size_t>
    label_distribution(0, 7-1);
  std::function<size_t()> random_label =
    std::bind(label_distribution, label_generator);
  
  // 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);

  for(size_t i = 0; i != 50; ++i) {
    // Get a random marble with random label and random weight.
    size_t label_idx = random_label();
    size_t weight = random_weight();
    //std::cerr << "label_idx: " << label_idx << ", " << labels[label_idx] << "\n";
    //std::cerr << " weight: " << weight << "\n";
    tree.add(std::string(labels[label_idx]), 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 $0x298, %rsp            # imm = 0x298
xorps %xmm0, %xmm0
movaps %xmm0, -0xf0(%rbp)
movaps %xmm0, -0x100(%rbp)
movaps %xmm0, -0x110(%rbp)
movaps %xmm0, -0x120(%rbp)
movaps %xmm0, -0x130(%rbp)
movaps %xmm0, -0x140(%rbp)
movq $0x4, -0xe0(%rbp)
movq $0x5, -0xd8(%rbp)
leaq -0x2b0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1dd0(%rip), %rsi      # 0xb329
leaq 0x1dcc(%rip), %rdx      # 0xb32c
leaq -0x2c0(%rbp), %r12
movq %r12, %rdi
callq 0xa7de
leaq -0x2a0(%rbp), %r14
leaq -0x290(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1df9(%rip), %rsi      # 0xb381
leaq 0x1df8(%rip), %rdx      # 0xb387
movq %r14, %rdi
callq 0xa7de
leaq -0x280(%rbp), %r14
leaq -0x270(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f0a(%rip), %rsi      # 0xb4ba
leaq 0x1f07(%rip), %rdx      # 0xb4be
movq %r14, %rdi
callq 0xa7de
leaq -0x260(%rbp), %r14
leaq -0x250(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ee7(%rip), %rsi      # 0xb4bf
leaq 0x1ee5(%rip), %rdx      # 0xb4c4
movq %r14, %rdi
callq 0xa7de
leaq -0x240(%rbp), %r14
leaq -0x230(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ec5(%rip), %rsi      # 0xb4c5
leaq 0x1ec4(%rip), %rdx      # 0xb4cb
movq %r14, %rdi
callq 0xa7de
leaq -0x220(%rbp), %r14
leaq -0x210(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ea4(%rip), %rsi      # 0xb4cc
leaq 0x1ea3(%rip), %rdx      # 0xb4d2
movq %r14, %rdi
callq 0xa7de
leaq -0x200(%rbp), %r14
leaq -0x1f0(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x1eb0(%rip), %rsi      # 0xb500
leaq 0x1ead(%rip), %rdx      # 0xb504
movq %r14, %rdi
callq 0xa7de
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movaps %xmm0, -0x50(%rbp)
movl $0x18, %edi
callq 0x21e0
movq $0x0, (%rax)
movq $0x6, 0x8(%rax)
movq $0x2a, 0x10(%rax)
movq %rax, -0x50(%rbp)
leaq 0x1492(%rip), %rax      # 0xab28
movq %rax, -0x38(%rbp)
leaq 0x149b(%rip), %rax      # 0xab3c
movq %rax, -0x40(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
movaps %xmm0, -0x70(%rbp)
movl $0x18, %edi
callq 0x21e0
movq $0x1, (%rax)
movq $0x3e8, 0x8(%rax)       # imm = 0x3E8
movq $0x2a, 0x10(%rax)
leaq -0x70(%rbp), %rcx
movq %rax, (%rcx)
leaq 0x166b(%rip), %rax      # 0xad4a
movq %rax, 0x18(%rcx)
leaq 0x1674(%rip), %rax      # 0xad5e
movq %rax, 0x10(%rcx)
movl $0x32, %r14d
cmpq $0x0, -0x40(%rbp)
je 0x99e7
leaq -0x50(%rbp), %rdi
callq *-0x38(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x99ec
movq %rax, %r13
leaq -0x70(%rbp), %rdi
callq *-0x58(%rbp)
leaq -0xd0(%rbp), %r12
movq %rax, %rbx
shlq $0x5, %r13
leaq -0xc0(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x2c0(%rbp,%r13), %rsi
movq -0x2b8(%rbp,%r13), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x4742
leaq -0x140(%rbp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x259c
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x977c
callq 0x21c0
leaq -0xb0(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x374e
movq -0xb0(%rbp), %rsi
movq -0xa8(%rbp), %rdx
movq 0x684c(%rip), %rdi      # 0xfff0
callq 0x2200
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x97c1
callq 0x21c0
decq %r14
jne 0x96f4
leaq -0x1e0(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x47dc
leaq -0x1c0(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0xa5ea
leaq -0x1a8(%rbp), %r14
leaq -0x108(%rbp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa66a
movaps -0xf0(%rbp), %xmm0
movaps -0xe0(%rbp), %xmm1
leaq -0x1e0(%rbp), %rsi
movups %xmm1, 0x60(%rsi)
movups %xmm0, 0x50(%rsi)
leaq -0xb0(%rbp), %rdi
movl $0xc350, %edx           # imm = 0xC350
callq 0x4056
movq %r14, %rdi
callq 0xa5b6
movq -0x1c0(%rbp), %rdi
testq %rdi, %rdi
je 0x9850
callq 0x21c0
movq -0x1d0(%rbp), %rax
testq %rax, %rax
je 0x986d
leaq -0x1e0(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq -0x170(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x3d54
leaq -0xb0(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x3edc
movsd %xmm0, -0x80(%rbp)
leaq -0x170(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x3edc
movsd %xmm0, -0x78(%rbp)
movq 0x6739(%rip), %rdi      # 0xfff0
leaq 0x1c15(%rip), %rsi      # 0xb4d3
movl $0x10, %edx
callq 0x2200
movq 0x6721(%rip), %rdi      # 0xfff0
movsd -0x80(%rbp), %xmm0
callq 0x2260
leaq 0x1c8c(%rip), %rsi      # 0xb56c
movl $0x1, %edx
movq %rax, %rdi
callq 0x2200
movq 0x66fc(%rip), %rdi      # 0xfff0
leaq 0x1be9(%rip), %rsi      # 0xb4e4
movl $0x10, %edx
callq 0x2200
movq 0x66e4(%rip), %rdi      # 0xfff0
movsd -0x78(%rbp), %xmm0
callq 0x2260
leaq 0x1c4f(%rip), %rsi      # 0xb56c
movl $0x1, %edx
movq %rax, %rdi
callq 0x2200
leaq -0x170(%rbp), %rdi
callq 0x52c6
leaq -0xb0(%rbp), %rdi
callq 0x52c6
movq -0x60(%rbp), %rax
testq %rax, %rax
je 0x9959
leaq -0x70(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq -0x40(%rbp), %rax
testq %rax, %rax
je 0x9970
leaq -0x50(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq -0x1f0(%rbp), %r14
xorl %r15d, %r15d
movq -0x200(%rbp,%r15), %rdi
leaq (%r14,%r15), %rax
cmpq %rdi, %rax
je 0x9990
callq 0x21c0
addq $-0x20, %r15
cmpq $-0xe0, %r15
jne 0x997a
movq %rbx, %rdi
callq 0xa5b6
movq -0x120(%rbp), %rdi
testq %rdi, %rdi
je 0x99b6
callq 0x21c0
movq -0x130(%rbp), %rax
testq %rax, %rax
je 0x99d3
leaq -0x140(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movb $0x1, %al
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x20b0
callq 0x20b0
jmp 0x9b86
jmp 0x9b86
jmp 0x9b86
jmp 0x9b86
jmp 0x9acb
movq %rax, %rbx
jmp 0x9ada
movq %rax, %rbx
leaq -0x1e0(%rbp), %rdi
callq 0xa43c
jmp 0x9b23
movq %rax, %rbx
movq -0x1c0(%rbp), %rdi
testq %rdi, %rdi
je 0x9a3f
callq 0x21c0
jmp 0x9a3f
movq %rax, %rbx
movq -0x1d0(%rbp), %rax
testq %rax, %rax
je 0x9b23
leaq -0x1e0(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x9b23
jmp 0x9b86
jmp 0x9b20
movq %rax, %rbx
jmp 0x9b3a
movq %rax, %rbx
jmp 0x9b51
jmp 0x9a89
jmp 0x9a89
jmp 0x9a89
jmp 0x9a89
jmp 0x9a89
movq %rax, %rbx
cmpq %r14, %r12
je 0x9b70
addq $-0x10, %r14
leaq -0x2c0(%rbp), %r15
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0x9aae
callq 0x21c0
leaq -0x20(%r14), %rax
addq $-0x10, %r14
cmpq %r15, %r14
movq %rax, %r14
jne 0x9aa0
jmp 0x9b70
movq %rax, %rbx
movq %r12, %r14
jmp 0x9a8c
movq %rax, %rbx
leaq -0x170(%rbp), %rdi
callq 0x52c6
leaq -0xb0(%rbp), %rdi
callq 0x52c6
jmp 0x9b23
jmp 0x9b20
jmp 0x9b20
jmp 0x9b20
movq %rax, %rbx
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
jmp 0x9b14
jmp 0x9b20
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x9b23
callq 0x21c0
jmp 0x9b23
movq %rax, %rbx
movq -0x60(%rbp), %rax
testq %rax, %rax
je 0x9b3a
leaq -0x70(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq -0x40(%rbp), %rax
testq %rax, %rax
je 0x9b51
leaq -0x50(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq $-0xe0, %r14
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x9b66
callq 0x21c0
addq $-0x20, %r15
addq $0x20, %r14
jne 0x9b58
leaq -0x140(%rbp), %rdi
callq 0xa43c
movq %rbx, %rdi
callq 0x22b0
jmp 0x9b86
movq %rax, %rdi
callq 0x4733