// File: momohatt[P]seccampDB/database.cpp
// Function: DataBase::recover()
void DataBase::recover() {
    LOG;
    ifstream ifs_log(logfilename_);
    string line;
    vector<string> buf;
    bool in_transaction = false;

    while (getline(ifs_log, line)) {
        if (line == "")
            continue;

       if (line == "{") {
            if (in_transaction) {
                UNREACHABLE;
                return;
            }
            in_transaction = true;
            continue;
        }
        if (line == "}") {
            if (!in_transaction) {
                UNREACHABLE;
                return;
            }
            in_transaction = false;
            continue;
        }

        buf.push_back(line);
    }

    DBDiff diff = {};
    deserialize(diff, buf);
    for (const auto& [key, value] : diff) {
        if (value.first == New) {
            table[key].value = value.second;
        } else {
            table.erase(key);
        }
    }

    ifs_log.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x300, %rsp            # imm = 0x300
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2e0(%rbp)
leaq 0x15067(%rip), %rdi     # 0x1c518
leaq 0x15090(%rip), %rsi     # 0x1c548
movl $0x10a, %edx            # imm = 0x10A
movb $0x0, %al
callq 0x3070
movq -0x2e0(%rbp), %rsi
addq $0x58, %rsi
leaq -0x210(%rbp), %rdi
movl $0x8, %edx
callq 0x34e0
leaq -0x230(%rbp), %rdi
callq 0x3440
leaq -0x248(%rbp), %rdi
callq 0x4190
movb $0x0, -0x249(%rbp)
leaq -0x210(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0x30a0
movq %rax, -0x2e8(%rbp)
jmp 0x751b
movq -0x2e8(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3410
movb %al, -0x2e9(%rbp)
jmp 0x7539
movb -0x2e9(%rbp), %al
testb $0x1, %al
jne 0x7548
jmp 0x7680
leaq 0x15028(%rip), %rsi     # 0x1c577
leaq -0x230(%rbp), %rdi
callq 0x42c0
movb %al, -0x2ea(%rbp)
jmp 0x7563
movb -0x2ea(%rbp), %al
testb $0x1, %al
jne 0x756f
jmp 0x7588
jmp 0x74ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x258(%rbp)
movl %eax, -0x25c(%rbp)
jmp 0x7871
leaq 0x14fc1(%rip), %rsi     # 0x1c550
leaq -0x230(%rbp), %rdi
callq 0x42c0
movb %al, -0x2eb(%rbp)
jmp 0x75a3
movb -0x2eb(%rbp), %al
testb $0x1, %al
jne 0x75af
jmp 0x75f7
testb $0x1, -0x249(%rbp)
je 0x75eb
movq 0x24a11(%rip), %rax     # 0x2bfd0
movq (%rax), %rdi
leaq 0x14f1f(%rip), %rsi     # 0x1c4e8
leaq 0x14f78(%rip), %rdx     # 0x1c548
movl $0x116, %ecx            # imm = 0x116
movb $0x0, %al
callq 0x3470
movl $0x1, -0x260(%rbp)
jmp 0x7838
movb $0x1, -0x249(%rbp)
jmp 0x74ff
leaq 0x14f54(%rip), %rsi     # 0x1c552
leaq -0x230(%rbp), %rdi
callq 0x42c0
movb %al, -0x2ec(%rbp)
jmp 0x7612
movb -0x2ec(%rbp), %al
testb $0x1, %al
jne 0x761e
jmp 0x7666
testb $0x1, -0x249(%rbp)
jne 0x765a
movq 0x249a2(%rip), %rax     # 0x2bfd0
movq (%rax), %rdi
leaq 0x14eb0(%rip), %rsi     # 0x1c4e8
leaq 0x14f09(%rip), %rdx     # 0x1c548
movl $0x11e, %ecx            # imm = 0x11E
movb $0x0, %al
callq 0x3470
movl $0x1, -0x260(%rbp)
jmp 0x7838
movb $0x0, -0x249(%rbp)
jmp 0x74ff
leaq -0x248(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0x9470
jmp 0x767b
jmp 0x74ff
xorps %xmm0, %xmm0
movaps %xmm0, -0x270(%rbp)
movaps %xmm0, -0x280(%rbp)
movaps %xmm0, -0x290(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x9180
leaq -0x2a8(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0xa1c0
jmp 0x76b9
movq -0x2e0(%rbp), %rdi
leaq -0x290(%rbp), %rsi
leaq -0x2a8(%rbp), %rdx
callq 0x7ac0
jmp 0x76d5
leaq -0x2a8(%rbp), %rdi
callq 0x41e0
leaq -0x290(%rbp), %rax
movq %rax, -0x2b0(%rbp)
movq -0x2b0(%rbp), %rdi
callq 0x98c0
movq %rax, -0x2b8(%rbp)
movq -0x2b0(%rbp), %rdi
callq 0x98f0
movq %rax, -0x2c0(%rbp)
leaq -0x2b8(%rbp), %rdi
leaq -0x2c0(%rbp), %rsi
callq 0x9920
testb $0x1, %al
jne 0x7731
jmp 0x7814
leaq -0x2b8(%rbp), %rdi
callq 0x9950
movq %rax, -0x2c8(%rbp)
movq -0x2c8(%rbp), %rdi
callq 0x9970
movq %rax, -0x2d0(%rbp)
movq -0x2c8(%rbp), %rdi
callq 0x9990
movq %rax, -0x2d8(%rbp)
movq -0x2d8(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x77ea
movq -0x2e0(%rbp), %rdi
movq -0x2d8(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x2fc(%rbp)
movq -0x2d0(%rbp), %rsi
callq 0x96d0
movq %rax, -0x2f8(%rbp)
jmp 0x77a2
movq -0x2f8(%rbp), %rax
movl -0x2fc(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x7801
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x258(%rbp)
movl %eax, -0x25c(%rbp)
jmp 0x7865
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x258(%rbp)
movl %eax, -0x25c(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0x41e0
jmp 0x7865
movq -0x2e0(%rbp), %rdi
movq -0x2d0(%rbp), %rsi
callq 0xa2b0
jmp 0x77ff
jmp 0x7801
jmp 0x7803
leaq -0x2b8(%rbp), %rdi
callq 0x99b0
jmp 0x7715
leaq -0x210(%rbp), %rdi
callq 0x30b0
jmp 0x7822
leaq -0x290(%rbp), %rdi
callq 0xa2e0
movl $0x0, -0x260(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x41e0
leaq -0x230(%rbp), %rdi
callq 0x35f8
leaq -0x210(%rbp), %rdi
callq 0x30c0
addq $0x300, %rsp            # imm = 0x300
popq %rbp
retq
leaq -0x290(%rbp), %rdi
callq 0xa2e0
leaq -0x248(%rbp), %rdi
callq 0x41e0
leaq -0x230(%rbp), %rdi
callq 0x35f8
leaq -0x210(%rbp), %rdi
callq 0x30c0
movq -0x258(%rbp), %rdi
callq 0x3540
nopw %cs:(%rax,%rax)