// File: /workspace/github_c_makefile_star2_O1/jflatow[P]jfdb/src/trie.c
// Function: make_scan_list
static inline JFT_Offset make_scan_list(JFT_Buffer *buf,
                                        JFT_Offset parentPos,
                                        const JFT_Stem *stem,
                                        JFT_SymbolSet *symbols,
                                        int numSymbols) {
  // first create the list of symbols for searching, then the list of offsets
  JFT_Offset size = JFT_scan_size(stem->size, numSymbols);
  if (!JFT_buffer_ample(buf, size))
    return 0;

  JFT_Offset parentOffset = offset_parent(buf, parentPos, stem);
  write_node(buf, ScanList, stem, numSymbols, parentOffset);

  uint64_t word;
  for (int w = 0; w < 4; w++)
    for (int b = ffsll(word = (*symbols)[w]); b; b = ffsll(word &= word - 1))
      JFT_buffer_equal(buf, uint8_t, 64 * w + b - 1);

  for (int i = 0; i < numSymbols; i++)
    JFT_buffer_equal(buf, JFT_Offset, 0);

  return size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %ebx
movq %rcx, %r12
movq %rdx, %r13
movq %rsi, %rbp
movq %rdi, %r14
movzwl 0x8(%rdx), %eax
movl %r8d, %ecx
leaq (%rcx,%rcx,8), %rcx
leaq (%rax,%rcx), %r15
addq $0x8, %r15
movq %r15, %rsi
callq *0x20(%rdi)
movl %eax, %ecx
xorl %eax, %eax
testq %r14, %r14
je 0x60d7
testl %ecx, %ecx
jne 0x60d7
movq 0x18(%r14), %rax
leaq (%rax,%rbp), %rsi
movq (%r13), %rdx
testq %rdx, %rdx
jne 0x5e90
movq 0x10(%r13), %rcx
movzbl (%rcx), %edx
movq 0x10(%r14), %rcx
movq (%rsi), %r8
movq %r8, %rdi
shrq $0x3e, %rdi
leaq 0x151b(%rip), %r9       # 0x73c0
movslq (%r9,%rdi,4), %rdi
addq %r9, %rdi
jmpq *%rdi
xorl %edi, %edi
cmpq $-0x2, %rdx
je 0x5f85
movq %r8, %r9
shrq $0x28, %r9
movzbl %r9b, %r10d
shll $0x4, %r10d
leaq 0x1510(%rip), %r11      # 0x73e0
movq (%r10,%r11), %r9
cmpq %rdx, %r9
ja 0x5f85
cmpq %rdx, 0x8(%r10,%r11)
jb 0x5f85
shrq $0x30, %r8
andl $0xfff, %r8d            # imm = 0xFFF
addq %r8, %rsi
leaq (%rsi,%rdx,8), %rdi
shlq $0x3, %r9
subq %r9, %rdi
addq $0x8, %rdi
jmp 0x5f85
cmpq $-0x2, %rdx
jne 0x5f11
xorl %edi, %edi
jmp 0x5f85
movq %r8, %rdi
shrq $0x28, %rdi
shrq $0x30, %r8
andl $0xfff, %r8d            # imm = 0xFFF
leaq (%rsi,%r8), %r9
movzbl %dil, %r10d
leaq (%r10,%r9), %rdi
addq $0x8, %rdi
movq %rdi, (%rsp)
testq %r10, %r10
setne %r9b
je 0x5f71
addq %rsi, %r8
addq $0x8, %r8
xorl %r11d, %r11d
leaq (%r11,%r10), %rsi
shrq %rsi
movzbl (%r8,%rsi), %edi
cmpq %rdi, %rdx
jbe 0x5f61
leaq 0x1(%rsi), %r11
jmp 0x5f66
movq %rsi, %r10
jae 0x5f73
cmpq %r10, %r11
setb %r9b
jb 0x5f4a
jmp 0x5f73
xorl %esi, %esi
movq (%rsp), %rdx
leaq (%rdx,%rsi,8), %rdx
xorl %edi, %edi
testb $0x1, %r9b
cmovneq %rdx, %rdi
subq %rbp, %rcx
testq %rdi, %rdi
je 0x5f90
movq %rcx, (%rdi)
movabsq $0x4000000000000000, %rsi # imm = 0x4000000000000000
movabsq $0xffffffffff, %rdx     # imm = 0xFFFFFFFFFF
movq (%r13), %rdi
movzwl 0x8(%r13), %ebp
testq %rdi, %rdi
je 0x6018
testl %edi, %edi
movabsq $0x6000000000000000, %rdi # imm = 0x6000000000000000
cmoveq %rsi, %rdi
andl $0xfff, %ebp            # imm = 0xFFF
shlq $0x30, %rbp
movzbl %bl, %esi
shlq $0x28, %rsi
orq %rbp, %rsi
orq %rdi, %rsi
andq %rdx, %rcx
orq %rsi, %rcx
movq 0x10(%r14), %rdx
movq %rcx, (%rax,%rdx)
movq 0x10(%r14), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x10(%r14)
movb (%r13), %dl
movb %dl, 0x8(%rax,%rcx)
movq 0x10(%r14), %rdi
incq %rdi
movq %rdi, 0x10(%r14)
movq 0x10(%r13), %rsi
movzwl 0x8(%r13), %ebp
decq %rbp
addq 0x18(%r14), %rdi
jmp 0x6058
movl %ebp, %edi
andl $0xfff, %edi            # imm = 0xFFF
shlq $0x30, %rdi
movzbl %bl, %r8d
shlq $0x28, %r8
orq %rdi, %r8
andq %rdx, %rcx
orq %r8, %rcx
orq %rsi, %rcx
movq 0x10(%r14), %rdx
movq %rcx, (%rax,%rdx)
movq 0x10(%r14), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x10(%r14)
movq 0x10(%r13), %rsi
leaq (%rax,%rcx), %rdi
addq $0x8, %rdi
movq %rbp, %rdx
callq 0x1140
addq %rbp, 0x10(%r14)
xorl %eax, %eax
xorl %ecx, %ecx
movq (%r12,%rcx,8), %rdx
testq %rdx, %rdx
je 0x60ae
bsfq %rdx, %rdi
incb %dil
movl %ecx, %esi
shlb $0x6, %sil
addb %sil, %dil
decb %dil
movq 0x10(%r14), %r8
movq 0x18(%r14), %r9
movb %dil, (%r9,%r8)
incq 0x10(%r14)
leaq -0x1(%rdx), %rdi
andq %rdi, %rdx
bsfq %rdx, %rdi
incb %dil
movzbl %dil, %edi
testq %rdx, %rdx
cmovel %eax, %edi
jne 0x607e
incq %rcx
cmpq $0x4, %rcx
jne 0x6068
testl %ebx, %ebx
jle 0x60d4
movq 0x18(%r14), %rax
movq 0x10(%r14), %rcx
movq $0x0, (%rax,%rcx)
addq $0x8, 0x10(%r14)
decl %ebx
jne 0x60bf
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq