// File: eva23511[P]OS-Virtual-Memory-Management/main.cpp
// Function: main
int main(int argc, char * argv[]) {
    string input_filename;
    string rand_filename;
    int num_frames = 0;
    string algo;
    
    ParseCommand(argc, argv, num_frames, algo, input_filename, rand_filename);
    
    // get randoms
    vector<int> randoms = ParseRandFile(rand_filename);
    
    // initialzie frames and pager
    initFrames(num_frames);
    Pager * pager = GetPager(algo, randoms, num_frames);
    
    
    // parse input_file and Initialzie process
    ifstream input_file (input_filename);
    vector<Process *> processes = GetProcess(input_file);
    
    Simulation(input_file, pager, processes);
    
    if (P_option) {
        PrintPagetable(processes);
    }
    
    if (F_option) {
        PrintFrameTable();
    }
    
    if (S_option) {
        PrintSummary(processes);
    }
    
    input_file.close();
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x390, %rsp            # imm = 0x390
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x378(%rbp)
callq 0x3280
leaq -0x50(%rbp), %rdi
movq %rdi, -0x370(%rbp)
callq 0x3280
movl $0x0, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
movq %rdi, -0x380(%rbp)
callq 0x3280
movq -0x380(%rbp), %rcx
movq -0x378(%rbp), %r8
movq -0x370(%rbp), %r9
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq -0x54(%rbp), %rdx
callq 0x3950
jmp 0x35e7
leaq -0xc0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x30f0
jmp 0x35f9
leaq -0xa0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x3c30
jmp 0x360e
leaq -0xc0(%rbp), %rdi
callq 0x3150
movl -0x54(%rbp), %edi
callq 0x3de0
jmp 0x3624
leaq -0xe8(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x30f0
jmp 0x3636
leaq -0x100(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x5170
jmp 0x364b
movl -0x54(%rbp), %edx
leaq -0xe8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x3e90
movq %rax, -0x388(%rbp)
jmp 0x366a
leaq -0x100(%rbp), %rdi
callq 0x5260
leaq -0xe8(%rbp), %rdi
callq 0x3150
movq -0x388(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq -0x308(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movl $0x8, %edx
callq 0x32d0
jmp 0x36a7
leaq -0x320(%rbp), %rdi
leaq -0x308(%rbp), %rsi
callq 0x4190
jmp 0x36bc
movq -0xc8(%rbp), %rax
movq %rax, -0x390(%rbp)
leaq -0x338(%rbp), %rdi
leaq -0x320(%rbp), %rsi
callq 0x52c0
jmp 0x36df
movq -0x390(%rbp), %rsi
leaq -0x308(%rbp), %rdi
leaq -0x338(%rbp), %rdx
callq 0x4480
jmp 0x36fb
leaq -0x338(%rbp), %rdi
callq 0x53b0
cmpl $0x0, 0x11ada(%rip)     # 0x151e8
je 0x3835
leaq -0x350(%rbp), %rdi
leaq -0x320(%rbp), %rsi
callq 0x52c0
jmp 0x3729
leaq -0x350(%rbp), %rdi
callq 0x4980
jmp 0x3737
leaq -0x350(%rbp), %rdi
callq 0x53b0
jmp 0x3835
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x3922
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x3150
jmp 0x3922
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x3916
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x37bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x5260
leaq -0xe8(%rbp), %rdi
callq 0x3150
jmp 0x3916
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x390a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x38fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x338(%rbp), %rdi
callq 0x53b0
jmp 0x38fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x350(%rbp), %rdi
callq 0x53b0
jmp 0x38fe
cmpl $0x0, 0x119b0(%rip)     # 0x151ec
je 0x3847
callq 0x49f0
jmp 0x3845
jmp 0x3847
cmpl $0x0, 0x119a2(%rip)     # 0x151f0
je 0x389e
leaq -0x368(%rbp), %rdi
leaq -0x320(%rbp), %rsi
callq 0x52c0
jmp 0x3865
leaq -0x368(%rbp), %rdi
callq 0x4ab0
jmp 0x3873
leaq -0x368(%rbp), %rdi
callq 0x53b0
jmp 0x389e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x368(%rbp), %rdi
callq 0x53b0
jmp 0x38fe
leaq -0x308(%rbp), %rdi
callq 0x3070
jmp 0x38ac
movl $0x0, -0x4(%rbp)
leaq -0x320(%rbp), %rdi
callq 0x53b0
leaq -0x308(%rbp), %rdi
callq 0x3090
leaq -0xa0(%rbp), %rdi
callq 0x5260
leaq -0x78(%rbp), %rdi
callq 0x3150
leaq -0x50(%rbp), %rdi
callq 0x3150
leaq -0x30(%rbp), %rdi
callq 0x3150
movl -0x4(%rbp), %eax
addq $0x390, %rsp            # imm = 0x390
popq %rbp
retq
leaq -0x320(%rbp), %rdi
callq 0x53b0
leaq -0x308(%rbp), %rdi
callq 0x3090
leaq -0xa0(%rbp), %rdi
callq 0x5260
leaq -0x78(%rbp), %rdi
callq 0x3150
leaq -0x50(%rbp), %rdi
callq 0x3150
leaq -0x30(%rbp), %rdi
callq 0x3150
movq -0x80(%rbp), %rdi
callq 0x3320
nopw %cs:(%rax,%rax)