// File: ratulSharker[P]Havec/src/common.cpp
// Function: process_mem_usage(double&, double&)
void process_mem_usage(double& vm_usage, double& resident_set)
{
   using std::ios_base;
   using std::ifstream;
   using std::string;

   vm_usage     = 0.0;
   resident_set = 0.0;

   // 'file' stat seems to give the most reliable results
   //
   ifstream stat_stream("/proc/self/stat",ios_base::in);

   // dummy vars for leading entries in stat that we don't care about
   //
   string pid, comm, state, ppid, pgrp, session, tty_nr;
   string tpgid, flags, minflt, cminflt, majflt, cmajflt;
   string utime, stime, cutime, cstime, priority, nice;
   string O, itrealvalue, starttime;

   // the two fields we want
   //
   unsigned long vsize;
   long rss;

   stat_stream >> pid >> comm >> state >> ppid >> pgrp >> session >> tty_nr
               >> tpgid >> flags >> minflt >> cminflt >> majflt >> cmajflt
               >> utime >> stime >> cutime >> cstime >> priority >> nice
               >> O >> itrealvalue >> starttime >> vsize >> rss; // don't care about the rest

   stat_stream.close();

   long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; // in case x86-64 is configured to use 2MB pages
   vm_usage     = vsize / 1024.0;
   resident_set = rss * page_size_kb;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x5d0, %rsp            # imm = 0x5D0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
leaq 0x20a8(%rip), %rsi      # 0x11888
leaq -0x218(%rbp), %rdi
movq %rdi, -0x518(%rbp)
movl $0x8, %edx
callq 0x3580
leaq -0x238(%rbp), %rdi
movq %rdi, -0x510(%rbp)
callq 0x3460
leaq -0x258(%rbp), %rdi
callq 0x3460
leaq -0x278(%rbp), %rdi
callq 0x3460
leaq -0x298(%rbp), %rdi
callq 0x3460
leaq -0x2b8(%rbp), %rdi
callq 0x3460
leaq -0x2d8(%rbp), %rdi
callq 0x3460
leaq -0x2f8(%rbp), %rdi
callq 0x3460
leaq -0x318(%rbp), %rdi
callq 0x3460
leaq -0x338(%rbp), %rdi
callq 0x3460
leaq -0x358(%rbp), %rdi
callq 0x3460
leaq -0x378(%rbp), %rdi
callq 0x3460
leaq -0x398(%rbp), %rdi
callq 0x3460
leaq -0x3b8(%rbp), %rdi
callq 0x3460
leaq -0x3d8(%rbp), %rdi
callq 0x3460
leaq -0x3f8(%rbp), %rdi
callq 0x3460
leaq -0x418(%rbp), %rdi
callq 0x3460
leaq -0x438(%rbp), %rdi
callq 0x3460
leaq -0x458(%rbp), %rdi
callq 0x3460
leaq -0x478(%rbp), %rdi
callq 0x3460
leaq -0x498(%rbp), %rdi
callq 0x3460
leaq -0x4b8(%rbp), %rdi
callq 0x3460
leaq -0x4d8(%rbp), %rdi
callq 0x3460
movq -0x518(%rbp), %rdi
movq -0x510(%rbp), %rsi
callq 0x3420
movq %rax, -0x508(%rbp)
jmp 0xf923
movq -0x508(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x3420
movq %rax, -0x520(%rbp)
jmp 0xf93f
movq -0x520(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x3420
movq %rax, -0x528(%rbp)
jmp 0xf95b
movq -0x528(%rbp), %rdi
leaq -0x298(%rbp), %rsi
callq 0x3420
movq %rax, -0x530(%rbp)
jmp 0xf977
movq -0x530(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
callq 0x3420
movq %rax, -0x538(%rbp)
jmp 0xf993
movq -0x538(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
callq 0x3420
movq %rax, -0x540(%rbp)
jmp 0xf9af
movq -0x540(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
callq 0x3420
movq %rax, -0x548(%rbp)
jmp 0xf9cb
movq -0x548(%rbp), %rdi
leaq -0x318(%rbp), %rsi
callq 0x3420
movq %rax, -0x550(%rbp)
jmp 0xf9e7
movq -0x550(%rbp), %rdi
leaq -0x338(%rbp), %rsi
callq 0x3420
movq %rax, -0x558(%rbp)
jmp 0xfa03
movq -0x558(%rbp), %rdi
leaq -0x358(%rbp), %rsi
callq 0x3420
movq %rax, -0x560(%rbp)
jmp 0xfa1f
movq -0x560(%rbp), %rdi
leaq -0x378(%rbp), %rsi
callq 0x3420
movq %rax, -0x568(%rbp)
jmp 0xfa3b
movq -0x568(%rbp), %rdi
leaq -0x398(%rbp), %rsi
callq 0x3420
movq %rax, -0x570(%rbp)
jmp 0xfa57
movq -0x570(%rbp), %rdi
leaq -0x3b8(%rbp), %rsi
callq 0x3420
movq %rax, -0x578(%rbp)
jmp 0xfa73
movq -0x578(%rbp), %rdi
leaq -0x3d8(%rbp), %rsi
callq 0x3420
movq %rax, -0x580(%rbp)
jmp 0xfa8f
movq -0x580(%rbp), %rdi
leaq -0x3f8(%rbp), %rsi
callq 0x3420
movq %rax, -0x588(%rbp)
jmp 0xfaab
movq -0x588(%rbp), %rdi
leaq -0x418(%rbp), %rsi
callq 0x3420
movq %rax, -0x590(%rbp)
jmp 0xfac7
movq -0x590(%rbp), %rdi
leaq -0x438(%rbp), %rsi
callq 0x3420
movq %rax, -0x598(%rbp)
jmp 0xfae3
movq -0x598(%rbp), %rdi
leaq -0x458(%rbp), %rsi
callq 0x3420
movq %rax, -0x5a0(%rbp)
jmp 0xfaff
movq -0x5a0(%rbp), %rdi
leaq -0x478(%rbp), %rsi
callq 0x3420
movq %rax, -0x5a8(%rbp)
jmp 0xfb1b
movq -0x5a8(%rbp), %rdi
leaq -0x498(%rbp), %rsi
callq 0x3420
movq %rax, -0x5b0(%rbp)
jmp 0xfb37
movq -0x5b0(%rbp), %rdi
leaq -0x4b8(%rbp), %rsi
callq 0x3420
movq %rax, -0x5b8(%rbp)
jmp 0xfb53
movq -0x5b8(%rbp), %rdi
leaq -0x4d8(%rbp), %rsi
callq 0x3420
movq %rax, -0x5c0(%rbp)
jmp 0xfb6f
movq -0x5c0(%rbp), %rdi
leaq -0x4e0(%rbp), %rsi
callq 0x3480
movq %rax, -0x5c8(%rbp)
jmp 0xfb8b
movq -0x5c8(%rbp), %rdi
leaq -0x4e8(%rbp), %rsi
callq 0x3190
jmp 0xfba0
leaq -0x218(%rbp), %rdi
callq 0x30a0
jmp 0xfbae
movl $0x1e, %edi
callq 0x31d0
movq %rax, %rcx
addq $0x3ff, %rcx            # imm = 0x3FF
testq %rax, %rax
cmovsq %rcx, %rax
sarq $0xa, %rax
movq %rax, -0x500(%rbp)
movaps 0x1585(%rip), %xmm1     # 0x11160
movq -0x4e0(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x1581(%rip), %xmm1     # 0x11170
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x1bd2(%rip), %xmm1     # 0x117d8
divsd %xmm1, %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x4e8(%rbp), %rax
imulq -0x500(%rbp), %rax
cvtsi2sd %rax, %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
leaq -0x4d8(%rbp), %rdi
callq 0x31b0
leaq -0x4b8(%rbp), %rdi
callq 0x31b0
leaq -0x498(%rbp), %rdi
callq 0x31b0
leaq -0x478(%rbp), %rdi
callq 0x31b0
leaq -0x458(%rbp), %rdi
callq 0x31b0
leaq -0x438(%rbp), %rdi
callq 0x31b0
leaq -0x418(%rbp), %rdi
callq 0x31b0
leaq -0x3f8(%rbp), %rdi
callq 0x31b0
leaq -0x3d8(%rbp), %rdi
callq 0x31b0
leaq -0x3b8(%rbp), %rdi
callq 0x31b0
leaq -0x398(%rbp), %rdi
callq 0x31b0
leaq -0x378(%rbp), %rdi
callq 0x31b0
leaq -0x358(%rbp), %rdi
callq 0x31b0
leaq -0x338(%rbp), %rdi
callq 0x31b0
leaq -0x318(%rbp), %rdi
callq 0x31b0
leaq -0x2f8(%rbp), %rdi
callq 0x31b0
leaq -0x2d8(%rbp), %rdi
callq 0x31b0
leaq -0x2b8(%rbp), %rdi
callq 0x31b0
leaq -0x298(%rbp), %rdi
callq 0x31b0
leaq -0x278(%rbp), %rdi
callq 0x31b0
leaq -0x258(%rbp), %rdi
callq 0x31b0
leaq -0x238(%rbp), %rdi
callq 0x31b0
leaq -0x218(%rbp), %rdi
callq 0x30c0
addq $0x5d0, %rsp            # imm = 0x5D0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4f0(%rbp)
movl %eax, -0x4f4(%rbp)
leaq -0x4d8(%rbp), %rdi
callq 0x31b0
leaq -0x4b8(%rbp), %rdi
callq 0x31b0
leaq -0x498(%rbp), %rdi
callq 0x31b0
leaq -0x478(%rbp), %rdi
callq 0x31b0
leaq -0x458(%rbp), %rdi
callq 0x31b0
leaq -0x438(%rbp), %rdi
callq 0x31b0
leaq -0x418(%rbp), %rdi
callq 0x31b0
leaq -0x3f8(%rbp), %rdi
callq 0x31b0
leaq -0x3d8(%rbp), %rdi
callq 0x31b0
leaq -0x3b8(%rbp), %rdi
callq 0x31b0
leaq -0x398(%rbp), %rdi
callq 0x31b0
leaq -0x378(%rbp), %rdi
callq 0x31b0
leaq -0x358(%rbp), %rdi
callq 0x31b0
leaq -0x338(%rbp), %rdi
callq 0x31b0
leaq -0x318(%rbp), %rdi
callq 0x31b0
leaq -0x2f8(%rbp), %rdi
callq 0x31b0
leaq -0x2d8(%rbp), %rdi
callq 0x31b0
leaq -0x2b8(%rbp), %rdi
callq 0x31b0
leaq -0x298(%rbp), %rdi
callq 0x31b0
leaq -0x278(%rbp), %rdi
callq 0x31b0
leaq -0x258(%rbp), %rdi
callq 0x31b0
leaq -0x238(%rbp), %rdi
callq 0x31b0
leaq -0x218(%rbp), %rdi
callq 0x30c0
movq -0x4f0(%rbp), %rdi
callq 0x3540
nopl (%rax)