// File: /workspace/github_c_makefile_star2_O0/mvermeulen[P]wspy/proctree.c
// Function: parse_stat
void parse_stat(char *stat,struct process_info *pinfo){
  debug2("parse_stat: %s\n",stat);
  char *p;
  int i;
  int index = 0;
  char *stat_fields[NUM_STAT_FIELDS] = { 0 };
  char *stat_line = strdup(stat);
  p = strtok(stat_line," \n");
  while (p && index < NUM_STAT_FIELDS){
    stat_fields[index] = p;
    p = strtok(NULL," \n");
    index++;
  }
  for (i=0;i<index;i++){
    debug2("\t%d: %s\n",i,stat_fields[i]);
  }
  if (stat_fields[13]) pinfo->utime = atoi(stat_fields[13]); // utime user time in clock ticks
  if (stat_fields[14]) pinfo->stime = atoi(stat_fields[14]); // stime system time in clock ticks
  if (stat_fields[21]) pinfo->starttime = atoll(stat_fields[21]); // starttime since boot in clock ticks
  if (stat_fields[22]) pinfo->vsize = atoi(stat_fields[22]); // vsize - virtual memory in bytes
  if (stat_fields[38]) pinfo->processor = atoi(stat_fields[38]); // last processor
  if (stat_fields[51]) pinfo->exit_code = atoi(stat_fields[51]); // exit code
  free(stat_line);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1d0, %rsp            # imm = 0x1D0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rsi
leaq 0x1acf(%rip), %rdi      # 0x30fd
movb $0x0, %al
callq 0x2a80
movl $0x0, -0x20(%rbp)
leaq -0x1c0(%rbp), %rdi
xorl %esi, %esi
movl $0x1a0, %edx            # imm = 0x1A0
callq 0x1090
movq -0x8(%rbp), %rdi
callq 0x1180
movq %rax, -0x1c8(%rbp)
movq -0x1c8(%rbp), %rdi
leaq 0x1aa0(%rip), %rsi      # 0x310d
callq 0x1120
movq %rax, -0x18(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x18(%rbp)
movb %al, -0x1c9(%rbp)
je 0x1692
cmpl $0x34, -0x20(%rbp)
setl %al
movb %al, -0x1c9(%rbp)
movb -0x1c9(%rbp), %al
testb $0x1, %al
jne 0x169e
jmp 0x16cd
movq -0x18(%rbp), %rcx
movslq -0x20(%rbp), %rax
movq %rcx, -0x1c0(%rbp,%rax,8)
xorl %eax, %eax
movl %eax, %edi
leaq 0x1a54(%rip), %rsi      # 0x310d
callq 0x1120
movq %rax, -0x18(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1676
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x1704
movl -0x1c(%rbp), %esi
movslq -0x1c(%rbp), %rax
movq -0x1c0(%rbp,%rax,8), %rdx
leaq 0x1a1e(%rip), %rdi      # 0x3110
movb $0x0, %al
callq 0x2a80
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x16d4
cmpq $0x0, -0x158(%rbp)
je 0x1723
movq -0x158(%rbp), %rdi
callq 0x1160
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x28(%rax)
cmpq $0x0, -0x150(%rbp)
je 0x1742
movq -0x150(%rbp), %rdi
callq 0x1160
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x2c(%rax)
cmpq $0x0, -0x118(%rbp)
je 0x1763
movq -0x118(%rbp), %rdi
callq 0x10c0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x30(%rax)
cmpq $0x0, -0x110(%rbp)
je 0x1782
movq -0x110(%rbp), %rdi
callq 0x1160
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x38(%rax)
cmpq $0x0, -0x90(%rbp)
je 0x17a1
movq -0x90(%rbp), %rdi
callq 0x1160
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x3c(%rax)
cmpq $0x0, -0x28(%rbp)
je 0x17ba
movq -0x28(%rbp), %rdi
callq 0x1160
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x40(%rax)
movq -0x1c8(%rbp), %rdi
callq 0x1030
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
nop