// File: /workspace/github_c_makefile_star2_O3/jflatow[P]jfdb/src/trie.c
// Function: prep_leaf
static inline JFT_Offset prep_leaf(JFT_Buffer *buf,
                                   JFT_Offset parentPos,
                                   const JFT_Stem *stem,
                                   JFT_Count maxWords) {
  // write the node, although it may be updated later
  // ensure space for maxWords and return a pointer where one can write words
  JFT_Offset size = JFT_leaf_size(stem->size, maxWords);
  if (!JFT_buffer_ample(buf, size))
    return 0;

  JFT_Offset parentOffset = offset_parent(buf, parentPos, stem);

  if (maxWords < 0xFF) {
    write_node(buf, Leaf, stem, maxWords, parentOffset);
  } else {
    write_node(buf, Leaf, stem, 0xFF, parentOffset);
    JFT_buffer_equal(buf, JFT_Count, maxWords);
  }

  return size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebp
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
movzwl 0x8(%rdx), %eax
xorl %ecx, %ecx
cmpl $0xff, %ebp
setae %cl
movl %ebp, %r13d
shlq $0x2, %rcx
leaq (%rcx,%r13,8), %rcx
leaq (%rax,%rcx), %r14
addq $0x8, %r14
movq %r14, %rsi
callq *0x20(%rdi)
movl %eax, %ecx
xorl %eax, %eax
testq %rbx, %rbx
je 0x5761
testl %ecx, %ecx
jne 0x5761
movq 0x18(%rbx), %rax
leaq (%rax,%r12), %rsi
movq (%r15), %rdx
testq %rdx, %rdx
jne 0x54ae
movq 0x10(%r15), %rcx
movzbl (%rcx), %edx
movq 0x10(%rbx), %rcx
subq %r12, %rcx
movq (%rsi), %rdi
movq %rdi, %r8
shrq $0x3e, %r8
leaq 0xeea(%rip), %r9        # 0x63b0
movslq (%r9,%r8,4), %r8
addq %r9, %r8
jmpq *%r8
cmpq $-0x2, %rdx
je 0x5582
movq %rdi, %r8
shrq $0x28, %r8
movzbl %r8b, %r9d
shll $0x4, %r9d
leaq 0xef0(%rip), %r10       # 0x63e0
movq (%r9,%r10), %r8
cmpq %rdx, %r8
ja 0x5582
cmpq %rdx, 0x8(%r9,%r10)
jb 0x5582
shrq $0x30, %rdi
andl $0xfff, %edi            # imm = 0xFFF
addq %rdi, %rsi
leaq (%rsi,%rdx,8), %rdx
shlq $0x3, %r8
subq %r8, %rdx
addq $0x8, %rdx
movq %rcx, (%rdx)
jmp 0x5582
cmpq $-0x2, %rdx
je 0x5582
movq %rdi, %r8
shrq $0x28, %r8
movzbl %r8b, %r8d
testq %r8, %r8
je 0x5582
shrq $0x30, %rdi
andl $0xfff, %edi            # imm = 0xFFF
leaq (%rsi,%rdi), %r9
addq %rsi, %rdi
addq $0x8, %rdi
leaq (%r8,%r9), %rsi
addq $0x8, %rsi
xorl %r9d, %r9d
leaq (%r9,%r8), %r10
shrq %r10
movzbl (%rdi,%r10), %r11d
cmpq %r11, %rdx
jbe 0x5574
incq %r10
movq %r10, %r9
jmp 0x557d
jae 0x5770
movq %r10, %r8
cmpq %r8, %r9
jb 0x555b
movq (%r15), %rdx
movzwl 0x8(%r15), %r12d
cmpl $0xfe, %ebp
ja 0x5618
testq %rdx, %rdx
je 0x5693
xorl %esi, %esi
testl %edx, %edx
setne %sil
shlq $0x3d, %rsi
andl $0xfff, %r12d           # imm = 0xFFF
shlq $0x30, %r12
orq %rsi, %r12
shlq $0x28, %r13
orq %r12, %r13
movabsq $0xffffffffff, %rdx     # imm = 0xFFFFFFFFFF
andq %rdx, %rcx
orq %r13, %rcx
movabsq $-0x4000000000000000, %rdx # imm = 0xC000000000000000
orq %rcx, %rdx
movq 0x10(%rbx), %rcx
movq %rdx, (%rax,%rcx)
movq 0x10(%rbx), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x10(%rbx)
movb (%r15), %dl
movb %dl, 0x8(%rax,%rcx)
movq 0x10(%rbx), %rdi
incq %rdi
movq %rdi, 0x10(%rbx)
movq 0x10(%r15), %rsi
movzwl 0x8(%r15), %r12d
decq %r12
addq 0x18(%rbx), %rdi
jmp 0x56e4
testq %rdx, %rdx
je 0x56f2
xorl %esi, %esi
testl %edx, %edx
setne %sil
shlq $0x3d, %rsi
andl $0xfff, %r12d           # imm = 0xFFF
shlq $0x30, %r12
orq %rsi, %r12
movabsq $0xffffffffff, %rdx     # imm = 0xFFFFFFFFFF
andq %rdx, %rcx
orq %r12, %rcx
movabsq $-0x3fff010000000000, %rdx # imm = 0xC000FF0000000000
orq %rcx, %rdx
movq 0x10(%rbx), %rcx
movq %rdx, (%rax,%rcx)
movq 0x10(%rbx), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x10(%rbx)
movb (%r15), %dl
movb %dl, 0x8(%rax,%rcx)
movq 0x10(%rbx), %rdi
incq %rdi
movq %rdi, 0x10(%rbx)
movq 0x10(%r15), %rsi
movzwl 0x8(%r15), %r12d
decq %r12
addq 0x18(%rbx), %rdi
jmp 0x573c
movl %r12d, %edx
andl $0xfff, %edx            # imm = 0xFFF
shlq $0x30, %rdx
shlq $0x28, %r13
orq %rdx, %r13
movabsq $0xffffffffff, %rdx     # imm = 0xFFFFFFFFFF
andq %rdx, %rcx
orq %r13, %rcx
movabsq $-0x4000000000000000, %rdx # imm = 0xC000000000000000
orq %rcx, %rdx
movq 0x10(%rbx), %rcx
movq %rdx, (%rax,%rcx)
movq 0x10(%rbx), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x10(%rbx)
movq 0x10(%r15), %rsi
leaq (%rax,%rcx), %rdi
addq $0x8, %rdi
movq %r12, %rdx
callq 0x1140
addq 0x10(%rbx), %r12
jmp 0x575a
movl %r12d, %edx
andl $0xfff, %edx            # imm = 0xFFF
shlq $0x30, %rdx
movabsq $0xffffffffff, %rsi     # imm = 0xFFFFFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movabsq $-0x3fff010000000000, %rdx # imm = 0xC000FF0000000000
orq %rcx, %rdx
movq 0x10(%rbx), %rcx
movq %rdx, (%rax,%rcx)
movq 0x10(%rbx), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x10(%rbx)
movq 0x10(%r15), %rsi
leaq (%rax,%rcx), %rdi
addq $0x8, %rdi
movq %r12, %rdx
callq 0x1140
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rcx
leaq (%rax,%r12), %rdx
movl %ebp, (%rcx,%rdx)
addq %rax, %r12
addq $0x4, %r12
movq %r12, 0x10(%rbx)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq (%rsi,%r10,8), %rdx
jmp 0x5520