// File: /workspace/github_cpp_makefile_star2_O1/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, 0x10(%rdi)
movups %xmm0, 0x20(%rdi)
movups %xmm0, (%rdi)
movq %rax, 0x18(%rdi)
movq %rax, 0x20(%rdi)
movq $0x0, 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 0x840a
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 0x840a
movq %rbp, 0x18(%rsp)
movq %r13, 0x20(%rsp)
movq %r12, 0x28(%rsp)
movl $0x0, 0x7c(%r15)
leaq 0x6d8c(%rip), %rdi      # 0xc508
leaq 0x6daa(%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 0x58d1
movq %r14, %rdi
leaq 0x6d4a(%rip), %rsi      # 0xc567
callq 0x30b0
testl %eax, %eax
je 0x57da
movq %r13, %r15
movq %r13, %rdi
movq %r14, %rsi
callq 0x397c
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
subq %rax, %rcx
cmpq $0x40, %rcx
jne 0x593a
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 0x593f
movq %rax, %rbx
movslq %ebx, %rax
cmpq %rbx, %rax
jne 0x594b
movl (%r12), %eax
cmpl $0x22, %eax
je 0x594b
testl %eax, %eax
movq %r13, %r14
jne 0x58b0
movl 0x34(%rsp), %eax
movl %eax, (%r12)
movq 0x68(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x74a4
movq %r15, %r13
movl %ebx, (%rax)
movq %r15, %rdi
callq 0x3fa8
jmp 0x57d5
leaq 0x80(%rsp), %rdi
callq 0x3080
movq 0x8(%rsp), %rdi
callq 0x5a52
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 0x591b
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 0x673f(%rip), %rdi      # 0xc085
callq 0x3190
leaq 0x6733(%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 0x5a18
movq %rax, %r14
movq %r15, %rbx
movq 0x10(%rsp), %r15
jmp 0x5a2d
movq %rax, %r14
movq %r15, %rbx
jmp 0x5a41
jmp 0x59d3
movq %rax, %r14
jmp 0x59ae
jmp 0x59d3
movq %rax, %r14
cmpl $0x0, (%r12)
jne 0x59ae
movl 0x34(%rsp), %eax
movl %eax, (%r12)
leaq 0x68(%rsp), %rdi
callq 0x3fa8
movq 0x8(%rsp), %rbx
movq 0x10(%rsp), %r15
movq 0x28(%rsp), %r12
movq 0x20(%rsp), %r13
movq 0x18(%rsp), %rbp
jmp 0x59ef
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 0x5a0b
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x32a0
leaq 0x80(%rsp), %rdi
callq 0x3090
movq (%rbp), %rdi
cmpq %r13, %rdi
je 0x5a2d
movq (%r13), %rsi
incq %rsi
callq 0x32a0
movq (%r12), %rdi
cmpq %r15, %rdi
je 0x5a41
movq (%r15), %rsi
incq %rsi
callq 0x32a0
movq %rbx, %rdi
callq 0x7f4e
movq %r14, %rdi
callq 0x3410
nop