// File: /workspace/github_c_makefile_star2_O1/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 0x370b5
leaq -0x30(%rbp), %rdx
movl $0x1, %esi
callq *0x10(%rax)
testl %eax, %eax
jne 0x370ce
movq -0x30(%rbp), %r15
movq (%r15), %r13
movq %r15, 0xd0(%rbx)
movl (%r13), %eax
bswapl %eax
movl %eax, 0x138(%rbx)
movl $0xffffffe8, %r14d      # imm = 0xFFFFFFE8
cmpl $0xfa782dcb, %eax       # imm = 0xFA782DCB
jne 0x370fc
movl 0x4(%r13), %r14d
bswapl %r14d
leaq 0x3e911(%rip), %rdi     # 0x758ac
movl $0xa, %esi
callq *0xc0(%rbx)
cmpl %r14d, %eax
jne 0x370e3
leaq 0x8(%r13), %rdi
leaq 0x118(%rbx), %rsi
callq 0x376e7
leaq 0x10(%r13), %rdi
leaq 0x120(%rbx), %rsi
callq 0x376e7
leaq 0x18(%r13), %rdi
leaq 0x128(%rbx), %rsi
callq 0x376e7
leaq 0x20(%r13), %rdi
movq 0x128(%rbx), %rax
addq %rax, %rax
movq %rax, 0x130(%rbx)
leaq 0xf8(%rbx), %r14
movq 0x10(%r15), %rax
movq %rax, 0xf8(%rbx)
leaq 0x108(%rbx), %r12
movq %r12, %rsi
callq 0x376e7
movl 0x28(%r13), %eax
bswapl %eax
movl %eax, 0x104(%rbx)
movq (%r15), %rdx
movq %r14, %r15
subl %edx, %r13d
addl $0x2c, %r13d
movw %r13w, 0x100(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x376f6
movl %eax, %r14d
testl %eax, %eax
jne 0x370fc
movq (%r12), %r13
testq %r13, %r13
je 0x37073
movq (%rbx), %rax
movq (%rax), %rdi
movq %r13, %rsi
leaq -0x38(%rbp), %rdx
callq *0x10(%rax)
testl %eax, %eax
je 0x3707a
movl $0x1, %ecx
movl %eax, %r14d
jmp 0x370a7
movl $0x2, %ecx
jmp 0x370a7
movq %r13, 0xf8(%rbx)
movw $0x0, 0x100(%rbx)
movq -0x38(%rbp), %rax
movq (%rax), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x376f6
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
cmovnel %eax, %r14d
testl %ecx, %ecx
je 0x3704c
cmpl $0x2, %ecx
jne 0x370fc
xorl %r14d, %r14d
jmp 0x370fc
leaq -0x30(%rbp), %rsi
callq *0x20(%rax)
testl %eax, %eax
jne 0x370ce
movq (%rbx), %rax
movq -0x30(%rbp), %rdi
callq *0x28(%rax)
testl %eax, %eax
je 0x37106
movl %eax, %r14d
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx), %rax
movq (%rax), %rdi
leaq 0x3e7c7(%rip), %rsi     # 0x758b7
callq *0x80(%rax)
movl $0xfffffff7, %r14d      # imm = 0xFFFFFFF7
testl %r14d, %r14d
jne 0x370d1
jmp 0x37197
movq -0x30(%rbp), %r15
movq (%r15), %r14
movq %r15, 0xd0(%rbx)
movl 0x138(%rbx), %eax
bswapl %eax
movl %eax, (%r14)
leaq 0x3e786(%rip), %rdi     # 0x758ac
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), %eax
subl %eax, %r14d
addl $0x2c, %r14d
movw %r14w, 0x100(%rbx)
xorl %r14d, %r14d
jmp 0x370d1