// File: /workspace/github_cpp_makefile_star2_O1/eva23511[P]OS-Virtual-Memory-Management/main.cpp
// Function: ParseCommand(int, char**, int&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
void ParseCommand(int argc, char * argv[], int &num_frames, string &algo, string &input_filename, string &rand_filename) {
    
    if (argc < 3) {
        printf("Use this to run: ./mmu –f<num_frames> -a<algo> [-o<options>] inputfile randomfile\n");
        exit (EXIT_FAILURE);
    }
    
    int c;
    while ((c = getopt (argc, argv, "a:f:o:")) != -1) {
        switch(c) {
            case 'f':
                num_frames = atoi(optarg);
                break;
            case 'a':
                algo = string(optarg);
                break;
            case 'o':
                ParseOptions(string(optarg));
                break;
            case '?':
                printf("Unknown Option -%c\n", optopt);
                printf("Use this to run: ./mmu –f<num_frames> -a<algo> [-o<options>] inputfile randomfile\n");
                exit (EXIT_FAILURE);
                break;
        }
    }
    
    for (int index = optind; index < argc; index++) {
        if (index == argc - 2) {
            input_filename = argv[index];
        } else if (index == argc - 1) {
            rand_filename = argv[index];
        } else {
            printf("Non-option argument %s\n", argv[index]);
            printf("Use this to run: ./mmu –f<num_frames> -a<algo> [-o<options>] inputfile randomfile\n");
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, -0x48(%rbp)
movq %r8, -0x58(%rbp)
movq %rcx, -0x40(%rbp)
movq %rdx, -0x38(%rbp)
cmpl $0x3, %edi
jl 0x2a1b
movq %rsi, %r12
movl %edi, %r15d
leaq 0x3755(%rip), %r14      # 0x6089
movq 0x667d(%rip), %rbx      # 0x8fb8
movl %r15d, %edi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2060
cmpl $0x65, %eax
jle 0x2968
cmpl $0x6f, %eax
je 0x29ab
cmpl $0x66, %eax
jne 0x293b
movq (%rbx), %rdi
callq 0x21e0
movq -0x38(%rbp), %rcx
movl %eax, (%rcx)
jmp 0x293b
cmpl $0x61, %eax
jne 0x29f6
movq (%rbx), %rsi
leaq -0x78(%rbp), %r13
movq %r13, %rdi
leaq -0x29(%rbp), %rdx
callq 0x3bd4
movq -0x40(%rbp), %rdi
movq %r13, %rsi
callq 0x2170
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x293b
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x2150
jmp 0x293b
movq %rbx, %r13
movq (%rbx), %rsi
leaq -0x98(%rbp), %rbx
movq %rbx, %rdi
leaq -0x78(%rbp), %rdx
callq 0x3bd4
movq %rbx, %rdi
callq 0x3953
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x29ee
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x2150
movq %r13, %rbx
jmp 0x293b
cmpl $-0x1, %eax
je 0x2a31
cmpl $0x3f, %eax
jne 0x293b
movq 0x65c5(%rip), %rax      # 0x8fd0
movl (%rax), %esi
leaq 0x367c(%rip), %rdi      # 0x6090
xorl %eax, %eax
callq 0x2030
leaq 0x3708(%rip), %rdi      # 0x612a
callq 0x21c0
movl $0x1, %edi
callq 0x2160
movq 0x65a0(%rip), %rax      # 0x8fd8
movslq (%rax), %rax
cmpl %eax, %r15d
jle 0x2ad9
leal -0x2(%r15), %ecx
leal -0x1(%r15), %edx
movslq %edx, %rdx
movslq %ecx, %rcx
subq %rax, %rcx
movq %rcx, -0x40(%rbp)
subq %rax, %rdx
movq %rdx, -0x50(%rbp)
leaq (%r12,%rax,8), %rcx
movq %rcx, -0x38(%rbp)
subl %eax, %r15d
xorl %ebx, %ebx
cmpq %rbx, -0x40(%rbp)
jne 0x2a81
movq -0x38(%rbp), %rax
movq (%rax,%rbx,8), %r12
movq -0x58(%rbp), %r14
jmp 0x2a93
movq -0x38(%rbp), %rax
movq (%rax,%rbx,8), %r12
cmpq %rbx, -0x50(%rbp)
jne 0x2ab4
movq -0x48(%rbp), %r14
movq 0x8(%r14), %r13
movq %r12, %rdi
callq 0x20c0
movq %r14, %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %r12, %rcx
movq %rax, %r8
callq 0x21d0
jmp 0x2ad1
leaq 0x35e9(%rip), %rdi      # 0x60a4
movq %r12, %rsi
xorl %eax, %eax
callq 0x2030
leaq 0x365e(%rip), %rdi      # 0x612a
callq 0x21c0
incq %rbx
cmpl %ebx, %r15d
jne 0x2a6d
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq