// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: lhash_kv_open
static int lhash_kv_open(unqlite_kv_engine *pEngine,pgno dbSize)
{
	lhash_kv_engine *pHash = (lhash_kv_engine *)pEngine;
	unqlite_page *pHeader;
	int rc;
	if( dbSize < 1 ){
		/* A new database, create the header */
		rc = pEngine->pIo->xNew(pEngine->pIo->pHandle,&pHeader);
		if( rc != UNQLITE_OK ){
			return rc;
		}
		/* Acquire a writer lock */
		rc = pEngine->pIo->xWrite(pHeader);
		if( rc != UNQLITE_OK ){
			return rc;
		}
		/* Write the hash header */
		rc = lhash_write_header(pHash,pHeader);
		if( rc != UNQLITE_OK ){
			return rc;
		}
	}else{
		/* Acquire the page one of the database */
		rc = pEngine->pIo->xGet(pEngine->pIo->pHandle,1,&pHeader);
		if( rc != UNQLITE_OK ){
			return rc;
		}
		/* Read the database header */
		rc = lhash_read_header(pHash,pHeader);
		if( rc != UNQLITE_OK ){
			return rc;
		}
	}
	return UNQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq (%rdi), %rax
movq (%rax), %rdi
testq %rsi, %rsi
je 0x3697f
leaq -0x30(%rbp), %rdx
movl $0x1, %esi
callq *0x10(%rax)
testl %eax, %eax
jne 0x36a4b
movq -0x30(%rbp), %r13
movq (%r13), %r12
movq %r13, 0xd0(%rbx)
movl (%r12), %ecx
bswapl %ecx
movl %ecx, 0x138(%rbx)
movl $0xffffffe8, %eax       # imm = 0xFFFFFFE8
cmpl $0xfa782dcb, %ecx       # imm = 0xFA782DCB
jne 0x36a4b
movl 0x4(%r12), %r14d
bswapl %r14d
leaq 0x3d042(%rip), %rdi     # 0x738b4
movl $0xa, %esi
callq *0xc0(%rbx)
cmpl %r14d, %eax
jne 0x36a33
leaq 0x8(%r12), %rdi
leaq 0x118(%rbx), %rsi
callq 0x36f8d
leaq 0x10(%r12), %rdi
leaq 0x120(%rbx), %rsi
callq 0x36f8d
leaq 0x18(%r12), %rdi
leaq 0x128(%rbx), %rsi
callq 0x36f8d
leaq 0x20(%r12), %rdi
movq 0x128(%rbx), %rax
addq %rax, %rax
movq %rax, 0x130(%rbx)
leaq 0xf8(%rbx), %r14
movq 0x10(%r13), %rax
movq %rax, 0xf8(%rbx)
leaq 0x108(%rbx), %r15
movq %r15, %rsi
callq 0x36f8d
movl 0x28(%r12), %eax
bswapl %eax
movl %eax, 0x104(%rbx)
movq (%r13), %rdx
subl %edx, %r12d
addl $0x2c, %r12d
movw %r12w, 0x100(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x36f9c
testl %eax, %eax
jne 0x36a4b
movq (%r15), %r13
testq %r13, %r13
je 0x36978
leaq -0x38(%rbp), %r12
movq (%rbx), %rax
movq (%rax), %rdi
movq %r13, %rsi
movq %r12, %rdx
callq *0x10(%rax)
testl %eax, %eax
jne 0x36a4b
movq %r13, 0xf8(%rbx)
movw $0x0, 0x100(%rbx)
movq -0x38(%rbp), %rax
movq (%rax), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x36f9c
testl %eax, %eax
jne 0x36a4b
movq (%r15), %r13
testq %r13, %r13
jne 0x3692f
xorl %eax, %eax
jmp 0x36a4b
leaq -0x30(%rbp), %rsi
callq *0x20(%rax)
testl %eax, %eax
jne 0x36a4b
movq (%rbx), %rax
movq -0x30(%rbp), %rdi
callq *0x28(%rax)
testl %eax, %eax
jne 0x36a4b
movq -0x30(%rbp), %r15
movq (%r15), %r14
movq %r15, 0xd0(%rbx)
movl 0x138(%rbx), %eax
bswapl %eax
movl %eax, (%r14)
leaq 0x3cef4(%rip), %rdi     # 0x738b4
movl $0xa, %esi
callq *0xc0(%rbx)
movl %eax, %ecx
rolw $0x8, %cx
movw %cx, 0x6(%r14)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x5(%r14)
shrl $0x18, %eax
movb %al, 0x4(%r14)
xorl %eax, %eax
movq %rax, 0x8(%r14)
movq 0x120(%rbx), %rcx
bswapq %rcx
movq %rcx, 0x10(%r14)
movq 0x128(%rbx), %rcx
bswapq %rcx
movq %rcx, 0x18(%r14)
movq 0x10(%r15), %rcx
movq %rcx, 0xf8(%rbx)
movq %rax, 0x20(%r14)
movl $0x0, 0x28(%r14)
movl (%r15), %ecx
subl %ecx, %r14d
addl $0x2c, %r14d
movw %r14w, 0x100(%rbx)
jmp 0x36a4b
movq (%rbx), %rax
movq (%rax), %rdi
leaq 0x3ce7f(%rip), %rsi     # 0x738bf
callq *0x80(%rax)
movl $0xfffffff7, %eax       # imm = 0xFFFFFFF7
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq