// File: /workspace/github_cpp_makefile_star2_O2/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
pushq $0x8
popq %rdx
movq %rbx, %rdi
callq 0xb450
movq (%rbx), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x90(%rsp,%rax)
jne 0x9c900
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x30(%rsp), %r15
leaq 0x2c(%rsp), %r12
leaq 0x10(%rsp), %r13
leaq 0x50(%rsp), %rbp
leaq 0x70(%rsp), %rdi
movq %r15, %rsi
callq 0xb0b0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x9c8b3
movl $0x3d0920, 0x2c(%rsp)   # imm = 0x3D0920
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0xb1e0
cmpq $-0x1, %rax
je 0x9c737
movq %rax, %r14
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0xb1a0
cmpq $-0x1, %rax
je 0x9c713
movq %rax, %rbx
movq %rax, %rcx
subq %r14, %rcx
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xb2f0
movq %r13, %rdi
movq %rbp, %rsi
callq 0x9ca42
movq %rbp, %rdi
callq 0xb568
movq %rbp, %rdi
movq %r15, %rsi
movq %rbx, %rdx
pushq $-0x1
popq %rcx
callq 0xb2f0
movq %r15, %rdi
movq %rbp, %rsi
callq 0xb340
movq %rbp, %rdi
callq 0xb568
jmp 0x9c695
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
pushq $-0x1
popq %rcx
callq 0xb2f0
movq %r13, %rdi
movq %rbp, %rsi
callq 0x9ca42
movq %rbp, %rdi
callq 0xb568
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %rax
subq %rbx, %rax
je 0x9c8a6
movq (%rbx), %rcx
cmpb $0x23, (%rcx)
je 0x9c8a6
cmpq $0x40, %rax
jne 0x9c8e3
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x9c960
addq $0x20, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0xb1c0
movq 0x10(%rsp), %rdi
leaq 0x40178(%rip), %rsi     # 0xdc900
callq 0x110e2
movq 0x10(%rsp), %rdi
testb %al, %al
je 0x9c7ac
movq 0x20(%rdi), %rdi
callq 0xb410
movq 0x8(%rsp), %rcx
movl %eax, 0x30(%rcx)
jmp 0x9c8a6
leaq 0x40156(%rip), %rsi     # 0xdc909
callq 0x110e2
movq 0x10(%rsp), %rdi
testb %al, %al
je 0x9c7d7
movq 0x20(%rdi), %rdi
callq 0xb410
movq 0x8(%rsp), %rcx
movl %eax, 0x34(%rcx)
jmp 0x9c8a6
leaq 0x40131(%rip), %rsi     # 0xdc90f
callq 0x110e2
movq 0x10(%rsp), %rdi
testb %al, %al
je 0x9c802
movq 0x20(%rdi), %rdi
callq 0xb410
movq 0x8(%rsp), %rcx
movl %eax, 0x38(%rcx)
jmp 0x9c8a6
leaq 0x40110(%rip), %rsi     # 0xdc919
callq 0x110e2
movq 0x10(%rsp), %rdi
testb %al, %al
je 0x9c82a
movq 0x20(%rdi), %rdi
callq 0xb410
movq 0x8(%rsp), %rcx
movl %eax, 0x3c(%rcx)
jmp 0x9c8a6
leaq 0x400f1(%rip), %rsi     # 0xdc922
callq 0x110e2
movq 0x10(%rsp), %rdi
testb %al, %al
je 0x9c852
movq 0x20(%rdi), %rdi
callq 0xb410
movq 0x8(%rsp), %rcx
movl %eax, 0x40(%rcx)
jmp 0x9c8a6
leaq 0x400d2(%rip), %rsi     # 0xdc92b
callq 0x110e2
movq 0x10(%rsp), %rdi
testb %al, %al
je 0x9c87d
movq 0x20(%rdi), %rdi
callq 0xb410
cltq
movq 0x8(%rsp), %rcx
movq %rax, 0x48(%rcx)
jmp 0x9c8a6
leaq 0x400bc(%rip), %rsi     # 0xdc940
callq 0x110e2
testb %al, %al
je 0x9c8a6
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0xb410
cltq
movq 0x8(%rsp), %rcx
movq %rax, 0x50(%rcx)
movq %r13, %rdi
callq 0x9c9c6
jmp 0x9c660
leaq 0x70(%rsp), %rdi
callq 0xb0c0
leaq 0x30(%rsp), %rdi
callq 0xb568
leaq 0x70(%rsp), %rdi
callq 0xb0e0
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3ffdc(%rip), %rdi     # 0xdc8c6
leaq 0x3ff98(%rip), %rsi     # 0xdc889
leaq 0x3ffa0(%rip), %rcx     # 0xdc898
pushq $0x2b
popq %rdx
callq 0xb210
leaq 0x3ff61(%rip), %rdi     # 0xdc868
leaq 0x3ff7b(%rip), %rsi     # 0xdc889
leaq 0x3ff83(%rip), %rcx     # 0xdc898
pushq $0xd
jmp 0x9c8fa
jmp 0x9c921
jmp 0x9c926
jmp 0x9c937
jmp 0x9c937
movq %rax, %rbx
jmp 0x9c944
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0xb568
jmp 0x9c93a
jmp 0x9c937
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x9c9c6
leaq 0x30(%rsp), %rdi
callq 0xb568
leaq 0x70(%rsp), %rdi
callq 0xb0e0
movq %rbx, %rdi
callq 0xb4d0