// File: /workspace/github_c_makefile_star2_O1/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, %r15d
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
movzwl 0x8(%rdx), %eax
xorl %ecx, %ecx
cmpl $0xff, %r15d
setae %cl
movl %r15d, %edx
shlq $0x2, %rcx
leaq (%rcx,%rdx,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 0x5e21
testl %ecx, %ecx
jne 0x5e21
movq 0x18(%rbx), %rax
leaq (%rax,%r13), %rsi
movq (%r12), %rdx
testq %rdx, %rdx
jne 0x5b4a
movq 0x10(%r12), %rcx
movzbl (%rcx), %edx
movq 0x10(%rbx), %rcx
movq (%rsi), %r8
movq %r8, %rdi
shrq $0x3e, %rdi
leaq 0x1851(%rip), %r9       # 0x73b0
movslq (%r9,%rdi,4), %rdi
addq %r9, %rdi
jmpq *%rdi
xorl %edi, %edi
cmpq $-0x2, %rdx
je 0x5c37
movq %r8, %r9
shrq $0x28, %r9
movzbl %r9b, %r10d
shll $0x4, %r10d
leaq 0x1856(%rip), %r11      # 0x73e0
movq (%r10,%r11), %r9
cmpq %rdx, %r9
ja 0x5c37
cmpq %rdx, 0x8(%r10,%r11)
jb 0x5c37
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 0x5c37
cmpq $-0x2, %rdx
jne 0x5bcb
xorl %edi, %edi
jmp 0x5c37
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
testq %r10, %r10
setne %r9b
je 0x5c27
addq %rsi, %r8
addq $0x8, %r8
xorl %r11d, %r11d
leaq (%r11,%r10), %rsi
shrq %rsi
movzbl (%r8,%rsi), %ebp
cmpq %rbp, %rdx
jbe 0x5c17
leaq 0x1(%rsi), %r11
jmp 0x5c1c
movq %rsi, %r10
jae 0x5c29
cmpq %r10, %r11
setb %r9b
jb 0x5c00
jmp 0x5c29
xorl %esi, %esi
leaq (%rdi,%rsi,8), %rdx
xorl %edi, %edi
testb $0x1, %r9b
cmovneq %rdx, %rdi
subq %r13, %rcx
testq %rdi, %rdi
je 0x5c42
movq %rcx, (%rdi)
movq (%r12), %rdi
movzwl 0x8(%r12), %r13d
cmpl $0xfe, %r15d
ja 0x5cdf
movabsq $-0x4000000000000000, %rsi # imm = 0xC000000000000000
movabsq $0xffffffffff, %rdx     # imm = 0xFFFFFFFFFF
testq %rdi, %rdi
je 0x5d6a
testl %edi, %edi
movabsq $-0x2000000000000000, %rdi # imm = 0xE000000000000000
cmoveq %rsi, %rdi
andl $0xfff, %r13d           # imm = 0xFFF
shlq $0x30, %r13
shlq $0x28, %r15
orq %r13, %r15
orq %rdi, %r15
andq %rdx, %rcx
orq %r15, %rcx
movq 0x10(%rbx), %rdx
movq %rcx, (%rax,%rdx)
movq 0x10(%rbx), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x10(%rbx)
movb (%r12), %dl
movb %dl, 0x8(%rax,%rcx)
movq 0x10(%rbx), %rdi
incq %rdi
movq %rdi, 0x10(%rbx)
movq 0x10(%r12), %rsi
movzwl 0x8(%r12), %r13d
decq %r13
addq 0x18(%rbx), %rdi
jmp 0x5da8
movabsq $0xffffffffff, %rdx     # imm = 0xFFFFFFFFFF
testq %rdi, %rdi
je 0x5db6
xorl %esi, %esi
testl %edi, %edi
setne %sil
shlq $0x3d, %rsi
andl $0xfff, %r13d           # imm = 0xFFF
shlq $0x30, %r13
orq %rsi, %r13
andq %rdx, %rcx
orq %r13, %rcx
movabsq $-0x4000000000000000, %rdx # imm = 0xC000000000000000
orq %rcx, %rdx
movabsq $0xff0000000000, %rcx   # imm = 0xFF0000000000
orq %rdx, %rcx
movq 0x10(%rbx), %rdx
movq %rcx, (%rax,%rdx)
movq 0x10(%rbx), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x10(%rbx)
movb (%r12), %dl
movb %dl, 0x8(%rax,%rcx)
movq 0x10(%rbx), %rdi
incq %rdi
movq %rdi, 0x10(%rbx)
movq 0x10(%r12), %rsi
movzwl 0x8(%r12), %r13d
decq %r13
addq 0x18(%rbx), %rdi
jmp 0x5df7
movl %r13d, %edi
andl $0xfff, %edi            # imm = 0xFFF
shlq $0x30, %rdi
shlq $0x28, %r15
orq %rdi, %r15
andq %rdx, %rcx
orq %r15, %rcx
orq %rsi, %rcx
movq 0x10(%rbx), %rdx
movq %rcx, (%rax,%rdx)
movq 0x10(%rbx), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x10(%rbx)
movq 0x10(%r12), %rsi
leaq (%rax,%rcx), %rdi
addq $0x8, %rdi
movq %r13, %rdx
callq 0x1140
addq 0x10(%rbx), %r13
jmp 0x5e1a
movl %r13d, %esi
andl $0xfff, %esi            # imm = 0xFFF
shlq $0x30, %rsi
andq %rdx, %rcx
orq %rsi, %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(%r12), %rsi
leaq (%rax,%rcx), %rdi
addq $0x8, %rdi
movq %r13, %rdx
callq 0x1140
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rcx
leaq (%rax,%r13), %rdx
movq %rdx, 0x10(%rbx)
movl %r15d, (%rcx,%rdx)
addq %rax, %r13
addq $0x4, %r13
movq %r13, 0x10(%rbx)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq