// File: /workspace/github_cpp_makefile_star2_O2/momohatt[P]seccampDB/database.cpp
// Function: DataBase::DataBase(Scheduler*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
DataBase::DataBase(Scheduler* scheduler, string dumpfilename, string logfilename)
  : scheduler_(scheduler),
    dumpfilename_(dumpfilename),
    logfilename_(logfilename)
{
    LOG;
    scheduler_->set_db(this);

    // 前回のDBファイルをメモリに読み出し
    ifstream ifs_dump(dumpfilename);
    string str;

    while (getline(ifs_dump, str)) {
        if (str == "") continue;
        vector<string> fields = words(str);
        if (fields.size() != 2) {
            UNREACHABLE;
            exit(1);
        }
        table[fields[0]].value = stoi(fields[1]);
    }

    ifs_dump.close();

    // (必要なら) crash recovery
    recover();

    fd_log_ = open(logfilename.c_str(), O_WRONLY | O_TRUNC);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movq %rcx, %r13
movq %rdi, %rbx
leaq 0x8(%rdi), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movq %rax, 0x18(%rdi)
movq %rax, 0x20(%rdi)
andq $0x0, 0x28(%rdi)
movq %rdx, %r14
movq %rsi, 0x30(%rdi)
leaq 0x38(%rdi), %r15
movq %r15, %rdi
movq %rdx, %rsi
callq 0x3320
leaq 0x58(%rbx), %r12
movq %r12, %rdi
movq %r13, %rsi
movq %r15, 0x8(%rsp)
callq 0x3320
movq %r13, 0x10(%rsp)
movq %r12, (%rsp)
andl $0x0, 0x7c(%rbx)
leaq 0x64db(%rip), %rdi      # 0xb528
leaq 0x64f9(%rip), %rsi      # 0xb54d
movl $0xdf, %edx
xorl %eax, %eax
callq 0x3050
movq 0x30(%rbx), %rax
movq %rbx, 0xb0(%rax)
leaq 0x50(%rsp), %rdi
pushq $0x8
popq %rdx
movq %r14, %rsi
callq 0x33c0
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x50(%rsp), %r13
leaq 0x30(%rsp), %rbp
leaq 0x64ea(%rip), %r14      # 0xb587
leaq 0x18(%rsp), %r15
movq %r13, %rdi
movq %rbp, %rsi
callq 0x3070
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x5113
movq %rbp, %rdi
movq %r14, %rsi
callq 0x3bf1
testb %al, %al
jne 0x50a2
movq %r15, %rdi
movq %rbp, %rsi
callq 0x372c
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rax
subq %rdi, %rax
cmpq $0x40, %rax
jne 0x5162
addq $0x20, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x3bfe
movl %eax, %r12d
movq 0x18(%rsp), %rsi
movq %rbx, %rdi
callq 0x6140
movl %r12d, (%rax)
movq %r15, %rdi
callq 0x3ba2
jmp 0x50a2
leaq 0x50(%rsp), %rdi
callq 0x3080
movq %rbx, %rdi
callq 0x51ea
movq 0x10(%rsp), %rax
movq (%rax), %rdi
movl $0x201, %esi            # imm = 0x201
xorl %eax, %eax
callq 0x31f0
movl %eax, 0x78(%rbx)
leaq 0x30(%rsp), %rdi
callq 0x3498
leaq 0x50(%rsp), %rdi
callq 0x3090
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xce67(%rip), %rax      # 0x11fd0
movq (%rax), %rdi
leaq 0x6385(%rip), %rsi      # 0xb4f8
leaq 0x63d3(%rip), %rdx      # 0xb54d
movl $0xea, %ecx
xorl %eax, %eax
callq 0x3350
pushq $0x1
popq %rdi
callq 0x3300
movq %rax, %r14
jmp 0x51c7
movq %rax, %r14
jmp 0x51d0
movq %rax, %r14
jmp 0x51da
jmp 0x51b0
jmp 0x51b0
movq %rax, %r14
leaq 0x18(%rsp), %rdi
callq 0x3ba2
jmp 0x51b3
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x3498
leaq 0x50(%rsp), %rdi
callq 0x3090
movq (%rsp), %rdi
callq 0x3498
movq 0x8(%rsp), %rdi
callq 0x3498
movq %rbx, %rdi
callq 0x6c6a
movq %r14, %rdi
callq 0x3410