// File: ColinHarker[P]ltsim/src/utils.cpp
// Function: parseCommandLineOutput[abi:cxx11](char const*)
vector<string> parseCommandLineOutput(const char* cmd)
{
   vector<string> buffer_container;

   std::array<char, 512>                    buffer;
   string                                   result;
   std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
   if(!pipe)
   {
      throw std::runtime_error("popen() failed!");
   }
   while(fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr)
   {
      result = buffer.data();

      // skipping over unneccessary data in stream
      if((result.find("Filesystem") != string::npos) || (result.find("/dev/loop") != string::npos))
      {
         continue;
      }
      buffer_container.emplace_back(result);
   }

   return buffer_container;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movq %rdi, -0x278(%rbp)
movq %rdi, %rax
movq %rax, -0x270(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
callq 0xd400
leaq -0x238(%rbp), %rdi
callq 0x3430
movq -0x10(%rbp), %rdi
leaq 0x11c3(%rip), %rsi      # 0xe347
callq 0x30d0
movq %rax, -0x268(%rbp)
jmp 0xd192
movq -0x268(%rbp), %rsi
movq 0x7e30(%rip), %rax      # 0x14fd0
movq %rax, -0x260(%rbp)
leaq -0x248(%rbp), %rdi
leaq -0x260(%rbp), %rdx
callq 0x5c20
leaq -0x248(%rbp), %rdi
callq 0x5c60
testb $0x1, %al
jne 0xd263
movl $0x10, %edi
callq 0x3180
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x280(%rbp)
leaq 0xed5(%rip), %rsi       # 0xe0c1
callq 0x3100
jmp 0xd1f3
movq -0x280(%rbp), %rdi
movq 0x7def(%rip), %rsi      # 0x14ff0
movq 0x7db8(%rip), %rdx      # 0x14fc0
callq 0x3500
jmp 0xd3b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x250(%rbp)
movl %eax, -0x254(%rbp)
jmp 0xd36e
movq -0x280(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x250(%rbp)
movl %eax, -0x254(%rbp)
callq 0x3220
jmp 0xd362
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x250(%rbp)
movl %eax, -0x254(%rbp)
jmp 0xd362
jmp 0xd265
leaq -0x211(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0xd420
movq -0x2a0(%rbp), %rdi
movq %rax, -0x298(%rbp)
callq 0xd440
movl %eax, -0x28c(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x5cc0
movq -0x298(%rbp), %rdi
movl -0x28c(%rbp), %esi
movq %rax, %rdx
callq 0x34b0
movq %rax, -0x288(%rbp)
jmp 0xd2bb
movq -0x288(%rbp), %rax
cmpq $0x0, %rax
je 0xd33e
leaq -0x211(%rbp), %rdi
callq 0xd420
movq %rax, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0xd2e5
leaq -0x238(%rbp), %rdi
leaq 0x1056(%rip), %rsi      # 0xe349
xorl %eax, %eax
movl %eax, %edx
callq 0x3570
cmpq $-0x1, %rax
jne 0xd31f
leaq -0x238(%rbp), %rdi
leaq 0x1044(%rip), %rsi      # 0xe354
xorl %eax, %eax
movl %eax, %edx
callq 0x3570
cmpq $-0x1, %rax
je 0xd324
jmp 0xd265
movq -0x278(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0xd450
jmp 0xd339
jmp 0xd265
movb $0x1, -0x11(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x5cf0
leaq -0x238(%rbp), %rdi
callq 0x31d0
testb $0x1, -0x11(%rbp)
jne 0xd394
jmp 0xd388
leaq -0x248(%rbp), %rdi
callq 0x5cf0
leaq -0x238(%rbp), %rdi
callq 0x31d0
movq -0x278(%rbp), %rdi
callq 0x8bc0
jmp 0xd3a4
movq -0x278(%rbp), %rdi
callq 0x8bc0
movq -0x270(%rbp), %rax
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
movq -0x250(%rbp), %rdi
callq 0x3510