// File: /workspace/github_c_makefile_star2_O3/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 0x59f1
testl %ecx, %ecx
jne 0x59f1
movq 0x18(%r14), %rax
leaq (%rax,%rbp), %rdi
movq (%r13), %rdx
movq %rdx, %rsi
testq %rdx, %rdx
jne 0x57dc
movq 0x10(%r13), %rcx
movzbl (%rcx), %esi
movq 0x10(%r14), %rcx
subq %rbp, %rcx
movq (%rdi), %r8
movq %r8, %r9
shrq $0x3e, %r9
leaq 0xbcc(%rip), %r10       # 0x63c0
movslq (%r10,%r9,4), %r9
addq %r10, %r9
jmpq *%r9
cmpq $-0x2, %rsi
je 0x58ba
movq %r8, %r9
shrq $0x28, %r9
movzbl %r9b, %r10d
shll $0x4, %r10d
leaq 0xbc2(%rip), %r11       # 0x63e0
movq (%r10,%r11), %r9
cmpq %rsi, %r9
ja 0x58ba
cmpq %rsi, 0x8(%r10,%r11)
jb 0x58ba
shrq $0x30, %r8
andl $0xfff, %r8d            # imm = 0xFFF
addq %r8, %rdi
leaq (%rdi,%rsi,8), %rdx
shlq $0x3, %r9
subq %r9, %rdx
addq $0x8, %rdx
movq %rcx, (%rdx)
movq (%r13), %rdx
jmp 0x58ba
cmpq $-0x2, %rsi
je 0x58ba
movq %r8, %r9
shrq $0x28, %r9
movzbl %r9b, %r9d
testq %r9, %r9
je 0x58ba
shrq $0x30, %r8
andl $0xfff, %r8d            # imm = 0xFFF
leaq (%rdi,%r8), %r10
addq %rdi, %r8
addq $0x8, %r8
leaq (%r9,%r10), %rdi
addq $0x8, %rdi
xorl %r10d, %r10d
leaq (%r10,%r9), %r11
shrq %r11
movzbl (%r8,%r11), %ebp
cmpq %rbp, %rsi
jbe 0x58ac
incq %r11
movq %r11, %r10
jmp 0x58b5
jae 0x5a00
movq %r11, %r9
cmpq %r9, %r10
jb 0x5893
movabsq $0x4000000000000000, %rsi # imm = 0x4000000000000000
movabsq $0xffffffffff, %rdi     # imm = 0xFFFFFFFFFF
movzwl 0x8(%r13), %ebp
testq %rdx, %rdx
je 0x593e
xorl %r8d, %r8d
testl %edx, %edx
setne %r8b
shlq $0x3d, %r8
andl $0xfff, %ebp            # imm = 0xFFF
shlq $0x30, %rbp
orq %r8, %rbp
movzbl %bl, %edx
shlq $0x28, %rdx
orq %rbp, %rdx
andq %rdi, %rcx
orq %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 0x597e
movl %ebp, %edx
andl $0xfff, %edx            # imm = 0xFFF
shlq $0x30, %rdx
movzbl %bl, %r8d
shlq $0x28, %r8
orq %rdx, %r8
andq %rdi, %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 0x10(%r14), %rbp
movq %rbp, 0x10(%r14)
xorl %eax, %eax
movq (%r12,%rax,8), %rcx
testq %rcx, %rcx
je 0x59c5
bsfq %rcx, %rsi
movl %eax, %edx
shlb $0x6, %dl
orb %dl, %sil
movq 0x18(%r14), %rdi
movb %sil, (%rdi,%rbp)
movq 0x10(%r14), %rbp
incq %rbp
movq %rbp, 0x10(%r14)
leaq -0x1(%rcx), %rsi
andq %rsi, %rcx
bsfq %rcx, %rsi
jne 0x59a2
incq %rax
cmpq $0x4, %rax
jne 0x5990
testl %ebx, %ebx
jle 0x59ee
movq 0x18(%r14), %rax
movq $0x0, (%rax,%rbp)
movq 0x10(%r14), %rbp
addq $0x8, %rbp
movq %rbp, 0x10(%r14)
decl %ebx
jne 0x59d6
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq (%rdi,%r11,8), %rdx
jmp 0x5853