// File: /workspace/github_cpp_makefile_star2_O2/Konano[P]UselessDatabase/Database.cpp
// Function: Database::Database(char const*, bool)
Database::Database(const char* name, bool create) {
    fm = new FileManager();
    bpm = new BufPageManager(fm);
    memset(table, 0, sizeof(table));
    table_num = 0;
    mem = 0;
    if (create) {
        strcpy(this->name, name); 
        char* dbdir = dirPath(this->name);
        if (access("db", 0) == -1) {
            #ifdef WIN32
            mkdir("db");
            #elif __linux__
            mkdir("db", 0777);
            #endif
        }
        if (access(dbdir, 0) == -1) {
            #ifdef WIN32
            mkdir(dbdir);
            #elif __linux__
            mkdir(dbdir, 0777);
            #endif
        }
        update();
        fm->createFile(dirPath(name, ".storage"));
    } else {
        fromJson(json::parse(readFile(dirPath(name, "database.udb"))));
    }
    fm->openFile(dirPath(name, ".storage"), mem_file);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movl $0x850, %eax            # imm = 0x850
xorps %xmm0, %xmm0
movb $0x0, -0x8(%rbx,%rax)
movups %xmm0, (%rbx,%rax)
movups %xmm0, 0x10(%rbx,%rax)
movups %xmm0, 0x20(%rbx,%rax)
movups %xmm0, 0x30(%rbx,%rax)
movups %xmm0, 0x40(%rbx,%rax)
andq $0x0, 0x70(%rbx,%rax)
movups %xmm0, 0x50(%rbx,%rax)
movups %xmm0, 0x60(%rbx,%rax)
subq $-0x80, %rax
cmpq $0x8850, %rax           # imm = 0x8850
jne 0x61e6
andl $0x0, 0x9048(%rbx)
movl $0x220, %edi            # imm = 0x220
callq 0x53e0
movq %rax, %r15
movq %rax, %rdi
callq 0x14614
movq %r15, 0x828(%rbx)
movl $0x110030, %edi         # imm = 0x110030
callq 0x53e0
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
callq 0x5b8a
movq %r12, 0x830(%rbx)
leaq 0x20(%rbx), %rdi
andq $0x0, 0x840(%rbx)
movl $0x804, %edx            # imm = 0x804
xorl %esi, %esi
callq 0x5270
testb %bpl, %bpl
je 0x6303
movq %rbx, %rdi
movq %r14, %rsi
callq 0x53b0
movq %rbx, %rdi
callq 0x148a7
movq %rax, %r15
leaq 0x31fc1(%rip), %rdi     # 0x38260
xorl %esi, %esi
callq 0x56a0
cmpl $-0x1, %eax
jne 0x62bc
leaq 0x31fae(%rip), %rdi     # 0x38260
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x5210
movq %r15, %rdi
xorl %esi, %esi
callq 0x56a0
cmpl $-0x1, %eax
jne 0x62d8
movq %r15, %rdi
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x5210
movq %rbx, %rdi
callq 0x6136
movq 0x828(%rbx), %r15
leaq 0x2d3f7(%rip), %rsi     # 0x336e5
movq %r14, %rdi
callq 0x148de
movq %r15, %rdi
movq %rax, %rsi
callq 0x146c2
jmp 0x636f
leaq 0x2d3ce(%rip), %rsi     # 0x336d8
movq %r14, %rdi
callq 0x148de
movq %rax, %rdi
callq 0x147fc
movq %rsp, %rdi
movq %rax, %rsi
callq 0x831c
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rdx
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, (%rdx)
leaq 0x10(%rsp), %rdi
movq %rsp, %rsi
pushq $0x1
popq %rcx
callq 0x8250
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x6014
leaq 0x10(%rsp), %rdi
callq 0x7de0
leaq 0x20(%rsp), %rdi
callq 0x8344
leaq 0x8(%rsp), %rdi
callq 0x8baa
movq 0x828(%rbx), %r15
leaq 0x2d368(%rip), %rsi     # 0x336e5
movq %r14, %rdi
callq 0x148de
leaq 0x838(%rbx), %rdx
movq %r15, %rdi
movq %rax, %rsi
callq 0x146ea
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x7de0
jmp 0x63b6
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x8344
leaq 0x8(%rsp), %rdi
callq 0x8baa
jmp 0x63f2
movq %rax, %r14
movl $0x110030, %esi         # imm = 0x110030
movq %r12, %rdi
jmp 0x63e4
movq %rax, %r14
movl $0x220, %esi            # imm = 0x220
movq %r15, %rdi
callq 0x53f0
jmp 0x63f2
jmp 0x63ef
jmp 0x63ef
movq %rax, %r14
movl $0x87c8, %r15d          # imm = 0x87C8
leaq (%rbx,%r15), %rdi
callq 0x8360
addq $-0x80, %r15
cmpq $0x7c8, %r15            # imm = 0x7C8
jne 0x63f8
movq %r14, %rdi
callq 0x56f0