// File: /workspace/github_cpp_makefile_star2_O3/CMU-SAFARI[P]ramulator/src/Config.cpp
// Function: ramulator::Config::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void Config::parse(const string& fname)
{
    ifstream file(fname);
    assert(file.good() && "Bad config file");
    string line;
    while (getline(file, line)) {
        char delim[] = " \t=";
        vector<string> tokens;

        while (true) {
            size_t start = line.find_first_not_of(delim);
            if (start == string::npos) 
                break;

            size_t end = line.find_first_of(delim, start);
            if (end == string::npos) {
                tokens.push_back(line.substr(start));
                break;
            }

            tokens.push_back(line.substr(start, end - start));
            line = line.substr(end);
        }

        // empty line
        if (!tokens.size())
            continue;

        // comment line
        if (tokens[0][0] == '#')
            continue;

        // parameter line
        assert(tokens.size() == 2 && "Only allow two tokens in one line");

        options[tokens[0]] = tokens[1];

        if (tokens[0] == "channels") {
          channels = atoi(tokens[1].c_str());
        } else if (tokens[0] == "ranks") {
          ranks = atoi(tokens[1].c_str());
        } else if (tokens[0] == "subarrays") {
          subarrays = atoi(tokens[1].c_str());
        } else if (tokens[0] == "cpu_tick") {
          cpu_tick = atoi(tokens[1].c_str());
        } else if (tokens[0] == "mem_tick") {
          mem_tick = atoi(tokens[1].c_str());
        } else if (tokens[0] == "expected_limit_insts") {
          expected_limit_insts = atoi(tokens[1].c_str());
        } else if (tokens[0] == "warmup_insts") {
          warmup_insts = atoi(tokens[1].c_str());
        }
    }
    file.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movq %rdi, 0x8(%rsp)
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movl $0x8, %edx
callq 0xb470
movq (%rbx), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x90(%rsp,%rax)
jne 0x1064c7
leaq 0x60(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
leaq 0x40(%rsp), %r13
leaq 0x50(%rsp), %r15
leaq 0x2c(%rsp), %r12
leaq 0x30(%rsp), %rbp
leaq (%rsp,%rax), %rdi
addq $0x70, %rdi
movl $0xa, %esi
callq 0xb2c0
movsbl %al, %edx
leaq 0x70(%rsp), %rdi
movq %r15, %rsi
callq 0xb540
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x106466
movl $0x3d0920, 0x2c(%rsp)   # imm = 0x3D0920
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq %r12, %rdi
callq 0xb180
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0xb4c0
movq %rax, %rbx
cmpq $-0x1, %rax
je 0x1062cc
movq %r12, %rdi
callq 0xb180
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %rax, %rcx
callq 0xb400
cmpq $-0x1, %rax
je 0x106293
movq %rax, %r14
movq %rax, %rcx
subq %rbx, %rcx
movq %rbp, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0xb310
leaq 0x10(%rsp), %rdi
movq %rbp, %rsi
callq 0x106626
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x106253
movq 0x40(%rsp), %rsi
incq %rsi
callq 0xb2f0
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq $-0x1, %rcx
callq 0xb310
movq %r15, %rdi
movq %rbp, %rsi
callq 0xb370
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x1061d4
movq 0x40(%rsp), %rsi
incq %rsi
callq 0xb2f0
jmp 0x1061d4
movq %rbp, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq $-0x1, %rcx
callq 0xb310
leaq 0x10(%rsp), %rdi
movq %rbp, %rsi
callq 0x106626
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x1062cc
movq 0x40(%rsp), %rsi
incq %rsi
callq 0xb2f0
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %rax
subq %rbx, %rax
je 0x10644e
movq (%rbx), %rcx
cmpb $0x23, (%rcx)
je 0x10644e
cmpq $0x40, %rax
jne 0x1064a8
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x10654c
addq $0x20, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0xb1c0
movq 0x10(%rsp), %rdi
leaq 0x4f643(%rip), %rsi     # 0x155960
callq 0xb100
movq 0x10(%rsp), %rdi
testl %eax, %eax
je 0x1063db
leaq 0x4f633(%rip), %rsi     # 0x155969
callq 0xb100
movq 0x10(%rsp), %rdi
testl %eax, %eax
je 0x1063ee
leaq 0x4f620(%rip), %rsi     # 0x15596f
callq 0xb100
movq 0x10(%rsp), %rdi
testl %eax, %eax
je 0x106401
leaq 0x4f611(%rip), %rsi     # 0x155979
callq 0xb100
movq 0x10(%rsp), %rdi
testl %eax, %eax
je 0x106414
leaq 0x4f601(%rip), %rsi     # 0x155982
callq 0xb100
movq 0x10(%rsp), %rdi
testl %eax, %eax
je 0x106427
leaq 0x4f5f1(%rip), %rsi     # 0x15598b
callq 0xb100
movq 0x10(%rsp), %rdi
testl %eax, %eax
je 0x10643a
leaq 0x4f5ed(%rip), %rsi     # 0x1559a0
callq 0xb100
testl %eax, %eax
jne 0x10644e
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0xb440
cltq
movq 0x8(%rsp), %rcx
movq %rax, 0x50(%rcx)
jmp 0x10644e
movq 0x20(%rdi), %rdi
callq 0xb440
movq 0x8(%rsp), %rcx
movl %eax, 0x30(%rcx)
jmp 0x10644e
movq 0x20(%rdi), %rdi
callq 0xb440
movq 0x8(%rsp), %rcx
movl %eax, 0x34(%rcx)
jmp 0x10644e
movq 0x20(%rdi), %rdi
callq 0xb440
movq 0x8(%rsp), %rcx
movl %eax, 0x38(%rcx)
jmp 0x10644e
movq 0x20(%rdi), %rdi
callq 0xb440
movq 0x8(%rsp), %rcx
movl %eax, 0x3c(%rcx)
jmp 0x10644e
movq 0x20(%rdi), %rdi
callq 0xb440
movq 0x8(%rsp), %rcx
movl %eax, 0x40(%rcx)
jmp 0x10644e
movq 0x20(%rdi), %rdi
callq 0xb440
cltq
movq 0x8(%rsp), %rcx
movq %rax, 0x48(%rcx)
leaq 0x10(%rsp), %rdi
callq 0x1065c8
movq 0x70(%rsp), %rax
movq -0x18(%rax), %rax
jmp 0x106187
leaq 0x70(%rsp), %rdi
callq 0xb0c0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x10648c
movq 0x60(%rsp), %rsi
incq %rsi
callq 0xb2f0
leaq 0x70(%rsp), %rdi
callq 0xb0d0
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4f477(%rip), %rdi     # 0x155926
leaq 0x4f433(%rip), %rsi     # 0x1558e9
leaq 0x4f43b(%rip), %rcx     # 0x1558f8
movl $0x2b, %edx
callq 0xb200
leaq 0x4f3fa(%rip), %rdi     # 0x1558c8
leaq 0x4f414(%rip), %rsi     # 0x1558e9
leaq 0x4f41c(%rip), %rcx     # 0x1558f8
movl $0xd, %edx
callq 0xb200
jmp 0x1064ee
jmp 0x106530
jmp 0x1064f5
jmp 0x1064f5
movq %rax, %rbx
jmp 0x106502
jmp 0x1064f5
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x1065c8
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x10651e
movq 0x60(%rsp), %rsi
incq %rsi
callq 0xb2f0
leaq 0x70(%rsp), %rdi
callq 0xb0d0
movq %rbx, %rdi
callq 0xb510
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x1064f8
movq 0x40(%rsp), %rsi
incq %rsi
callq 0xb2f0
jmp 0x1064f8