// File: /workspace/github_cpp_makefile_star2_O2/ColinHarker[P]ltsim/src/memory.cpp
// Function: RandomAccessMemory::parseMemInfo(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, flag::memType)
void RandomAccessMemory::parseMemInfo(const std::string& memInfoType,
                                      flag::memType      classVariable)
{
   std::string   token;
   std::ifstream file("/proc/meminfo");
   while(file >> token)
   {
      if(token == memInfoType + ":")
      {
         std::string mem;
         if(file >> mem)
         {
            if(classVariable == flag::memType::memTotal)
            {
               m_memTotal = std::stoul(mem);
            }
            else if(classVariable == flag::memType::memAvailable)
            {
               m_memAvailable = std::stoul(mem);
            }
            else if(classVariable == flag::memType::swapTotal)
            {
               m_swapTotal = std::stoul(mem);
            }
            else
            {
               m_swapFree = std::stoul(mem);
            }
         }
      }
      // ignore rest of the line
      file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
   }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, 0x8(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x2a39(%rip), %rsi      # 0x7170
leaq 0x50(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x33e0
leaq 0x50(%rsp), %r12
leaq 0x30(%rsp), %r13
leaq 0x10(%rsp), %r15
movq %r12, %rdi
movq %r13, %rsi
callq 0x32c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x485b
movq %r15, %rdi
movq %r14, %rsi
leaq 0x2a01(%rip), %rdx      # 0x717e
callq 0x497f
movq %r13, %rdi
movq %r15, %rsi
callq 0x4956
movl %eax, %ebx
movq %r15, %rdi
callq 0x3110
testb %bl, %bl
je 0x47d1
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
andq $0x0, 0x18(%rsp)
movb $0x0, 0x20(%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x32c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x47eb
movq %r15, %rdi
callq 0x3110
movq %r12, %rdi
movabsq $0x7fffffffffffffff, %rsi # imm = 0x7FFFFFFFFFFFFFFF
pushq $0xa
popq %rdx
callq 0x31a0
jmp 0x4753
cmpl $0x2, %ebp
je 0x4828
cmpl $0x1, %ebp
je 0x4810
testl %ebp, %ebp
jne 0x4840
movq %r15, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x49b7
movq 0x8(%rsp), %rcx
movq %rax, (%rcx)
jmp 0x47c9
movq %r15, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x49b7
movq 0x8(%rsp), %rcx
movq %rax, 0x8(%rcx)
jmp 0x47c9
movq %r15, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x49b7
movq 0x8(%rsp), %rcx
movq %rax, 0x10(%rcx)
jmp 0x47c9
movq %r15, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x49b7
movq 0x8(%rsp), %rcx
movq %rax, 0x18(%rcx)
jmp 0x47c9
leaq 0x50(%rsp), %rdi
callq 0x3090
leaq 0x30(%rsp), %rdi
callq 0x3110
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x48a4
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x3110
jmp 0x489a
jmp 0x4897
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x3090
leaq 0x30(%rsp), %rdi
callq 0x3110
movq %rbx, %rdi
callq 0x33c0