// File: /workspace/github_c_makefile_star2_O3/icebert[P]pblat/lib/bPlusTree.c
// Function: rFind
static boolean rFind(struct bptFile *bpt, bits64 blockStart, void *key, void *val)
/* Find value corresponding to key.  If found copy value to memory pointed to by val and return 
 * true. Otherwise return false. */
{
/* Seek to start of block. */
udcSeek(bpt->udc, blockStart);

/* Read block header. */
UBYTE isLeaf;
UBYTE reserved;
bits16 i, childCount;
udcMustReadOne(bpt->udc, isLeaf);
udcMustReadOne(bpt->udc, reserved);
boolean isSwapped = bpt->isSwapped;
childCount = udcReadBits16(bpt->udc, isSwapped);

UBYTE keyBuf[bpt->keySize];   /* Place to put a key, buffered on stack. */

if (isLeaf)
    {
    for (i=0; i<childCount; ++i)
        {
	udcMustRead(bpt->udc, keyBuf, bpt->keySize);
	udcMustRead(bpt->udc, val, bpt->valSize);
	if (memcmp(key, keyBuf, bpt->keySize) == 0)
	    return TRUE;
	}
    return FALSE;
    }
else
    {
    /* Read and discard first key. */
    udcMustRead(bpt->udc, keyBuf, bpt->keySize);

    /* Scan info for first file offset. */
    bits64 fileOffset = udcReadBits64(bpt->udc, isSwapped);

    /* Loop through remainder. */
    for (i=1; i<childCount; ++i)
	{
	udcMustRead(bpt->udc, keyBuf, bpt->keySize);
	if (memcmp(key, keyBuf, bpt->keySize) < 0)
	    break;
	fileOffset = udcReadBits64(bpt->udc, isSwapped);
	}
    return rFind(bpt, fileOffset, key, val);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, -0x48(%rbp)
movq %rdx, %r14
movq %rdi, %r15
movq 0x10(%rdi), %rdi
callq 0x41dfc
movq 0x10(%r15), %rdi
leaq -0x29(%rbp), %rsi
movl $0x1, %edx
callq 0x40215
movq 0x10(%r15), %rdi
leaq -0x2a(%rbp), %rsi
movl $0x1, %edx
callq 0x40215
movl 0x30(%r15), %ebx
movq 0x10(%r15), %rdi
movl %ebx, %esi
callq 0x41b07
movl %eax, %r12d
movq %rsp, %rcx
movl 0x1c(%r15), %eax
movq %rsp, %r13
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %r13
movq %r13, %rsp
leaq -0x29(%rbp), %rax
cmpb $0x0, (%rax)
je 0x43f32
xorl %eax, %eax
testw %r12w, %r12w
je 0x43fd9
movq %rcx, -0x38(%rbp)
movl 0x1c(%r15), %ebx
movq 0x10(%r15), %rdi
movl %ebx, %edx
movq %r13, %rsi
callq 0x40215
movq 0x10(%r15), %rdi
movl 0x20(%r15), %edx
movq -0x48(%rbp), %rsi
callq 0x40215
movl 0x1c(%r15), %ebx
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x6710
testl %eax, %eax
je 0x43fd0
decw %r12w
jne 0x43ee8
movq -0x38(%rbp), %rcx
xorl %eax, %eax
jmp 0x43fd9
movq %rcx, -0x38(%rbp)
movq 0x10(%r15), %rdi
movl 0x1c(%r15), %edx
movq %r13, %rsi
callq 0x40215
movq 0x10(%r15), %rdi
movl %ebx, -0x3c(%rbp)
movl %ebx, %esi
callq 0x41aac
movq %rax, %rbx
cmpw $0x2, %r12w
jb 0x43fbc
movq 0x10(%r15), %rdi
movl 0x1c(%r15), %edx
movq %r13, %rsi
callq 0x40215
movl 0x1c(%r15), %edx
movq %r14, %rdi
movq %r13, %rsi
callq 0x62e0
testl %eax, %eax
js 0x43fbc
decl %r12d
movq 0x10(%r15), %rdi
movl -0x3c(%rbp), %esi
callq 0x41aac
movq %rax, %rbx
decw %r12w
je 0x43fbc
movq 0x10(%r15), %rdi
movl 0x1c(%r15), %edx
movq %r13, %rsi
callq 0x40215
movl 0x1c(%r15), %edx
movq %r14, %rdi
movq %r13, %rsi
callq 0x62e0
testl %eax, %eax
jns 0x43f84
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq -0x48(%rbp), %rcx
callq 0x43e59
jmp 0x43fd5
movl $0x1, %eax
movq -0x38(%rbp), %rcx
movq %rcx, %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop