// File: /workspace/github_cpp_makefile_star2_O2/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 $0xa8, %rsp
movl $0xc0, %r14d
movq %rdi, %rbp
xorl %ebx, %ebx
xorl %r15d, %r15d
movq (%rbp), %rdi
movq 0x8(%rbp), %rax
subq %rdi, %rax
cqto
idivq %r14
cmpq %rax, %r15
jae 0x310e
addq %rbx, %rdi
callq 0x2860
incq %r15
addq $0xc0, %rbx
jmp 0x30e5
leaq 0x48(%rbp), %rbx
xorl %esi, %esi
movq %rbx, %rdi
callq 0x23ea
pushq $0x1
popq %rsi
movq %rbx, %rdi
movq %rbx, 0x8(%rsp)
callq 0x23ea
movq (%rbp), %rax
leaq 0x98(%rbp), %rdi
movq %rdi, 0x18(%rsp)
movq 0x50(%rax), %rax
movq (%rax), %rsi
andl $0x1, %esi
callq 0x23ea
leaq 0xe8(%rbp), %rdi
xorl %esi, %esi
movq %rdi, 0x20(%rsp)
callq 0x23ea
leaq 0x40(%rsp), %r15
leaq 0x138(%rbp), %rdi
movq %r15, %rsi
movb $0x20, (%r15)
movq %rdi, 0x90(%rsp)
callq 0x39c4
vxorps %xmm0, %xmm0, %xmm0
vmovups %zmm0, 0x10(%r15)
movq $0x8, 0x8(%r15)
pushq $0x40
popq %rdi
vzeroupper
callq 0x2160
movq %rax, %r14
addq $0x18, %r14
movq %rax, (%r15)
movl $0x200, %edi            # imm = 0x200
callq 0x2160
movq %rax, %rcx
addq $0x200, %rcx            # imm = 0x200
movq %r14, 0x68(%rsp)
movq %rax, 0x58(%rsp)
movq %rax, (%r14)
movq %rcx, 0x60(%rsp)
movq %r14, 0x88(%rsp)
movq %rax, 0x78(%rsp)
movq %rcx, 0x80(%rsp)
movq %rax, 0x50(%rsp)
movq %rax, 0x70(%rsp)
movq (%rbp), %rcx
movq 0xc0(%rcx), %rcx
testb $0x1, (%rcx)
jne 0x3217
movq %rsp, %rsi
movq $0x1, (%rsi)
leaq 0x40(%rsp), %rdi
callq 0x2548
movq 0x50(%rsp), %rax
leaq 0x150(%rbp), %rcx
leaq 0x1a0(%rbp), %rdx
movq %rbp, 0x30(%rsp)
movq %rcx, 0x10(%rsp)
movq %rdx, 0xa0(%rsp)
cmpq %rax, 0x70(%rsp)
je 0x3497
movq (%rax), %r14
testl $0xffffff, %r14d        # imm = 0xFFFFFF
je 0x3435
movq (%rbp), %rax
movl %r14d, %r15d
andl $0xffffff, %r15d        # imm = 0xFFFFFF
movq %r14, %rcx
shrq $0x1e, %rcx
movq %r14, %rbx
shrq $0x18, %rbx
imulq $0xc0, %r15, %r12
movq (%rax,%r12), %rax
movq (%rax,%rcx,8), %rax
btq %rbx, %rax
jb 0x3435
movq 0x8(%rsp), %rdi
xorl %esi, %esi
callq 0x23ea
movq %r14, 0x98(%rsp)
movq (%rbp), %r14
movq %rbx, %rsi
leaq (%r14,%r12), %rdi
callq 0x272c
movq 0xa0(%r14,%r12), %rsi
subq %rax, %rbx
movq %r12, %r13
addq %rbx, %rsi
movq 0x90(%rsp), %rdi
callq 0x3bae
movq %r15, 0x28(%rsp)
xorl %r15d, %r15d
movq (%rbp), %rbp
testq %rbx, %rbx
je 0x32f3
leaq 0xc0(%rbp,%r13), %rdi
leaq -0x1(%rbx), %rsi
callq 0x277c
movq %rax, %r12
incq %r12
jmp 0x32f6
xorl %r12d, %r12d
movq 0x50(%rbp,%r13), %rax
movq %rbx, %r14
shrq $0x6, %r14
movq %r13, %rsi
movl %ebx, %r13d
andl $0x3f, %r13d
movq %rsi, 0x38(%rsp)
movq (%rax,%r14,8), %rax
btq %r13, %rax
jb 0x3385
movq 0xc0(%rbp,%rsi), %rax
leaq 0x1(%r12), %rcx
movq %rcx, %rdx
shrq $0x6, %rdx
movq (%rax,%rdx,8), %rdx
btq %rcx, %rdx
jae 0x338d
xorl %esi, %esi
subq $0x1, %r15
setb %sil
movq 0x10(%rsp), %rdi
callq 0x23ea
movq 0x30(%rsp), %rbp
movq 0x38(%rsp), %r13
movq (%rbp), %rax
subq %rbx, %r12
movq 0x160(%rax,%r13), %rsi
addq $0xc0, %r13
addq %r12, %rsi
movq 0xa0(%rsp), %rdi
callq 0x3bae
movq %r12, %rbx
jmp 0x32d1
movq 0xc0(%rbp,%rsi), %rax
movq %r12, %rcx
shrq $0x6, %rcx
movq 0x28(%rsp), %rbx
movq 0x30(%rsp), %rbp
movq (%rax,%rcx,8), %rax
subq %r15, %rbx
btq %r12, %rax
jae 0x33bf
andq $0x0, (%rsp)
leaq 0x40(%rsp), %rdi
movq %rsp, %rsi
callq 0x2548
jmp 0x33e0
leaq 0x1(%rbx), %rax
shlq $0x18, %r12
andl $0xffffff, %eax         # imm = 0xFFFFFF
orq %rax, %r12
movq %r12, (%rsp)
leaq 0x40(%rsp), %rdi
movq %rsp, %rsi
callq 0x2548
movq 0x28(%rsp), %r15
xorl %esi, %esi
cmpq %r15, %rbx
seta %sil
movq 0x20(%rsp), %rdi
callq 0x23ea
movq (%rbp), %rax
movq 0x38(%rsp), %rcx
movq 0x50(%rax,%rcx), %rax
shrxq %r13, (%rax,%r14,8), %rsi
andl $0x1, %esi
movq 0x18(%rsp), %rdi
callq 0x23ea
movq 0x98(%rsp), %r14
andq $-0x1000000, %r14       # imm = 0xFF000000
leaq 0x1000000(%r14,%r15), %r14
jmp 0x3252
movq 0x8(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x23ea
movq 0x60(%rsp), %rcx
movq 0x50(%rsp), %rax
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x345b
addq $0x8, %rax
jmp 0x348d
movq 0x58(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x2170
movq 0x68(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x68(%rsp)
movq 0x8(%rax), %rax
leaq 0x200(%rax), %rcx
movq %rax, 0x58(%rsp)
movq %rcx, 0x60(%rsp)
movq %rax, 0x50(%rsp)
jmp 0x3237
movq 0x8(%rsp), %rdi
callq 0x2860
movq 0x18(%rsp), %rdi
callq 0x2860
movq 0x20(%rsp), %rdi
callq 0x2860
pushq $0x1
popq %rsi
movq 0x10(%rsp), %rdi
callq 0x23ea
movq 0x10(%rsp), %rdi
callq 0x2860
leaq 0x40(%rsp), %rdi
callq 0x2a72
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3554
movq %rax, %rdi
callq 0x2090
movq %r14, %rdi
movq %r14, %rsi
callq 0x2aa0
callq 0x21a0
movq %rax, %rbx
callq 0x21e0
movq %rbx, %rdi
callq 0x2090
movq 0x48(%rsp), %rsi
movq 0x40(%rsp), %rdi
shlq $0x3, %rsi
callq 0x2170
vxorps %xmm0, %xmm0, %xmm0
vmovaps %xmm0, 0x40(%rsp)
callq 0x21a0
movq %rax, %rbx
callq 0x21e0
jmp 0x3561
jmp 0x3540
movq %rax, %rdi
callq 0x37bc
jmp 0x3554
jmp 0x3554
jmp 0x3554
jmp 0x3554
jmp 0x3554
jmp 0x3554
leaq 0x40(%rsp), %rdi
movq %rax, %rbx
callq 0x2a72
movq %rbx, %rdi
callq 0x21f0
nop