// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: lhParseOneCell
static int lhParseOneCell(lhpage *pPage,const unsigned char *zRaw,const unsigned char *zEnd,lhcell **ppOut)
{
	sxu16 iNext,iOfft;
	sxu32 iHash,nKey;
	lhcell *pCell;
	sxu64 nData;
	int rc;
	/* Offset this cell is stored */
	iOfft = (sxu16)(zRaw - (const unsigned char *)pPage->pRaw->zData);
	/* 4 byte hash number */
	SyBigEndianUnpack32(zRaw,&iHash);
	zRaw += 4;	
	/* 4 byte key length  */
	SyBigEndianUnpack32(zRaw,&nKey);
	zRaw += 4;	
	/* 8 byte data length */
	SyBigEndianUnpack64(zRaw,&nData);
	zRaw += 8;
	/* 2 byte offset of the next cell */
	SyBigEndianUnpack16(zRaw,&iNext);
	/* Perform a sanity check */
	if( iNext > 0 && &pPage->pRaw->zData[iNext] >= zEnd ){
		return UNQLITE_CORRUPT;
	}
	zRaw += 2;
	pCell = lhNewCell(pPage->pHash,pPage);
	if( pCell == 0 ){
		return UNQLITE_NOMEM;
	}
	/* Fill in the structure */
	pCell->iNext = iNext;
	pCell->nKey  = nKey;
	pCell->nData = nData;
	pCell->nHash = iHash;
	/* Overflow page if any */
	SyBigEndianUnpack64(zRaw,&pCell->iOvfl);
	zRaw += 8;
	/* Cell offset */
	pCell->iStart = iOfft;
	/* Consume the key */
	rc = lhConsumeCellkey(pCell,unqliteDataConsumer,&pCell->sKey,pCell->nKey > 262144 /* 256 KB */? 1 : 0);
	if( rc != UNQLITE_OK ){
		/* TICKET: 14-32-chm@symisc.net: Key too large for memory */
		SyBlobRelease(&pCell->sKey);
	}
	/* Finally install the cell */
	rc = lhInstallCell(pCell);
	if( rc != UNQLITE_OK ){
		return rc;
	}
	if( ppOut ){
		*ppOut = pCell;
	}
	return UNQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq (%rcx), %rcx
subq %rcx, %rax
movw %ax, -0x2c(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x61d60
movq -0x18(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x61d60
movq -0x18(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x61db0
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x2a(%rbp), %rsi
callq 0x64c70
movzwl -0x2a(%rbp), %eax
cmpl $0x0, %eax
jle 0x654c3
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movzwl -0x2a(%rbp), %ecx
addq %rcx, %rax
cmpq -0x20(%rbp), %rax
jb 0x654c3
movl $0xffffffe8, -0x4(%rbp) # imm = 0xFFFFFFE8
jmp 0x655c2
movq -0x18(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x64080
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x654f6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x655c2
movw -0x2a(%rbp), %cx
movq -0x40(%rbp), %rax
movw %cx, 0x10(%rax)
movl -0x34(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x30(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rsi
addq $0x18, %rsi
callq 0x61db0
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x18(%rbp)
movw -0x2c(%rbp), %cx
movq -0x40(%rbp), %rax
movw %cx, 0x28(%rax)
movq -0x40(%rbp), %rdi
movq -0x40(%rbp), %rdx
addq $0x40, %rdx
movq -0x40(%rbp), %rax
movl 0x4(%rax), %esi
xorl %ecx, %ecx
movl $0x1, %eax
cmpl $0x40000, %esi          # imm = 0x40000
cmoval %eax, %ecx
leaq -0xc3c4(%rip), %rsi     # 0x591b0
callq 0x655d0
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x6558f
movq -0x40(%rbp), %rdi
addq $0x40, %rdi
callq 0x58c00
movq -0x40(%rbp), %rdi
callq 0x64100
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x655a9
movl -0x4c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x655c2
cmpq $0x0, -0x28(%rbp)
je 0x655bb
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)