// File: /workspace/github_cpp_makefile_star2_O1/rocket323[P]fishdb/./pager.cpp
// Function: fishdb::Pager::NewPage(fishdb::PageType)
std::shared_ptr<MemPage> Pager::NewPage(PageType type)
{
    std::shared_ptr<MemPage> mp;
    if (m_db_header->free_list != -1)
    {
        mp = ReadPage(m_db_header->free_list);
        m_db_header->free_list = mp->header.next_free;
    }
    else
    {
        mp = std::make_shared<MemPage>();
        mp->header.page_no = m_db_header->total_pages++;
    }
    // init page
    auto &header = mp->header;
    header.type = type;
    header.next_free = -1;
    header.of_page_no = -1;
    header.data_size = 0;
    header.page_cnt = 1;
    header.is_leaf = true;

    if (type == TREE_PAGE &&
            m_pages.find(mp->header.page_no) == m_pages.end())
        CachePage(mp);

    return mp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %rbx
pxor %xmm0, %xmm0
movdqu %xmm0, (%rdi)
movq 0x30(%rsi), %rax
movq (%rax), %rdx
cmpq $-0x1, %rdx
je 0x6432
leaq -0x40(%rbp), %rdi
movq %r14, %rsi
callq 0x67b8
movq -0x40(%rbp), %r12
movq -0x38(%rbp), %rax
pxor %xmm0, %xmm0
movdqa %xmm0, -0x40(%rbp)
movq %r12, (%rbx)
movq 0x8(%rbx), %rdi
movq %rax, 0x8(%rbx)
testq %rdi, %rdi
je 0x6413
callq 0x277e
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x6421
callq 0x277e
movq 0x10(%r12), %rax
movq 0x30(%r14), %rcx
movq %rax, (%rcx)
jmp 0x64c2
movl $0xa0, %edi
callq 0x21f0
movq %rax, %r13
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r13)
leaq 0x58b4(%rip), %rax      # 0xbd08
movq %rax, (%r13)
leaq 0x10(%r13), %r12
movl $0x90, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x2120
movq %r13, %rax
addq $0x48, %rax
movq %rax, 0x38(%r13)
movq $0x0, 0x40(%r13)
movb $0x0, 0x48(%r13)
pxor %xmm0, %xmm0
movdqu %xmm0, 0x58(%r13)
movdqu %xmm0, 0x68(%r13)
movdqu %xmm0, 0x78(%r13)
movq %r12, (%rbx)
movq 0x8(%rbx), %rdi
movq %r13, 0x8(%rbx)
testq %rdi, %rdi
je 0x64ae
callq 0x277e
movq 0x30(%r14), %rax
movq 0x10(%rax), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq %rcx, (%r12)
movq (%rbx), %rax
movb %r15b, 0x8(%rax)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x10(%rax)
movl $0x0, 0x20(%rax)
movw $0x1, 0x24(%rax)
movb $0x1, 0x26(%rax)
cmpl $0x2, %r15d
jne 0x6577
movq 0x10(%r14), %rsi
leaq 0x8(%r14), %rcx
movq %rcx, %rdx
testq %rsi, %rsi
je 0x651c
movq (%rax), %rdi
movq %rcx, %rdx
xorl %r8d, %r8d
cmpq %rdi, 0x20(%rsi)
setl %r8b
cmovgeq %rsi, %rdx
movq 0x10(%rsi,%r8,8), %rsi
testq %rsi, %rsi
jne 0x6503
movq %rcx, %rsi
cmpq %rcx, %rdx
je 0x6532
movq (%rax), %rsi
cmpq 0x20(%rdx), %rsi
cmovlq %rcx, %rdx
movq %rdx, %rsi
cmpq %rcx, %rsi
jne 0x6577
movq %rax, -0x50(%rbp)
movq 0x8(%rbx), %rax
movq %rax, -0x48(%rbp)
testq %rax, %rax
je 0x655d
movq 0x5a81(%rip), %rcx      # 0xbfd0
cmpb $0x0, (%rcx)
je 0x6559
incl 0x8(%rax)
jmp 0x655d
lock
incl 0x8(%rax)
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x69bc
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x6577
callq 0x277e
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x65a1
callq 0x277e
jmp 0x65a1
jmp 0x659e
movq %rax, %r14
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x65af
callq 0x277e
movq %r14, %rdi
callq 0x2300
nop