// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/unix.cpp
// Function: ps(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int)
const char * ps(const string & args, pid_t pid) {
  LOG(DEBUG) << "looking at ps output for ps " << args << " " << pid;
  stringstream ss;
  ss << "/bin/ps " << args << " " << pid;
  FILE * p = popen(ss.str().c_str(), "r");
  if (p) {
    char buffer[256];
    char * rval = fgets(buffer, 256, p);
    pclose(p);
    if (!rval) return "null";
    for (size_t i = strlen(rval) - 1; i > 0; --i)
      if (rval[i] == '\n') {
        rval[i] = '\0';
        break;
      }
    return rval;
  }
  return "null";
}

// Assembly:
subq $0x668, %rsp            # imm = 0x668
movq %rdi, 0x658(%rsp)
movl %esi, 0x654(%rsp)
leaq 0x338(%rsp), %rdi
movq %rdi, 0x48(%rsp)
xorl %esi, %esi
callq 0xa1800
movq 0x48(%rsp), %rdi
leaq 0xcc5a(%rip), %rsi      # 0xb42f0
callq 0x945b0
movq %rax, 0x50(%rsp)
jmp 0xa76a2
movq 0x50(%rsp), %rdi
movq 0x658(%rsp), %rsi
callq 0x8350
movq %rax, 0x40(%rsp)
jmp 0xa76bb
movq 0x40(%rsp), %rdi
leaq 0x8787(%rip), %rsi      # 0xafe4e
callq 0x8400
movq %rax, 0x38(%rsp)
jmp 0xa76d3
movq 0x38(%rsp), %rdi
movl 0x654(%rsp), %esi
callq 0x8780
jmp 0xa76e6
leaq 0x338(%rsp), %rdi
callq 0xa1f50
leaq 0x1a0(%rsp), %rdi
callq 0x82a0
leaq 0x1b0(%rsp), %rdi
leaq 0xcbfe(%rip), %rsi      # 0xb430d
callq 0x8400
movq %rax, 0x30(%rsp)
jmp 0xa771b
movq 0x30(%rsp), %rdi
movq 0x658(%rsp), %rsi
callq 0x8350
movq %rax, 0x28(%rsp)
jmp 0xa7734
movq 0x28(%rsp), %rdi
leaq 0x870e(%rip), %rsi      # 0xafe4e
callq 0x8400
movq %rax, 0x20(%rsp)
jmp 0xa774c
movq 0x20(%rsp), %rdi
movl 0x654(%rsp), %esi
callq 0x8780
jmp 0xa775f
leaq 0x178(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x83e0
jmp 0xa7776
leaq 0x178(%rsp), %rdi
callq 0x8190
movq %rax, 0x18(%rsp)
jmp 0xa778a
movq 0x18(%rsp), %rdi
leaq 0x6e97(%rip), %rsi      # 0xae62d
callq 0x8120
movq %rax, 0x10(%rsp)
jmp 0xa77a2
leaq 0x178(%rsp), %rdi
callq 0x88f8
jmp 0xa77b1
movq 0x10(%rsp), %rax
movq %rax, 0x198(%rsp)
cmpq $0x0, 0x198(%rsp)
je 0xa78fc
movq 0x198(%rsp), %rdx
leaq 0x70(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x86c0
movq %rax, 0x8(%rsp)
jmp 0xa77eb
movq 0x8(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x198(%rsp), %rdi
callq 0x85f0
jmp 0xa7804
cmpq $0x0, 0x68(%rsp)
jne 0xa7895
leaq 0xb521(%rip), %rax      # 0xb2d38
movq %rax, 0x660(%rsp)
movl $0x1, 0x64(%rsp)
jmp 0xa7913
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
leaq 0x338(%rsp), %rdi
callq 0xa1f50
jmp 0xa784f
jmp 0xa7941
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
jmp 0xa7930
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
leaq 0x178(%rsp), %rdi
callq 0x88f8
jmp 0xa7890
jmp 0xa7930
movq 0x68(%rsp), %rdi
callq 0x81b0
subq $0x1, %rax
movq %rax, 0x58(%rsp)
cmpq $0x0, 0x58(%rsp)
jbe 0xa78e5
movq 0x68(%rsp), %rax
movq 0x58(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0xa78d3
movq 0x68(%rsp), %rax
movq 0x58(%rsp), %rcx
movb $0x0, (%rax,%rcx)
jmp 0xa78e5
jmp 0xa78d5
movq 0x58(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x58(%rsp)
jmp 0xa78a8
movq 0x68(%rsp), %rax
movq %rax, 0x660(%rsp)
movl $0x1, 0x64(%rsp)
jmp 0xa7913
leaq 0xb435(%rip), %rax      # 0xb2d38
movq %rax, 0x660(%rsp)
movl $0x1, 0x64(%rsp)
leaq 0x1a0(%rsp), %rdi
callq 0x8900
movq 0x660(%rsp), %rax
addq $0x668, %rsp            # imm = 0x668
retq
leaq 0x1a0(%rsp), %rdi
callq 0x8900
jmp 0xa793f
jmp 0xa7941
movq 0x330(%rsp), %rdi
callq 0x87d0
movq %rax, %rdi
callq 0x8cf60
nopw %cs:(%rax,%rax)