// File: /workspace/github_cpp_makefile_star2_O3/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 0x34c0
movabsq $-0x5555555555555555, %r14 # imm = 0xAAAAAAAAAAAAAAAB
xorl %ebx, %ebx
xorl %r15d, %r15d
addq %rbx, %rdi
callq 0x28ec
movq (%r12), %rdi
movq 0x8(%r12), %rax
incq %r15
addq $0xc0, %rbx
subq %rdi, %rax
sarq $0x6, %rax
imulq %r14, %rax
cmpq %rax, %r15
jb 0x3495
leaq 0x48(%r12), %rbx
xorl %esi, %esi
movq %rbx, %rdi
callq 0x2490
movl $0x1, %esi
movq %rbx, %rdi
movq %rbx, 0x18(%rsp)
callq 0x2490
movq (%r12), %rax
leaq 0x98(%r12), %rdi
movq %rdi, 0x70(%rsp)
movq 0x50(%rax), %rax
movq (%rax), %rsi
andl $0x1, %esi
callq 0x2490
leaq 0xe8(%r12), %rdi
xorl %esi, %esi
movq %rdi, 0x78(%rsp)
callq 0x2490
leaq 0x20(%rsp), %r13
leaq 0x138(%r12), %rdi
movq %r13, %rsi
movb $0x20, (%r13)
movq %rdi, 0x90(%rsp)
callq 0x3ed2
vxorps %xmm0, %xmm0, %xmm0
movl $0x40, %edi
vmovups %zmm0, 0x10(%r13)
movq $0x8, 0x8(%r13)
vzeroupper
callq 0x2180
movq %rax, %r15
movq %rax, (%r13)
movl $0x200, %edi            # imm = 0x200
callq 0x2180
movq %r15, %rcx
movq %rax, %rdx
addq $0x18, %rcx
addq $0x200, %rdx            # imm = 0x200
movq %rax, 0x18(%r15)
movq %rcx, 0x48(%rsp)
movq %rax, 0x38(%rsp)
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 0x3943
leaq 0x10(%rsp), %rsi
movq $0x1, (%rsi)
leaq 0x20(%rsp), %rdi
callq 0x25de
movq 0x30(%rsp), %rax
cmpq %rax, 0x50(%rsp)
je 0x3943
leaq 0x150(%r12), %rdx
leaq 0x140(%r12), %rcx
leaq 0x1a8(%r12), %rsi
movq %r12, 0x88(%rsp)
movq %rdx, 0xc0(%rsp)
leaq 0x1a0(%r12), %rdx
movq %rcx, 0xa0(%rsp)
movq %rsi, 0x98(%rsp)
movq %rdx, 0xb8(%rsp)
movq (%rax), %rdx
movq %rdx, %rax
andq $0xffffff, %rax         # imm = 0xFFFFFF
movq %rax, 0x8(%rsp)
je 0x38d9
movq 0x8(%rsp), %rcx
movq (%r12), %rax
movq %rdx, %r15
shrq $0x18, %r15
leaq (%rcx,%rcx,2), %rcx
movq %rcx, 0x80(%rsp)
shll $0x6, %ecx
movq (%rax,%rcx), %rax
movq %rdx, %rcx
shrq $0x1e, %rcx
movq (%rax,%rcx,8), %rax
btq %r15, %rax
jb 0x38d9
movq 0x80(%rsp), %rax
shll $0x6, %eax
movq %rax, 0xa8(%rsp)
movq 0x18(%rsp), %rdi
xorl %esi, %esi
movq %rdx, 0xb0(%rsp)
callq 0x2490
movq (%r12), %rbx
movq 0xa8(%rsp), %r14
movq %r15, %rdx
movq (%rbx,%r14), %rdi
movq 0x18(%rbx,%r14), %rsi
callq 0x27ba
movq 0xa0(%rbx,%r14), %rdx
movq 0x140(%r12), %rsi
subq %rax, %r15
addq %r15, %rdx
cmpq 0x148(%r12), %rsi
je 0x36ef
movq 0xa0(%rsp), %rax
movq 0x8(%rsp), %r13
jmp 0x381f
movq 0x90(%rsp), %rdi
callq 0x3ffa
movq 0x8(%rsp), %r13
movq %r13, %rax
shlq $0x6, %rax
movq %r15, %r14
leaq (%rax,%rax,2), %rbp
movq (%r12), %rbx
testq %r14, %r14
je 0x3746
leaq 0xc0(%rbx,%rbp), %r12
leaq -0x1(%r14), %rsi
movq %r12, %rdi
callq 0x2802
movq -0x70(%r12), %rdx
movq %r14, %rcx
shrq $0x6, %rcx
movq %rax, %r15
incq %r15
shrxq %r14, (%rdx,%rcx,8), %rax
jmp 0x3751
movq 0x50(%rbx,%rbp), %rax
xorl %r15d, %r15d
movq (%rax), %rax
testb $0x1, %al
jne 0x37d9
movq 0xc0(%rbx,%rbp), %rax
leaq 0x1(%r15), %rcx
movq 0x88(%rsp), %r12
movq %rcx, %rdx
shrq $0x6, %rdx
movq (%rax,%rdx,8), %rdx
btq %rcx, %rdx
jae 0x37e9
xorl %esi, %esi
cmpq %r13, 0x8(%rsp)
sete %sil
movq 0xc0(%rsp), %rdi
callq 0x2490
movq (%r12), %rax
movq 0x1a8(%r12), %rsi
subq %r14, %r15
movq 0x160(%rax,%rbp), %rdx
addq %r15, %rdx
cmpq 0x1b0(%r12), %rsi
jne 0x3814
addq $0xc0, %rbp
incq %r13
movq 0xb8(%rsp), %rdi
callq 0x3ffa
movq %r15, %r14
jmp 0x370f
movq 0xc0(%rbx,%rbp), %rax
movq 0x88(%rsp), %r12
movq %r15, %rcx
shrq $0x6, %rcx
movq (%rax,%rcx,8), %rax
btq %r15, %rax
jae 0x382b
movq $0x0, 0x10(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x25de
jmp 0x384f
movq 0x98(%rsp), %rax
incq %r13
movb (%rdx), %cl
movb %cl, (%rsi)
incq (%rax)
jmp 0x3701
leaq 0x1(%r13), %rax
shlq $0x18, %r15
andl $0xffffff, %eax         # imm = 0xFFFFFF
orq %rax, %r15
movq %r15, 0x10(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x25de
xorl %esi, %esi
cmpq 0x8(%rsp), %r13
seta %sil
movq 0x78(%rsp), %rdi
callq 0x2490
movq (%r12), %rax
movq %r14, %rcx
shrq $0x6, %rcx
movq 0x50(%rax,%rbp), %rax
shrxq %r14, (%rax,%rcx,8), %rsi
andl $0x1, %esi
movq 0x70(%rsp), %rdi
callq 0x2490
movq (%r12), %rcx
movq 0xb0(%rsp), %rsi
movq 0x8(%rsp), %rax
movq 0x80(%rsp), %rdx
shll $0x6, %edx
movq (%rcx,%rdx), %rcx
andq $-0x1000000, %rsi       # imm = 0xFF000000
leaq 0x1000000(%rsi,%rax), %rax
addq $0x1000000, %rsi        # imm = 0x1000000
movq %rsi, %r15
shrq $0x1e, %rsi
shrq $0x18, %r15
movq %rax, %rdx
movq (%rcx,%rsi,8), %rcx
btq %r15, %rcx
jae 0x368c
movq 0x18(%rsp), %rdi
movl $0x1, %esi
callq 0x2490
movq 0x40(%rsp), %rcx
movq 0x30(%rsp), %rax
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x3901
addq $0x8, %rax
jmp 0x3933
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
leaq 0x200(%rax), %rcx
movq %rax, 0x38(%rsp)
movq %rcx, 0x40(%rsp)
movq %rax, 0x30(%rsp)
cmpq %rax, 0x50(%rsp)
jne 0x362a
movq 0x18(%rsp), %rdi
callq 0x28ec
movq 0x70(%rsp), %rdi
callq 0x28ec
movq 0x78(%rsp), %rdi
callq 0x28ec
addq $0x150, %r12            # imm = 0x150
movl $0x1, %esi
movq %r12, %rdi
callq 0x2490
movq %r12, %rdi
callq 0x28ec
movq 0x20(%rsp), %rbx
testq %rbx, %rbx
je 0x39c6
movq 0x68(%rsp), %r15
movq 0x48(%rsp), %r14
leaq 0x8(%r15), %rax
cmpq %rax, %r14
jae 0x39b5
addq $-0x8, %r14
movq 0x8(%r14), %rdi
movl $0x200, %esi            # imm = 0x200
addq $0x8, %r14
callq 0x2190
cmpq %r15, %r14
jb 0x399e
movq 0x28(%rsp), %rsi
movq %rbx, %rdi
shlq $0x3, %rsi
callq 0x2190
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3a39
movq %rax, %rdi
callq 0x2090
callq 0x21b0
movq %rax, %rbx
callq 0x21f0
movq %rbx, %rdi
callq 0x2090
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdi
shlq $0x3, %rsi
callq 0x2190
vxorps %xmm0, %xmm0, %xmm0
vmovaps %xmm0, 0x20(%rsp)
callq 0x21b0
movq %rax, %rbx
callq 0x21f0
jmp 0x3a5a
jmp 0x3a25
movq %rax, %rdi
callq 0x3d33
jmp 0x3a39
jmp 0x3a39
jmp 0x3a39
jmp 0x3a39
jmp 0x3a39
jmp 0x3a39
movq 0x20(%rsp), %rcx
movq %rax, %rbx
testq %rcx, %rcx
je 0x3a5a
leaq 0x28(%rsp), %rdx
leaq 0x48(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x2240
movq %rbx, %rdi
callq 0x2200