// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/lib/bPlusTree.c
// Function: bptFileBulkIndexToOpenFile
void bptFileBulkIndexToOpenFile(void *itemArray, int itemSize, bits64 itemCount, bits32 blockSize,
	void (*fetchKey)(const void *va, char *keyBuf), bits32 keySize,
	void* (*fetchVal)(const void *va), bits32 valSize, FILE *f)
/* Create a b+ tree index from a sorted array, writing output starting at current position
 * of an already open file.  See bptFileCreate for explanation of parameters. */
{
bits32 magic = bptSig;
bits32 reserved = 0;
writeOne(f, magic);
writeOne(f, blockSize);
writeOne(f, keySize);
writeOne(f, valSize);
writeOne(f, itemCount);
writeOne(f, reserved);
writeOne(f, reserved);
bits64 indexOffset = ftell(f);

/* Write non-leaf nodes. */
int levels = bptCountLevels(blockSize, itemCount);
int i;
for (i=levels-1; i > 0; --i)
    {
    bits32 endLevelOffset = writeIndexLevel(blockSize, itemArray, itemSize, itemCount, indexOffset, 
    	i, fetchKey, keySize, valSize, f);
    indexOffset = ftell(f);
    if (endLevelOffset != indexOffset)
        internalErr();
    }

/* Write leaf nodes */
writeLeafLevel(blockSize, itemArray, itemSize, itemCount, 
	fetchKey, keySize, fetchVal, valSize, f);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x78, %rsp
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
movl $0x78ca8c91, -0x38(%rbp) # imm = 0x78CA8C91
movl $0x0, -0x3c(%rbp)
movq 0x20(%rbp), %rdi
leaq -0x38(%rbp), %rsi
movl $0x4, %edx
callq 0x2f8b0
movq 0x20(%rbp), %rdi
leaq -0x24(%rbp), %rsi
movl $0x4, %edx
callq 0x2f8b0
movq 0x20(%rbp), %rdi
leaq -0x34(%rbp), %rsi
movl $0x4, %edx
callq 0x2f8b0
movq 0x20(%rbp), %rdi
leaq 0x18(%rbp), %rsi
movl $0x4, %edx
callq 0x2f8b0
movq 0x20(%rbp), %rdi
leaq -0x20(%rbp), %rsi
movl $0x8, %edx
callq 0x2f8b0
movq 0x20(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
movl $0x4, %edx
callq 0x2f8b0
movq 0x20(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
movl $0x4, %edx
callq 0x2f8b0
movq 0x20(%rbp), %rdi
callq 0x6030
movq %rax, -0x48(%rbp)
movl -0x24(%rbp), %edi
movq -0x20(%rbp), %rax
movl %eax, %esi
callq 0x618d0
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x50(%rbp)
cmpl $0x0, -0x50(%rbp)
jle 0x61881
movl -0x24(%rbp), %eax
movw %ax, %di
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rcx
movq -0x48(%rbp), %rax
movl %eax, %r8d
movl -0x50(%rbp), %r9d
movq -0x30(%rbp), %rbx
movl -0x34(%rbp), %r11d
movl 0x18(%rbp), %r10d
movq 0x20(%rbp), %rax
movzwl %di, %edi
movq %rbx, (%rsp)
movl %r11d, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x61910
movl %eax, -0x54(%rbp)
movq 0x20(%rbp), %rdi
callq 0x6030
movq %rax, -0x48(%rbp)
movl -0x54(%rbp), %eax
cmpq -0x48(%rbp), %rax
je 0x61871
leaq 0x7630f(%rip), %rdi     # 0xd7b6d
leaq 0x7dc31(%rip), %rsi     # 0xdf496
movl $0x23c, %edx            # imm = 0x23C
movb $0x0, %al
callq 0x35d40
jmp 0x61873
movl -0x50(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x617ed
movl -0x24(%rbp), %eax
movw %ax, %di
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %r8
movl -0x34(%rbp), %r9d
movq 0x10(%rbp), %r11
movl 0x18(%rbp), %r10d
movq 0x20(%rbp), %rax
movzwl %di, %edi
movq %r11, (%rsp)
movl %r10d, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x61c80
addq $0x78, %rsp
popq %rbx
popq %rbp
retq
nopw %cs:(%rax,%rax)