// File: /workspace/github_cpp_makefile_star2_O3/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 0x222c(%rip), %rsi      # 0xb329
leaq 0x2228(%rip), %rdx      # 0xb32c
leaq -0x2c0(%rbp), %r12
movq %r12, %rdi
callq 0xa378
leaq -0x2a0(%rbp), %r15
leaq -0x290(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x2255(%rip), %rsi      # 0xb381
leaq 0x2254(%rip), %rdx      # 0xb387
movq %r15, %rdi
callq 0xa378
leaq -0x280(%rbp), %r15
leaq -0x270(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x2366(%rip), %rsi      # 0xb4ba
leaq 0x2363(%rip), %rdx      # 0xb4be
movq %r15, %rdi
callq 0xa378
leaq -0x260(%rbp), %r15
leaq -0x250(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x2343(%rip), %rsi      # 0xb4bf
leaq 0x2341(%rip), %rdx      # 0xb4c4
movq %r15, %rdi
callq 0xa378
leaq -0x240(%rbp), %r15
leaq -0x230(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x2321(%rip), %rsi      # 0xb4c5
leaq 0x2320(%rip), %rdx      # 0xb4cb
movq %r15, %rdi
callq 0xa378
leaq -0x220(%rbp), %r15
leaq -0x210(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x2300(%rip), %rsi      # 0xb4cc
leaq 0x22ff(%rip), %rdx      # 0xb4d2
movq %r15, %rdi
callq 0xa378
leaq -0x200(%rbp), %r15
leaq -0x1f0(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x230c(%rip), %rsi      # 0xb500
leaq 0x2309(%rip), %rdx      # 0xb504
movq %r15, %rdi
callq 0xa378
movq $0x0, -0x40(%rbp)
movl $0x18, %edi
callq 0x21e0
xorl %ecx, %ecx
movq %rcx, (%rax)
movq $0x6, 0x8(%rax)
movq $0x2a, 0x10(%rax)
movq %rax, -0x48(%rbp)
leaq 0x1487(%rip), %rax      # 0xa6bc
movq %rax, -0x30(%rbp)
leaq 0x1490(%rip), %rax      # 0xa6d0
movq %rax, -0x38(%rbp)
movq %rcx, -0x60(%rbp)
movl $0x18, %edi
callq 0x21e0
movq $0x1, (%rax)
movq $0x3e8, 0x8(%rax)       # imm = 0x3E8
movq $0x2a, 0x10(%rax)
leaq -0x68(%rbp), %rcx
movq %rax, (%rcx)
leaq 0x166b(%rip), %rax      # 0xa8e2
movq %rax, 0x18(%rcx)
leaq 0x1674(%rip), %rax      # 0xa8f6
movq %rax, 0x10(%rcx)
movl $0x32, %r15d
cmpq $0x0, -0x38(%rbp)
je 0x957f
leaq -0x48(%rbp), %rdi
callq *-0x30(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x9584
movq %rax, %r13
leaq -0x68(%rbp), %rdi
callq *-0x50(%rbp)
leaq -0xc8(%rbp), %r12
movq %rax, %rbx
shlq $0x5, %r13
leaq -0xb8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x2c0(%rbp,%r13), %rsi
movq -0x2b8(%rbp,%r13), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x4420
leaq -0x140(%rbp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x259c
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0x9314
callq 0x21c0
leaq -0xa8(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x3316
movq -0xa8(%rbp), %rsi
movq -0xa0(%rbp), %rdx
movq 0x6cb4(%rip), %rdi      # 0xfff0
callq 0x2200
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x9359
callq 0x21c0
decq %r15
jne 0x928c
leaq -0x1e0(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x44be
leaq -0x1c0(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0xa184
leaq -0x1a8(%rbp), %r15
leaq -0x108(%rbp), %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0xa204
movaps -0xf0(%rbp), %xmm0
movaps -0xe0(%rbp), %xmm1
leaq -0x1e0(%rbp), %rsi
movups %xmm1, 0x60(%rsi)
movups %xmm0, 0x50(%rsi)
leaq -0xa8(%rbp), %rdi
movl $0xc350, %edx           # imm = 0xC350
callq 0x3c20
movq %r15, %rdi
callq 0xa150
movq -0x1c0(%rbp), %rdi
testq %rdi, %rdi
je 0x93e8
callq 0x21c0
movq -0x1d0(%rbp), %rax
testq %rax, %rax
je 0x9405
leaq -0x1e0(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq -0x170(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x391c
leaq -0xa8(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x3aa4
movsd %xmm0, -0x78(%rbp)
leaq -0x170(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x3aa4
movsd %xmm0, -0x70(%rbp)
movq 0x6ba1(%rip), %rdi      # 0xfff0
leaq 0x207d(%rip), %rsi      # 0xb4d3
movl $0x10, %edx
callq 0x2200
movq 0x6b89(%rip), %rdi      # 0xfff0
movsd -0x78(%rbp), %xmm0
callq 0x2260
leaq 0x20f4(%rip), %rsi      # 0xb56c
movl $0x1, %edx
movq %rax, %rdi
callq 0x2200
movq 0x6b64(%rip), %rdi      # 0xfff0
leaq 0x2051(%rip), %rsi      # 0xb4e4
movl $0x10, %edx
callq 0x2200
movq 0x6b4c(%rip), %rdi      # 0xfff0
movsd -0x70(%rbp), %xmm0
callq 0x2260
leaq 0x20b7(%rip), %rsi      # 0xb56c
movl $0x1, %edx
movq %rax, %rdi
callq 0x2200
leaq -0x170(%rbp), %rdi
callq 0x4ee0
leaq -0xa8(%rbp), %rdi
callq 0x4ee0
movq -0x58(%rbp), %rax
testq %rax, %rax
je 0x94f1
leaq -0x68(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq -0x38(%rbp), %rax
testq %rax, %rax
je 0x9508
leaq -0x48(%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 0x9528
callq 0x21c0
addq $-0x20, %r15
cmpq $-0xe0, %r15
jne 0x9512
movq %rbx, %rdi
callq 0xa150
movq -0x120(%rbp), %rdi
testq %rdi, %rdi
je 0x954e
callq 0x21c0
movq -0x130(%rbp), %rax
testq %rax, %rax
je 0x956b
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 0x970e
jmp 0x970e
jmp 0x970e
jmp 0x970e
jmp 0x9653
movq %rax, %rbx
jmp 0x9662
movq %rax, %rbx
leaq -0x1e0(%rbp), %rdi
callq 0x9fd6
jmp 0x96ab
movq %rax, %rbx
movq -0x1c0(%rbp), %rdi
testq %rdi, %rdi
je 0x95d7
callq 0x21c0
jmp 0x95d7
movq %rax, %rbx
movq -0x1d0(%rbp), %rax
testq %rax, %rax
je 0x96ab
leaq -0x1e0(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x96ab
jmp 0x970e
jmp 0x96a8
movq %rax, %rbx
jmp 0x96c2
movq %rax, %rbx
jmp 0x96d9
jmp 0x9621
jmp 0x9621
jmp 0x9621
jmp 0x9621
jmp 0x9621
movq %rax, %rbx
addq $-0x10, %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x9636
callq 0x21c0
leaq -0x20(%r15), %rax
addq $-0x10, %r15
cmpq %r12, %r15
movq %rax, %r15
jne 0x9628
jmp 0x96f8
movq %rax, %rbx
jmp 0x96f8
movq %rax, %rbx
leaq -0x170(%rbp), %rdi
callq 0x4ee0
leaq -0xa8(%rbp), %rdi
callq 0x4ee0
jmp 0x96ab
jmp 0x96a8
jmp 0x96a8
jmp 0x96a8
movq %rax, %rbx
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
jmp 0x969c
jmp 0x96a8
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x96ab
callq 0x21c0
jmp 0x96ab
movq %rax, %rbx
movq -0x58(%rbp), %rax
testq %rax, %rax
je 0x96c2
leaq -0x68(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq -0x38(%rbp), %rax
testq %rax, %rax
je 0x96d9
leaq -0x48(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq $-0xe0, %r15
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0x96ee
callq 0x21c0
addq $-0x20, %r14
addq $0x20, %r15
jne 0x96e0
leaq -0x140(%rbp), %rdi
callq 0x9fd6
movq %rbx, %rdi
callq 0x22b0
jmp 0x970e
movq %rax, %rdi
callq 0x4411