// File: /workspace/github_c_makefile_star2_O0/silverneko[P]miku/isolate/isolate.c
// Function: get_run_time_ms
static int
get_run_time_ms(struct rusage *rus)
{
  if (cg_timing)
    return cg_get_run_time_ms();

  if (rus)
    {
      struct timeval total;
      timeradd(&rus->ru_utime, &rus->ru_stime, &total);
      return total.tv_sec*1000 + total.tv_usec/1000;
    }

  char buf[PROC_BUF_SIZE], *x;
  int utime, stime;
  static int proc_stat_fd;

  read_proc_file(buf, "stat", &proc_stat_fd);
  x = buf;
  while (*x && *x != ' ')
    x++;
  while (*x == ' ')
    x++;
  if (*x++ != '(')
    die("proc stat syntax error 1");
  while (*x && (*x != ')' || x[1] != ' '))
    x++;
  while (*x == ')' || *x == ' ')
    x++;
  if (sscanf(x, "%*c %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %d %d", &utime, &stime) != 2)
    die("proc stat syntax error 2");

  return (utime + stime) * 1000 / ticks_per_sec;
}

// Assembly:
subq $0x1048, %rsp           # imm = 0x1048
movq %rdi, 0x1038(%rsp)
cmpl $0x0, 0x69c6(%rip)      # 0xa30c
je 0x3959
callq 0x3d00
movl %eax, 0x1044(%rsp)
jmp 0x3bae
cmpq $0x0, 0x1038(%rsp)
je 0x3a1d
jmp 0x396a
movq 0x1038(%rsp), %rax
movq (%rax), %rax
movq 0x1038(%rsp), %rcx
addq 0x10(%rcx), %rax
movq %rax, 0x1028(%rsp)
movq 0x1038(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x1038(%rsp), %rcx
addq 0x18(%rcx), %rax
movq %rax, 0x1030(%rsp)
cmpq $0xf4240, 0x1030(%rsp) # imm = 0xF4240
jl 0x39e1
movq 0x1028(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1028(%rsp)
movq 0x1030(%rsp), %rax
subq $0xf4240, %rax          # imm = 0xF4240
movq %rax, 0x1030(%rsp)
jmp 0x39e3
imulq $0x3e8, 0x1028(%rsp), %rax # imm = 0x3E8
movq %rax, 0x8(%rsp)
movq 0x1030(%rsp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
movq %rax, %rcx
movq 0x8(%rsp), %rax
addq %rcx, %rax
movl %eax, 0x1044(%rsp)
jmp 0x3bae
leaq 0x20(%rsp), %rdi
leaq 0x3604(%rip), %rsi      # 0x702d
leaq 0x6920(%rip), %rdx      # 0xa350
callq 0x3d70
leaq 0x20(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0x7(%rsp)
je 0x3a64
movq 0x18(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x20, %eax
setne %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x3a6e
jmp 0x3a7e
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
jmp 0x3a3f
jmp 0x3a80
movq 0x18(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x20, %eax
jne 0x3a9d
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
jmp 0x3a80
movq 0x18(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x18(%rsp)
movsbl (%rax), %eax
cmpl $0x28, %eax
je 0x3ac4
leaq 0x3575(%rip), %rdi      # 0x7032
movb $0x0, %al
callq 0x2ed0
jmp 0x3ac6
movq 0x18(%rsp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0x6(%rsp)
je 0x3b07
movq 0x18(%rsp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x29, %ecx
movb %al, 0x5(%rsp)
jne 0x3aff
movq 0x18(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x20, %eax
setne %al
movb %al, 0x5(%rsp)
movb 0x5(%rsp), %al
movb %al, 0x6(%rsp)
movb 0x6(%rsp), %al
testb $0x1, %al
jne 0x3b11
jmp 0x3b21
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
jmp 0x3ac6
jmp 0x3b23
movq 0x18(%rsp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x29, %ecx
movb %al, 0x4(%rsp)
je 0x3b48
movq 0x18(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x20, %eax
sete %al
movb %al, 0x4(%rsp)
movb 0x4(%rsp), %al
testb $0x1, %al
jne 0x3b52
jmp 0x3b62
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
jmp 0x3b23
movq 0x18(%rsp), %rdi
leaq 0x34dd(%rip), %rsi      # 0x704b
leaq 0x14(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movb $0x0, %al
callq 0x23a0
cmpl $0x2, %eax
je 0x3b92
leaq 0x34f2(%rip), %rdi      # 0x707d
movb $0x0, %al
callq 0x2ed0
movl 0x14(%rsp), %eax
addl 0x10(%rsp), %eax
imull $0x3e8, %eax, %eax      # imm = 0x3E8
cltd
idivl 0x67ad(%rip)            # 0xa354
movl %eax, 0x1044(%rsp)
movl 0x1044(%rsp), %eax
addq $0x1048, %rsp           # imm = 0x1048
retq
nopl (%rax)