// File: /workspace/github_c_makefile_star2_O2/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 0x2f14b
pushq $0x1
popq %rsi
leaq -0x30(%rbp), %rdx
callq *0x10(%rax)
testl %eax, %eax
jne 0x2f21a
movq -0x30(%rbp), %r13
movq (%r13), %r14
movq %r13, 0xd0(%rbx)
leaq 0x138(%rbx), %rsi
movq %r14, %rdi
callq 0x2f679
cmpl $0xfa782dcb, 0x138(%rbx) # imm = 0xFA782DCB
jne 0x2f200
leaq 0x4(%r14), %rdi
leaq -0x3c(%rbp), %r15
movq %r15, %rsi
callq 0x2f679
leaq 0x34849(%rip), %rdi     # 0x63894
pushq $0xa
popq %rsi
callq *0xc0(%rbx)
cmpl (%r15), %eax
jne 0x2f204
leaq 0x8(%r14), %rdi
leaq 0x118(%rbx), %rsi
callq 0x2f685
leaq 0x10(%r14), %rdi
leaq 0x120(%rbx), %rsi
callq 0x2f685
leaq 0x18(%r14), %rdi
leaq 0x128(%rbx), %rsi
callq 0x2f685
leaq 0x20(%r14), %rdi
movq 0x128(%rbx), %rax
addq %rax, %rax
movq %rax, 0x130(%rbx)
leaq 0xf8(%rbx), %r15
movq 0x10(%r13), %rax
movq %rax, 0xf8(%rbx)
leaq 0x108(%rbx), %r12
movq %r12, %rsi
callq 0x2f685
leaq 0x28(%r14), %rdi
leaq 0x104(%rbx), %rsi
callq 0x2f679
movq (%r13), %rdx
subl %edx, %r14d
addl $0x2c, %r14d
movw %r14w, 0x100(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2f694
testl %eax, %eax
jne 0x2f21a
leaq -0x38(%rbp), %r14
movq (%r12), %r13
testq %r13, %r13
je 0x2f1fc
movq (%rbx), %rax
movq (%rax), %rdi
movq %r13, %rsi
movq %r14, %rdx
callq *0x10(%rax)
testl %eax, %eax
jne 0x2f21a
movq %r13, 0xf8(%rbx)
andw $0x0, 0x100(%rbx)
movq -0x38(%rbp), %rax
movq (%rax), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2f694
testl %eax, %eax
je 0x2f0fd
jmp 0x2f21a
leaq -0x30(%rbp), %rsi
callq *0x20(%rax)
testl %eax, %eax
jne 0x2f21a
movq (%rbx), %rax
movq -0x30(%rbp), %rdi
callq *0x28(%rax)
testl %eax, %eax
jne 0x2f21a
movq -0x30(%rbp), %r15
movq (%r15), %r14
movq %r15, 0xd0(%rbx)
movl 0x138(%rbx), %eax
bswapl %eax
movl %eax, (%r14)
leaq 0x34708(%rip), %rdi     # 0x63894
pushq $0xa
popq %rsi
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)
leaq 0x10(%r14), %rdi
andq $0x0, 0x8(%r14)
movq 0x120(%rbx), %rsi
callq 0x2f66d
leaq 0x18(%r14), %rdi
movq 0x128(%rbx), %rsi
callq 0x2f66d
movq 0x10(%r15), %rax
movq %rax, 0xf8(%rbx)
andl $0x0, 0x28(%r14)
andq $0x0, 0x20(%r14)
movl (%r15), %eax
subl %eax, %r14d
addl $0x2c, %r14d
movw %r14w, 0x100(%rbx)
xorl %eax, %eax
jmp 0x2f21a
pushq $-0x18
jmp 0x2f219
movq (%rbx), %rax
movq (%rax), %rdi
leaq 0x3468e(%rip), %rsi     # 0x6389f
callq *0x80(%rax)
pushq $-0x9
popq %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq