// File: /workspace/github_cpp_makefile_star2_O1/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 0x108fb5
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x40(%rsp), %r13
leaq 0x50(%rsp), %r15
leaq 0x2c(%rsp), %r12
leaq 0x30(%rsp), %rbp
movq 0x70(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0xb2c0
movsbl %al, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xb540
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x108f54
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, %r14
cmpq $-0x1, %rax
je 0x108dbe
movq %r12, %rdi
callq 0xb180
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %rax, %rcx
callq 0xb400
cmpq $-0x1, %rax
je 0x108d85
movq %rax, %rbx
movq %rax, %rcx
subq %r14, %rcx
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xb310
leaq 0x10(%rsp), %rdi
movq %rbp, %rsi
callq 0x109112
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x108d45
movq 0x40(%rsp), %rsi
incq %rsi
callq 0xb2f0
movq %rbp, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq $-0x1, %rcx
callq 0xb310
movq %r15, %rdi
movq %rbp, %rsi
callq 0xb370
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x108cc6
movq 0x40(%rsp), %rsi
incq %rsi
callq 0xb2f0
jmp 0x108cc6
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq $-0x1, %rcx
callq 0xb310
leaq 0x10(%rsp), %rdi
movq %rbp, %rsi
callq 0x109112
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x108dbe
movq 0x40(%rsp), %rsi
incq %rsi
callq 0xb2f0
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %rax
subq %rbx, %rax
je 0x108f40
movq (%rbx), %rcx
cmpb $0x23, (%rcx)
je 0x108f40
cmpq $0x40, %rax
jne 0x108f96
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x10903a
addq $0x20, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0xb1c0
movq 0x10(%rsp), %rdi
leaq 0x4fb11(%rip), %rsi     # 0x158920
callq 0xb100
movq 0x10(%rsp), %rdi
testl %eax, %eax
je 0x108ecd
leaq 0x4fb01(%rip), %rsi     # 0x158929
callq 0xb100
movq 0x10(%rsp), %rdi
testl %eax, %eax
je 0x108ee0
leaq 0x4faee(%rip), %rsi     # 0x15892f
callq 0xb100
movq 0x10(%rsp), %rdi
testl %eax, %eax
je 0x108ef3
leaq 0x4fadf(%rip), %rsi     # 0x158939
callq 0xb100
movq 0x10(%rsp), %rdi
testl %eax, %eax
je 0x108f06
leaq 0x4facf(%rip), %rsi     # 0x158942
callq 0xb100
movq 0x10(%rsp), %rdi
testl %eax, %eax
je 0x108f19
leaq 0x4fabf(%rip), %rsi     # 0x15894b
callq 0xb100
movq 0x10(%rsp), %rdi
testl %eax, %eax
je 0x108f2c
leaq 0x4fabb(%rip), %rsi     # 0x158960
callq 0xb100
testl %eax, %eax
jne 0x108f40
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0xb440
cltq
movq 0x8(%rsp), %rcx
movq %rax, 0x50(%rcx)
jmp 0x108f40
movq 0x20(%rdi), %rdi
callq 0xb440
movq 0x8(%rsp), %rcx
movl %eax, 0x30(%rcx)
jmp 0x108f40
movq 0x20(%rdi), %rdi
callq 0xb440
movq 0x8(%rsp), %rcx
movl %eax, 0x34(%rcx)
jmp 0x108f40
movq 0x20(%rdi), %rdi
callq 0xb440
movq 0x8(%rsp), %rcx
movl %eax, 0x38(%rcx)
jmp 0x108f40
movq 0x20(%rdi), %rdi
callq 0xb440
movq 0x8(%rsp), %rcx
movl %eax, 0x3c(%rcx)
jmp 0x108f40
movq 0x20(%rdi), %rdi
callq 0xb440
movq 0x8(%rsp), %rcx
movl %eax, 0x40(%rcx)
jmp 0x108f40
movq 0x20(%rdi), %rdi
callq 0xb440
cltq
movq 0x8(%rsp), %rcx
movq %rax, 0x48(%rcx)
leaq 0x10(%rsp), %rdi
callq 0x1090b6
leaq 0x70(%rsp), %rbx
jmp 0x108c77
leaq 0x70(%rsp), %rdi
callq 0xb0c0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x108f7a
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 0x4f949(%rip), %rdi     # 0x1588e6
leaq 0x4f905(%rip), %rsi     # 0x1588a9
leaq 0x4f90d(%rip), %rcx     # 0x1588b8
movl $0x2b, %edx
callq 0xb200
leaq 0x4f8cc(%rip), %rdi     # 0x158888
leaq 0x4f8e6(%rip), %rsi     # 0x1588a9
leaq 0x4f8ee(%rip), %rcx     # 0x1588b8
movl $0xd, %edx
callq 0xb200
jmp 0x108fdc
jmp 0x10901e
jmp 0x108fe3
jmp 0x108fe3
movq %rax, %rbx
jmp 0x108ff0
jmp 0x108fe3
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x1090b6
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x10900c
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 0x108fe6
movq 0x40(%rsp), %rsi
incq %rsi
callq 0xb2f0
jmp 0x108fe6