// File: gossterrible[P]Calendar-/Calendar.cpp
// Function: Calendar::Load()
void Calendar::Load() {
    events.clear();

    ifstream file;
    file.open("db.event", ios::app);
    file.seekg(0, ios::end); // put the "cursor" at the end of the file
    int length = file.tellg(); // find the position of the cursor

    if (!file.is_open()) {
        cerr << "Unable to open the file: " << endl;
        cerr << "Abort loading events." << endl;
        return;
    }



    while (true) {
        Event event;

        int year, month, day;
        file >> year >> month>> day;

        if (file.eof())
            break;

        event.date.setDate(year, month, day);

        string desc;
        file >> event.description;

        events.push_back(event);
    }


    file.close();
    cout << "Load from file success." << endl;
    if (length == 0) {
        cout << "The are no event currently stored\n";
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x300, %rsp            # imm = 0x300
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x2a8(%rbp)
addq $0x10, %rdi
callq 0x52b0
leaq -0x210(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x32a0
movq -0x2a0(%rbp), %rdi
leaq 0x2599(%rip), %rsi      # 0x71ad
movl $0x1, %edx
callq 0x3110
jmp 0x4c20
xorl %eax, %eax
movl %eax, %esi
leaq -0x210(%rbp), %rdi
movl $0x2, %edx
callq 0x3310
jmp 0x4c37
leaq -0x210(%rbp), %rdi
callq 0x33c0
movq %rdx, -0x2b8(%rbp)
movq %rax, -0x2b0(%rbp)
jmp 0x4c53
movq -0x2b8(%rbp), %rax
movq -0x2b0(%rbp), %rcx
movq %rcx, -0x230(%rbp)
movq %rax, -0x228(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x52d0
movq %rax, -0x2c0(%rbp)
jmp 0x4c84
movq -0x2c0(%rbp), %rax
movl %eax, -0x220(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x3380
movb %al, -0x2c1(%rbp)
jmp 0x4ca5
movb -0x2c1(%rbp), %al
testb $0x1, %al
jne 0x4d3d
jmp 0x4cb5
movq 0x5334(%rip), %rdi      # 0x9ff0
leaq 0x2509(%rip), %rsi      # 0x71cc
callq 0x3200
movq %rax, -0x2d0(%rbp)
jmp 0x4cd1
movq -0x2d0(%rbp), %rdi
movq 0x52d9(%rip), %rsi      # 0x9fb8
callq 0x3230
jmp 0x4ce6
movq 0x5303(%rip), %rdi      # 0x9ff0
leaq 0x24f2(%rip), %rsi      # 0x71e6
callq 0x3200
movq %rax, -0x2d8(%rbp)
jmp 0x4d02
movq -0x2d8(%rbp), %rdi
movq 0x52a8(%rip), %rsi      # 0x9fb8
callq 0x3230
jmp 0x4d17
movl $0x1, -0x234(%rbp)
jmp 0x4f12
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x4f27
jmp 0x4d3f
jmp 0x4d41
leaq -0x268(%rbp), %rdi
callq 0x4f60
jmp 0x4d4f
leaq -0x210(%rbp), %rdi
leaq -0x26c(%rbp), %rsi
callq 0x30f0
movq %rax, -0x2e0(%rbp)
jmp 0x4d6b
movq -0x2e0(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x30f0
movq %rax, -0x2e8(%rbp)
jmp 0x4d87
movq -0x2e8(%rbp), %rdi
leaq -0x274(%rbp), %rsi
callq 0x30f0
jmp 0x4d9c
movq -0x210(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x210(%rbp,%rax), %rdi
callq 0x3410
movb %al, -0x2e9(%rbp)
jmp 0x4dbc
movb -0x2e9(%rbp), %al
testb $0x1, %al
jne 0x4dc8
jmp 0x4dee
movl $0x3, -0x234(%rbp)
jmp 0x4e5e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x4e9b
movl -0x26c(%rbp), %esi
movl -0x270(%rbp), %edx
movl -0x274(%rbp), %ecx
leaq -0x268(%rbp), %rdi
callq 0x6480
jmp 0x4e0e
leaq -0x298(%rbp), %rdi
callq 0x3320
leaq -0x258(%rbp), %rsi
leaq -0x210(%rbp), %rdi
callq 0x32f0
jmp 0x4e2f
movq -0x2a8(%rbp), %rdi
addq $0x10, %rdi
leaq -0x268(%rbp), %rsi
callq 0x4f90
jmp 0x4e48
leaq -0x298(%rbp), %rdi
callq 0x3100
movl $0x0, -0x234(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x5000
movl -0x234(%rbp), %eax
testl %eax, %eax
je 0x4e78
jmp 0x4e76
jmp 0x4ea9
jmp 0x4d3f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x298(%rbp), %rdi
callq 0x3100
leaq -0x268(%rbp), %rdi
callq 0x5000
jmp 0x4f27
leaq -0x210(%rbp), %rdi
callq 0x3060
jmp 0x4eb7
movq 0x510a(%rip), %rdi      # 0x9fc8
leaq 0x2337(%rip), %rsi      # 0x71fc
callq 0x3200
movq %rax, -0x2f8(%rbp)
jmp 0x4ed3
movq -0x2f8(%rbp), %rdi
movq 0x50d7(%rip), %rsi      # 0x9fb8
callq 0x3230
jmp 0x4ee8
cmpl $0x0, -0x220(%rbp)
jne 0x4f08
movq 0x50d0(%rip), %rdi      # 0x9fc8
leaq 0x2315(%rip), %rsi      # 0x7214
callq 0x3200
jmp 0x4f06
jmp 0x4f08
movl $0x0, -0x234(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x3070
addq $0x300, %rsp            # imm = 0x300
popq %rbp
retq
leaq -0x210(%rbp), %rdi
callq 0x3070
movq -0x218(%rbp), %rdi
callq 0x33d0
nop