// File: /workspace/github_cpp_makefile_star2_O1/s-yata[P]louds-patricia/louds-patricia.cpp
// Function: louds::PatriciaImpl::build()
void build() {
    trie_.build();

    louds_.add(0);
    louds_.add(1);
    outs_.add(trie_.levels[0].outs.get(0));
    links_.add(0);
    labels_.push_back(' ');

    queue<Node> queue;
    if (!trie_.levels[1].louds.get(0)) {
      queue.push(Node{ 1, 0 });
    }
    while (!queue.empty()) {
      Node node = queue.front();
      if (node.level_id != 0) {
        while (!trie_.levels[node.level_id].louds.get(node.node_pos)) {
          louds_.add(0);
          uint64_t level_id = node.level_id;
          uint64_t node_pos = node.node_pos;
          uint64_t node_id = node_pos - trie_.levels[level_id].louds.rank(node_pos);
          labels_.push_back(trie_.levels[level_id].labels[node_id]);
          for ( ; ; ) {
            node_pos = (node_id == 0) ? 0 :
              trie_.levels[level_id + 1].louds.select(node_id - 1) + 1;
            if (trie_.levels[level_id].outs.get(node_id) ||
              !trie_.levels[level_id + 1].louds.get(node_pos + 1)) {
              break;
            }
            node_id = node_pos - node_id;
            tail_bits_.add(level_id == node.level_id);
            ++level_id;
            tail_bytes_.push_back(trie_.levels[level_id].labels[node_id]);
          }
          if (!trie_.levels[level_id + 1].louds.get(node_pos)) {
            queue.push(Node{ level_id + 1, node_pos });
          } else {
            queue.push(Node{ 0, 0 });
          }
          links_.add(level_id > node.level_id);
          outs_.add(trie_.levels[level_id].outs.get(node_id));
          ++node.node_pos;
          ++node_id;
        }
      }
      louds_.add(1);
      queue.pop();
    }

    louds_.build();
    outs_.build();
    links_.build();
    tail_bits_.add(1);
    tail_bits_.build();

    // Note: trie_ is no longer required.
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdi, %r12
movq (%rdi), %rdi
cmpq %rdi, 0x8(%r12)
je 0x34f8
xorl %ebx, %ebx
movabsq $-0x5555555555555555, %r14 # imm = 0xAAAAAAAAAAAAAAAB
xorl %r15d, %r15d
addq %rbx, %rdi
callq 0x2904
incq %r15
movq (%r12), %rdi
movq 0x8(%r12), %rax
subq %rdi, %rax
sarq $0x6, %rax
imulq %r14, %rax
addq $0xc0, %rbx
cmpq %rax, %r15
jb 0x34cd
leaq 0x48(%r12), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2492
movl $0x1, %esi
movq %rbx, 0x18(%rsp)
movq %rbx, %rdi
callq 0x2492
leaq 0x98(%r12), %rdi
movq (%r12), %rax
movq 0x50(%rax), %rax
movq (%rax), %rsi
andl $0x1, %esi
movq %rdi, 0x78(%rsp)
callq 0x2492
leaq 0xe8(%r12), %rdi
movq %rdi, 0x80(%rsp)
xorl %esi, %esi
callq 0x2492
leaq 0x138(%r12), %rdi
leaq 0x20(%rsp), %r13
movb $0x20, (%r13)
movq %rdi, 0x90(%rsp)
movq %r13, %rsi
callq 0x3f3a
vxorps %xmm0, %xmm0, %xmm0
vmovups %zmm0, (%r13)
vmovups %zmm0, 0x10(%r13)
movq $0x8, 0x8(%r13)
movl $0x40, %edi
vzeroupper
callq 0x2180
movq %rax, %r15
movq %rax, (%r13)
movl $0x200, %edi            # imm = 0x200
callq 0x2180
movq %r15, %rcx
addq $0x18, %rcx
movq %rax, 0x18(%r15)
movq %rcx, 0x48(%rsp)
movq %rax, 0x38(%rsp)
movq %rax, %rdx
addq $0x200, %rdx            # imm = 0x200
movq %rdx, 0x40(%rsp)
movq %rcx, 0x68(%rsp)
movq %rax, 0x58(%rsp)
movq %rdx, 0x60(%rsp)
movq %rax, 0x30(%rsp)
movq %rax, 0x50(%rsp)
movq (%r12), %rax
movq 0xc0(%rax), %rax
testb $0x1, (%rax)
jne 0x3610
leaq 0x10(%rsp), %rsi
movq $0x1, (%rsi)
leaq 0x20(%rsp), %rdi
callq 0x25dc
movq 0x30(%rsp), %rax
cmpq %rax, 0x50(%rsp)
je 0x396c
leaq 0x140(%r12), %rcx
movq %rcx, 0xa0(%rsp)
leaq 0x150(%r12), %rcx
movq %rcx, 0xc0(%rsp)
leaq 0x1a8(%r12), %rcx
movq %rcx, 0x98(%rsp)
leaq 0x1a0(%r12), %rcx
movq %rcx, 0xb8(%rsp)
movq %r12, 0x8(%rsp)
movq (%rax), %r14
testl $0xffffff, %r14d        # imm = 0xFFFFFF
je 0x3902
movl %r14d, %ecx
andl $0xffffff, %ecx         # imm = 0xFFFFFF
movq (%r12), %rax
movq %rcx, (%rsp)
leaq (%rcx,%rcx,2), %rcx
movq %rcx, 0x88(%rsp)
shll $0x6, %ecx
movq %r14, %rbx
shrq $0x18, %rbx
movq %r14, %rdx
shrq $0x1e, %rdx
movq (%rax,%rcx), %rax
movq (%rax,%rdx,8), %rax
btq %rbx, %rax
jb 0x3902
movq 0x88(%rsp), %rax
shll $0x6, %eax
movq %rax, 0xa8(%rsp)
movq 0x18(%rsp), %rdi
xorl %esi, %esi
callq 0x2492
movq %r14, 0xb0(%rsp)
movq (%r12), %r14
movq 0xa8(%rsp), %r15
leaq (%r14,%r15), %rdi
movq %rbx, %rsi
callq 0x27b8
subq %rax, %rbx
movq 0xa0(%r14,%r15), %rdx
addq %rbx, %rdx
movq 0x140(%r12), %rsi
cmpq 0x148(%r12), %rsi
je 0x3725
movq 0xa0(%rsp), %rax
movq (%rsp), %r14
jmp 0x3848
movq 0x90(%rsp), %rdi
callq 0x405a
movq (%rsp), %r14
movq %r14, %rax
shlq $0x6, %rax
leaq (%rax,%rax,2), %rbp
movq %rbx, %r15
movq 0x8(%rsp), %r12
testq %r15, %r15
je 0x376b
movq (%r12), %rax
leaq 0xc0(%rax,%rbp), %rdi
leaq -0x1(%r15), %rsi
callq 0x2808
movq %rax, %rbx
incq %rbx
jmp 0x376d
xorl %ebx, %ebx
movq (%r12), %rax
movq %r15, %r13
shrq $0x6, %r13
movq 0x50(%rax,%rbp), %rcx
movq (%rcx,%r13,8), %rcx
movl %r15d, %r12d
andl $0x3f, %r12d
btq %r12, %rcx
jb 0x380a
leaq 0x1(%rbx), %rcx
movq %rcx, %rdx
shrq $0x6, %rdx
movq 0xc0(%rax,%rbp), %rsi
movq (%rsi,%rdx,8), %rdx
btq %rcx, %rdx
jae 0x380a
xorl %esi, %esi
cmpq %r14, (%rsp)
sete %sil
movq 0xc0(%rsp), %rdi
callq 0x2492
movq 0x8(%rsp), %r12
subq %r15, %rbx
movq (%r12), %rax
movq 0x1a8(%r12), %rsi
movq 0x160(%rax,%rbp), %rdx
addq %rbx, %rdx
cmpq 0x1b0(%r12), %rsi
jne 0x383d
addq $0xc0, %rbp
incq %r14
movq 0xb8(%rsp), %rdi
callq 0x405a
movq %rbx, %r15
jmp 0x3749
movq %rbx, %rcx
shrq $0x6, %rcx
movq 0xc0(%rax,%rbp), %rax
movq (%rax,%rcx,8), %rax
btq %rbx, %rax
jae 0x3854
movq $0x0, 0x10(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x25dc
jmp 0x3878
incq %r14
movq 0x98(%rsp), %rax
movb (%rdx), %cl
movb %cl, (%rsi)
incq (%rax)
jmp 0x3736
leaq 0x1(%r14), %rax
andl $0xffffff, %eax         # imm = 0xFFFFFF
shlq $0x18, %rbx
orq %rax, %rbx
movq %rbx, 0x10(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x25dc
xorl %esi, %esi
cmpq (%rsp), %r14
seta %sil
movq 0x80(%rsp), %rdi
callq 0x2492
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x50(%rax,%rbp), %rax
shrxq %r12, (%rax,%r13,8), %rsi
andl $0x1, %esi
movq 0x78(%rsp), %rdi
callq 0x2492
movq 0xb0(%rsp), %rsi
andq $-0x1000000, %rsi       # imm = 0xFF000000
movq (%rsp), %rax
leaq 0x1000000(%rsi,%rax), %r14
addq $0x1000000, %rsi        # imm = 0x1000000
movq 0x8(%rsp), %r12
movq (%r12), %rcx
movq 0x88(%rsp), %rdx
shll $0x6, %edx
movq %rsi, %rbx
shrq $0x18, %rbx
shrq $0x1e, %rsi
movq (%rcx,%rdx), %rcx
movq (%rcx,%rsi,8), %rcx
btq %rbx, %rcx
jae 0x36c8
movl $0x1, %esi
movq 0x18(%rsp), %rdi
callq 0x2492
movq 0x30(%rsp), %rax
movq 0x40(%rsp), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x392a
addq $0x8, %rax
jmp 0x395c
movq 0x38(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x2190
movq 0x48(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x48(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
leaq 0x200(%rax), %rcx
movq %rcx, 0x40(%rsp)
movq %rax, 0x30(%rsp)
cmpq %rax, 0x50(%rsp)
jne 0x3665
movq 0x18(%rsp), %rdi
callq 0x2904
movq 0x78(%rsp), %rdi
callq 0x2904
movq 0x80(%rsp), %rdi
callq 0x2904
addq $0x150, %r12            # imm = 0x150
movl $0x1, %esi
movq %r12, %rdi
callq 0x2492
movq %r12, %rdi
callq 0x2904
movq 0x20(%rsp), %rbx
testq %rbx, %rbx
je 0x39f2
movq 0x48(%rsp), %r14
movq 0x68(%rsp), %r15
leaq 0x8(%r15), %rax
cmpq %rax, %r14
jae 0x39e1
addq $-0x8, %r14
movq 0x8(%r14), %rdi
addq $0x8, %r14
movl $0x200, %esi            # imm = 0x200
callq 0x2190
cmpq %r15, %r14
jb 0x39ca
movq 0x28(%rsp), %rsi
shlq $0x3, %rsi
movq %rbx, %rdi
callq 0x2190
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3a65
movq %rax, %rdi
callq 0x2090
callq 0x21b0
movq %rax, %rbx
callq 0x21f0
movq %rbx, %rdi
callq 0x2090
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
shlq $0x3, %rsi
callq 0x2190
vxorps %xmm0, %xmm0, %xmm0
vmovaps %xmm0, 0x20(%rsp)
callq 0x21b0
movq %rax, %rbx
callq 0x21f0
jmp 0x3a86
jmp 0x3a51
movq %rax, %rdi
callq 0x3da0
jmp 0x3a65
jmp 0x3a65
jmp 0x3a65
jmp 0x3a65
jmp 0x3a65
jmp 0x3a65
movq %rax, %rbx
movq 0x20(%rsp), %rcx
testq %rcx, %rcx
je 0x3a86
leaq 0x28(%rsp), %rdx
leaq 0x48(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x2240
movq %rbx, %rdi
callq 0x2200