// File: /workspace/github_cpp_makefile_star2_O3/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 $0x288, %rsp            # imm = 0x288
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r15
leaq 0x8(%rdi), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
xorl %ecx, %ecx
movq %rcx, 0x10(%rdi)
movq %rax, 0x18(%rdi)
movq %rax, 0x20(%rdi)
movq %rcx, 0x28(%rdi)
movq %rsi, 0x30(%rdi)
addq $0x38, %rdi
leaq 0x48(%r15), %rax
movq %rax, 0x10(%rsp)
movq %rax, 0x38(%r15)
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
addq %rsi, %rdx
movq %rdi, %r12
callq 0x839a
leaq 0x58(%r15), %rbp
leaq 0x68(%r15), %r13
movq %r13, 0x58(%r15)
movq (%rbx), %rsi
movq %rbx, 0x38(%rsp)
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0x839a
movq %rbp, 0x18(%rsp)
movq %r13, 0x20(%rsp)
movq %r12, 0x28(%rsp)
movl $0x0, 0x7c(%r15)
leaq 0x6d96(%rip), %rdi      # 0xc508
leaq 0x6db4(%rip), %rsi      # 0xc52d
movl $0xdf, %edx
xorl %eax, %eax
callq 0x3060
movq 0x30(%r15), %rax
movq %r15, 0x8(%rsp)
movq %r15, 0xb0(%rax)
leaq 0x80(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
movl $0x8, %edx
callq 0x33c0
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x40(%rsp), %r14
leaq 0x68(%rsp), %r13
movq 0x38(%rsp), %rbx
movq 0x80(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3270
movsbl %al, %edx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x3440
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x58c7
movq %r14, %rdi
leaq 0x6d54(%rip), %rsi      # 0xc567
callq 0x30b0
testl %eax, %eax
je 0x57d0
movq %r13, %r15
movq %r13, %rdi
movq %r14, %rsi
callq 0x399c
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
subq %rax, %rcx
cmpq $0x40, %rcx
jne 0x5930
movq %r14, %r13
movq 0x20(%rax), %r14
callq 0x3050
movq %rax, %r12
movl (%rax), %eax
movl %eax, 0x34(%rsp)
movl $0x0, (%r12)
movq %r14, %rdi
leaq 0x60(%rsp), %rsi
movl $0xa, %edx
callq 0x3350
cmpq %r14, 0x60(%rsp)
je 0x5935
movq %rax, %rbx
movslq %ebx, %rax
cmpq %rbx, %rax
jne 0x5941
movl (%r12), %eax
cmpl $0x22, %eax
je 0x5941
testl %eax, %eax
movq %r13, %r14
jne 0x58a6
movl 0x34(%rsp), %eax
movl %eax, (%r12)
movq 0x68(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x7446
movq %r15, %r13
movl %ebx, (%rax)
movq %r15, %rdi
callq 0x3fa6
jmp 0x57cb
leaq 0x80(%rsp), %rdi
callq 0x3080
movq 0x8(%rsp), %rdi
callq 0x5a48
movq (%rbx), %rdi
movl $0x201, %esi            # imm = 0x201
xorl %eax, %eax
callq 0x31f0
movq 0x8(%rsp), %rcx
movl %eax, 0x78(%rcx)
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x5911
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x32a0
leaq 0x80(%rsp), %rdi
callq 0x3090
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x34fd
leaq 0x6749(%rip), %rdi      # 0xc085
callq 0x3190
leaq 0x673d(%rip), %rdi      # 0xc085
callq 0x3380
movq %rax, %r14
movq 0x10(%rsp), %r15
movq 0x28(%rsp), %r12
movq 0x20(%rsp), %r13
movq 0x18(%rsp), %rbp
movq 0x8(%rsp), %rbx
jmp 0x5a0e
movq %rax, %r14
movq %r15, %rbx
movq 0x10(%rsp), %r15
jmp 0x5a23
movq %rax, %r14
movq %r15, %rbx
jmp 0x5a37
jmp 0x59c9
movq %rax, %r14
jmp 0x59a4
jmp 0x59c9
movq %rax, %r14
cmpl $0x0, (%r12)
jne 0x59a4
movl 0x34(%rsp), %eax
movl %eax, (%r12)
leaq 0x68(%rsp), %rdi
callq 0x3fa6
movq 0x8(%rsp), %rbx
movq 0x10(%rsp), %r15
movq 0x28(%rsp), %r12
movq 0x20(%rsp), %r13
movq 0x18(%rsp), %rbp
jmp 0x59e5
movq %rax, %r14
movq 0x10(%rsp), %r15
movq 0x28(%rsp), %r12
movq 0x20(%rsp), %r13
movq 0x18(%rsp), %rbp
movq 0x8(%rsp), %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x5a01
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x32a0
leaq 0x80(%rsp), %rdi
callq 0x3090
movq (%rbp), %rdi
cmpq %r13, %rdi
je 0x5a23
movq (%r13), %rsi
incq %rsi
callq 0x32a0
movq (%r12), %rdi
cmpq %r15, %rdi
je 0x5a37
movq (%r15), %rsi
incq %rsi
callq 0x32a0
movq %rbx, %rdi
callq 0x7ede
movq %r14, %rdi
callq 0x3410
nop