// File: s-yata[P]louds-patricia/louds-patricia.cpp
// Function: louds::(anonymous namespace)::BitVector::select(unsigned long) const
uint64_t select(uint64_t i) const {
    const uint64_t block_id = i / 256;
    uint64_t begin = selects[block_id];
    uint64_t end = selects[block_id + 1] + 1UL;
    if (begin + 10 >= end) {
      while (i >= ranks[begin + 1].abs()) {
        ++begin;
      }
    } else {
      while (begin + 1 < end) {
        const uint64_t middle = (begin + end) / 2;
        if (i < ranks[middle].abs()) {
          end = middle;
        } else {
          begin = middle;
        }
      }
    }
    const uint64_t rank_id = begin;
    i -= ranks[rank_id].abs();

    uint64_t word_id = rank_id * 4;
    if (i < ranks[rank_id].rels[1]) {
      if (i >= ranks[rank_id].rels[0]) {
        word_id += 1;
        i -= ranks[rank_id].rels[0];
      }
    } else if (i < ranks[rank_id].rels[2]) {
      word_id += 2;
      i -= ranks[rank_id].rels[1];
    } else {
      word_id += 3;
      i -= ranks[rank_id].rels[2];
    }
    return (word_id * 64) + Ctz(_pdep_u64(1UL << i, words[word_id]));
  }

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x80(%rsp)
movq %rsi, 0x78(%rsp)
movq 0x80(%rsp), %rdi
movq %rdi, 0x40(%rsp)
movq 0x78(%rsp), %rax
shrq $0x8, %rax
movq %rax, 0x70(%rsp)
addq $0x30, %rdi
movq 0x70(%rsp), %rsi
callq 0x9960
movq 0x40(%rsp), %rdi
movl (%rax), %eax
movq %rax, 0x68(%rsp)
addq $0x30, %rdi
movq 0x70(%rsp), %rsi
addq $0x1, %rsi
callq 0x9960
movl (%rax), %eax
addq $0x1, %rax
movq %rax, 0x60(%rsp)
movq 0x68(%rsp), %rax
addq $0xa, %rax
cmpq 0x60(%rsp), %rax
jb 0x4440
jmp 0x43f8
movq 0x40(%rsp), %rdi
movq 0x78(%rsp), %rax
movq %rax, 0x38(%rsp)
addq $0x18, %rdi
movq 0x68(%rsp), %rsi
addq $0x1, %rsi
callq 0x5c00
movq %rax, %rdi
callq 0x5c20
movq %rax, %rcx
movq 0x38(%rsp), %rax
cmpq %rcx, %rax
jb 0x443e
movq 0x68(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x68(%rsp)
jmp 0x43f8
jmp 0x44b0
jmp 0x4442
movq 0x68(%rsp), %rax
addq $0x1, %rax
cmpq 0x60(%rsp), %rax
jae 0x44ae
movq 0x40(%rsp), %rdi
movq 0x68(%rsp), %rax
addq 0x60(%rsp), %rax
shrq %rax
movq %rax, 0x58(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x30(%rsp)
addq $0x18, %rdi
movq 0x58(%rsp), %rsi
callq 0x5c00
movq %rax, %rdi
callq 0x5c20
movq %rax, %rcx
movq 0x30(%rsp), %rax
cmpq %rcx, %rax
jae 0x44a2
movq 0x58(%rsp), %rax
movq %rax, 0x60(%rsp)
jmp 0x44ac
movq 0x58(%rsp), %rax
movq %rax, 0x68(%rsp)
jmp 0x4442
jmp 0x44b0
movq 0x40(%rsp), %rdi
movq 0x68(%rsp), %rax
movq %rax, 0x50(%rsp)
addq $0x18, %rdi
movq 0x50(%rsp), %rsi
callq 0x5c00
movq %rax, %rdi
callq 0x5c20
movq 0x40(%rsp), %rdi
movq %rax, %rcx
movq 0x78(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x78(%rsp)
movq 0x50(%rsp), %rax
shlq $0x2, %rax
movq %rax, 0x48(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x28(%rsp)
addq $0x18, %rdi
movq 0x50(%rsp), %rsi
callq 0x5c00
movq %rax, %rcx
movq 0x28(%rsp), %rax
movzbl 0x6(%rcx), %ecx
cmpq %rcx, %rax
jae 0x4588
movq 0x40(%rsp), %rdi
movq 0x78(%rsp), %rax
movq %rax, 0x20(%rsp)
addq $0x18, %rdi
movq 0x50(%rsp), %rsi
callq 0x5c00
movq %rax, %rcx
movq 0x20(%rsp), %rax
movzbl 0x5(%rcx), %ecx
cmpq %rcx, %rax
jb 0x4583
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
addq $0x18, %rdi
movq 0x50(%rsp), %rsi
callq 0x5c00
movzbl 0x5(%rax), %eax
movl %eax, %ecx
movq 0x78(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x78(%rsp)
jmp 0x4622
movq 0x40(%rsp), %rdi
movq 0x78(%rsp), %rax
movq %rax, 0x18(%rsp)
addq $0x18, %rdi
movq 0x50(%rsp), %rsi
callq 0x5c00
movq %rax, %rcx
movq 0x18(%rsp), %rax
movzbl 0x7(%rcx), %ecx
cmpq %rcx, %rax
jae 0x45ec
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rax
addq $0x2, %rax
movq %rax, 0x48(%rsp)
addq $0x18, %rdi
movq 0x50(%rsp), %rsi
callq 0x5c00
movzbl 0x6(%rax), %eax
movl %eax, %ecx
movq 0x78(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x78(%rsp)
jmp 0x4620
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rax
addq $0x3, %rax
movq %rax, 0x48(%rsp)
addq $0x18, %rdi
movq 0x50(%rsp), %rsi
callq 0x5c00
movzbl 0x7(%rax), %eax
movl %eax, %ecx
movq 0x78(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x78(%rsp)
jmp 0x4622
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rax
shlq $0x6, %rax
movq %rax, 0x10(%rsp)
movq 0x78(%rsp), %rcx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, 0x8(%rsp)
movq 0x48(%rsp), %rsi
callq 0x9700
movq 0x8(%rsp), %rcx
movq (%rax), %rax
movq %rcx, 0x90(%rsp)
movq %rax, 0x88(%rsp)
movq 0x90(%rsp), %rax
movq 0x88(%rsp), %rcx
pdepq %rcx, %rax, %rdi
callq 0x5c60
movq %rax, %rcx
movq 0x10(%rsp), %rax
addq %rcx, %rax
addq $0x98, %rsp
retq
nopw %cs:(%rax,%rax)