// File: /workspace/github_c_makefile_star2_O0/mvermeulen[P]wspy/system.c
// Function: print_system
void print_system(enum output_format oformat){
  double elapsed;
  int i;
  if (interval) elapsed = interval;
  else {
    clock_gettime(CLOCK_REALTIME,&finish_time);
    elapsed = finish_time.tv_sec + finish_time.tv_nsec / 1000000000.0 -
      start_time.tv_sec - start_time.tv_nsec / 1000000000.0;    
  }

  switch(oformat){
  case PRINT_CSV_HEADER:
    if (system_mask & SYSTEM_LOADAVG) fprintf(outfile,"load,runnable,");
    if (system_mask & SYSTEM_CPU) fprintf(outfile,"cpu,idle,iowait,irq,");
#if AMDGPU
    if (system_mask & SYSTEM_GPU)
      fprintf(outfile,"gpu temp,gpu gfx,gpu umc,gpu_mm,");
#endif
    if (system_mask & SYSTEM_NETWORK){
      if (system_state.netinfo == NULL) setup_net_info();
      for (i=0;i<system_state.num_net;i++) fprintf(outfile,"net %s,",system_state.netinfo[i].name);
    }
    break;
  case PRINT_CSV:
    if (system_mask & SYSTEM_LOADAVG) fprintf(outfile,"%4.2f,%d,",system_state.load,system_state.runnable);
    if (system_mask & SYSTEM_CPU){
      fprintf(outfile,"%3.2f%%,",
	      (double) (system_state.cpu.usertime+system_state.cpu.systemtime)/elapsed/num_procs);
      fprintf(outfile,"%3.2f%%,",
	      (double) (system_state.cpu.idletime)/elapsed/num_procs);
      fprintf(outfile,"%3.2f%%,",
	      (double) (system_state.cpu.iowaittime)/elapsed/num_procs);      
      fprintf(outfile,"%3.2f%%,",
	      (double) (system_state.cpu.irqtime)/elapsed/num_procs);
    }
#if AMDGPU
    if (system_mask & SYSTEM_GPU){
      fprintf(outfile,"%d,",system_state.gpu.temperature);
      fprintf(outfile,"%d%%,",system_state.gpu.gfx_activity);
      fprintf(outfile,"%d%%,",system_state.gpu.umc_activity);
      fprintf(outfile,"%d%%,",system_state.gpu.mm_activity);
    }
#endif
    if (system_mask & SYSTEM_NETWORK){
      if (system_state.netinfo == NULL) setup_net_info();
      for (i=0;i<system_state.num_net;i++){
	fprintf(outfile,"%lu,",system_state.netinfo[i].bytes);
      }
    }    
    break;
  case PRINT_NORMAL:
    if (system_mask & SYSTEM_LOADAVG){
      fprintf(outfile,"load                 %4.2f\n",system_state.load);
      fprintf(outfile,"runnable             %d\n",system_state.runnable);      
    }
    if (system_mask & SYSTEM_CPU){
      fprintf(outfile,"cpu                  %3.2f%%\n",
	      (double) (system_state.cpu.usertime+system_state.cpu.systemtime)/elapsed/num_procs);
      fprintf(outfile,"idle                 %3.2f%%\n",
	      (double) (system_state.cpu.idletime/elapsed/num_procs));
      fprintf(outfile,"io                   %3.2f%%\n",
	      (double) (system_state.cpu.iowaittime/elapsed/num_procs));      
      fprintf(outfile,"irq                  %3.2f%%\n",
	      (double) (system_state.cpu.usertime+system_state.cpu.systemtime)/elapsed/num_procs);      
    }
#if AMDGPU
    if (system_mask & SYSTEM_GPU){
      fprintf(outfile,"temperature          %dC\n",system_state.gpu.temperature);
      fprintf(outfile,"gpu gfx              %d%%\n",system_state.gpu.gfx_activity);
      fprintf(outfile,"gpu umc              %d%%\n",system_state.gpu.umc_activity);
      fprintf(outfile,"gpu mm               %d%%\n",system_state.gpu.mm_activity);      
    }
#endif
    if (system_mask & SYSTEM_NETWORK){
      if (system_state.netinfo == NULL) setup_net_info();
      for (i=0;i<system_state.num_net;i++){
	fprintf(outfile,"%-14s       %lu\n",system_state.netinfo[i].name,system_state.netinfo[i].bytes);
      }
    }    
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movl %edi, -0x4(%rbp)
leaq 0x67e7(%rip), %rax      # 0x130ec
cmpl $0x0, (%rax)
je 0xc91c
leaq 0x67db(%rip), %rax      # 0x130ec
cvtsi2sdl (%rax), %xmm0
movsd %xmm0, -0x10(%rbp)
jmp 0xc985
xorl %edi, %edi
leaq 0x782b(%rip), %rsi      # 0x14150
callq 0x3080
leaq 0x781f(%rip), %rax      # 0x14150
cvtsi2sdq (%rax), %xmm0
leaq 0x7813(%rip), %rax      # 0x14150
cvtsi2sdq 0x8(%rax), %xmm1
movsd 0x88d(%rip), %xmm2      # 0xd1d8
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
leaq 0x7806(%rip), %rax      # 0x14160
cvtsi2sdq (%rax), %xmm1
subsd %xmm1, %xmm0
leaq 0x77f6(%rip), %rax      # 0x14160
cvtsi2sdq 0x8(%rax), %xmm1
movsd 0x860(%rip), %xmm2      # 0xd1d8
divsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x10(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x18(%rbp)
testl %eax, %eax
je 0xcc81
jmp 0xc995
movl -0x18(%rbp), %eax
subl $0x1, %eax
je 0xca6b
jmp 0xc9a3
movl -0x18(%rbp), %eax
subl $0x2, %eax
jne 0xcee3
jmp 0xc9b1
movl 0x6711(%rip), %eax      # 0x130c8
andl $0x1, %eax
cmpl $0x0, %eax
je 0xc9d7
leaq 0x6742(%rip), %rax      # 0x13108
movq (%rax), %rdi
leaq 0x31ed(%rip), %rsi      # 0xfbbd
movb $0x0, %al
callq 0x31d0
movl 0x66eb(%rip), %eax      # 0x130c8
andl $0x2, %eax
cmpl $0x0, %eax
je 0xc9fd
leaq 0x671c(%rip), %rax      # 0x13108
movq (%rax), %rdi
leaq 0x31d6(%rip), %rsi      # 0xfbcc
movb $0x0, %al
callq 0x31d0
movl 0x66c5(%rip), %eax      # 0x130c8
andl $0x8, %eax
cmpl $0x0, %eax
je 0xca66
cmpq $0x0, 0x7815(%rip)      # 0x14228
jne 0xca1a
callq 0xc250
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x77f6(%rip), %eax      # 0x14220
jge 0xca64
leaq 0x66d5(%rip), %rax      # 0x13108
movq (%rax), %rdi
movq 0x77eb(%rip), %rax      # 0x14228
movslq -0x14(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rdx
leaq 0x318f(%rip), %rsi      # 0xfbe1
movb $0x0, %al
callq 0x31d0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xca21
jmp 0xca66
jmp 0xcee3
movl 0x6657(%rip), %eax      # 0x130c8
andl $0x1, %eax
cmpl $0x0, %eax
je 0xca9f
leaq 0x6688(%rip), %rax      # 0x13108
movq (%rax), %rdi
movsd 0x770d(%rip), %xmm0     # 0x14198
movl 0x770f(%rip), %edx      # 0x141a0
leaq 0x3151(%rip), %rsi      # 0xfbe9
movb $0x1, %al
callq 0x31d0
movl 0x6623(%rip), %eax      # 0x130c8
andl $0x2, %eax
cmpl $0x0, %eax
je 0xcc12
leaq 0x6650(%rip), %rax      # 0x13108
movq %rax, -0x20(%rbp)
movq (%rax), %rdi
movq 0x76e2(%rip), %rax      # 0x141a8
movq 0x76e3(%rip), %rcx      # 0x141b0
addq %rcx, %rax
movq %rax, %xmm0
movaps 0xe54(%rip), %xmm1      # 0xd930
movaps %xmm1, -0x40(%rbp)
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0xe54(%rip), %xmm1      # 0xd940
movaps %xmm1, -0x30(%rbp)
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd -0x10(%rbp), %xmm1
divsd %xmm1, %xmm0
leaq 0x660d(%rip), %rax      # 0x1311c
movq %rax, -0x58(%rbp)
cvtsi2sdl (%rax), %xmm1
divsd %xmm1, %xmm0
leaq 0x30d1(%rip), %rsi      # 0xfbf3
movq %rsi, -0x50(%rbp)
movb $0x1, %al
movb %al, -0x41(%rbp)
callq 0x31d0
movq -0x58(%rbp), %rcx
movq -0x50(%rbp), %rsi
movq -0x20(%rbp), %rdx
movaps -0x40(%rbp), %xmm2
movaps -0x30(%rbp), %xmm1
movb -0x41(%rbp), %al
movq (%rdx), %rdi
movq 0x7666(%rip), %xmm0     # 0x141b8
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd -0x10(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl (%rcx), %xmm1
divsd %xmm1, %xmm0
callq 0x31d0
movq -0x58(%rbp), %rcx
movq -0x50(%rbp), %rsi
movq -0x20(%rbp), %rdx
movaps -0x40(%rbp), %xmm2
movaps -0x30(%rbp), %xmm1
movb -0x41(%rbp), %al
movq (%rdx), %rdi
movq 0x7623(%rip), %xmm0     # 0x141c0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd -0x10(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl (%rcx), %xmm1
divsd %xmm1, %xmm0
callq 0x31d0
movaps -0x40(%rbp), %xmm2
movaps -0x30(%rbp), %xmm1
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq 0x75eb(%rip), %xmm0     # 0x141c8
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
divsd -0x10(%rbp), %xmm0
leaq 0x6520(%rip), %rax      # 0x1311c
cvtsi2sdl (%rax), %xmm1
divsd %xmm1, %xmm0
leaq 0x2fe8(%rip), %rsi      # 0xfbf3
movb $0x1, %al
callq 0x31d0
movl 0x64b0(%rip), %eax      # 0x130c8
andl $0x8, %eax
cmpl $0x0, %eax
je 0xcc7c
cmpq $0x0, 0x7600(%rip)      # 0x14228
jne 0xcc2f
callq 0xc250
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x75e1(%rip), %eax      # 0x14220
jge 0xcc7a
leaq 0x64c0(%rip), %rax      # 0x13108
movq (%rax), %rdi
movq 0x75d6(%rip), %rax      # 0x14228
movslq -0x14(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdx
leaq 0x2f94(%rip), %rsi      # 0xfbfc
movb $0x0, %al
callq 0x31d0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xcc36
jmp 0xcc7c
jmp 0xcee3
movl 0x6441(%rip), %eax      # 0x130c8
andl $0x1, %eax
cmpl $0x0, %eax
je 0xcccd
leaq 0x6472(%rip), %rax      # 0x13108
movq (%rax), %rdi
movsd 0x74f7(%rip), %xmm0     # 0x14198
leaq 0x2f59(%rip), %rsi      # 0xfc01
movb $0x1, %al
callq 0x31d0
leaq 0x6452(%rip), %rax      # 0x13108
movq (%rax), %rdi
movl 0x74e1(%rip), %edx      # 0x141a0
leaq 0x2f57(%rip), %rsi      # 0xfc1d
movb $0x0, %al
callq 0x31d0
movl 0x63f5(%rip), %eax      # 0x130c8
andl $0x2, %eax
cmpl $0x0, %eax
je 0xce62
leaq 0x6422(%rip), %rax      # 0x13108
movq %rax, -0x60(%rbp)
movq (%rax), %rdi
movq 0x74b4(%rip), %rax      # 0x141a8
movq 0x74b5(%rip), %rcx      # 0x141b0
addq %rcx, %rax
movq %rax, %xmm0
movaps 0xc26(%rip), %xmm1      # 0xd930
movaps %xmm1, -0x80(%rbp)
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0xc26(%rip), %xmm1      # 0xd940
movaps %xmm1, -0x70(%rbp)
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd -0x10(%rbp), %xmm1
divsd %xmm1, %xmm0
leaq 0x63df(%rip), %rax      # 0x1311c
movq %rax, -0x90(%rbp)
cvtsi2sdl (%rax), %xmm1
divsd %xmm1, %xmm0
leaq 0x2ee3(%rip), %rsi      # 0xfc36
movb $0x1, %al
movb %al, -0x81(%rbp)
callq 0x31d0
movq -0x90(%rbp), %rcx
movq -0x60(%rbp), %rdx
movaps -0x80(%rbp), %xmm2
movaps -0x70(%rbp), %xmm1
movb -0x81(%rbp), %al
movq (%rdx), %rdi
movq 0x7434(%rip), %xmm0     # 0x141b8
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd -0x10(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl (%rcx), %xmm1
divsd %xmm1, %xmm0
leaq 0x2ea5(%rip), %rsi      # 0xfc54
callq 0x31d0
movq -0x90(%rbp), %rcx
movq -0x60(%rbp), %rdx
movaps -0x80(%rbp), %xmm2
movaps -0x70(%rbp), %xmm1
movb -0x81(%rbp), %al
movq (%rdx), %rdi
movq 0x73e8(%rip), %xmm0     # 0x141c0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd -0x10(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl (%rcx), %xmm1
divsd %xmm1, %xmm0
leaq 0x2e6f(%rip), %rsi      # 0xfc72
callq 0x31d0
movaps -0x80(%rbp), %xmm2
movaps -0x70(%rbp), %xmm1
movq -0x60(%rbp), %rax
movq (%rax), %rdi
movq 0x738a(%rip), %rax      # 0x141a8
movq 0x738b(%rip), %rcx      # 0x141b0
addq %rcx, %rax
movq %rax, %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
divsd -0x10(%rbp), %xmm0
leaq 0x62d0(%rip), %rax      # 0x1311c
cvtsi2sdl (%rax), %xmm1
divsd %xmm1, %xmm0
leaq 0x2e35(%rip), %rsi      # 0xfc90
movb $0x1, %al
callq 0x31d0
movl 0x6260(%rip), %eax      # 0x130c8
andl $0x8, %eax
cmpl $0x0, %eax
je 0xcee1
cmpq $0x0, 0x73b0(%rip)      # 0x14228
jne 0xce7f
callq 0xc250
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x7391(%rip), %eax      # 0x14220
jge 0xcedf
leaq 0x6270(%rip), %rax      # 0x13108
movq (%rax), %rdi
movq 0x7386(%rip), %rax      # 0x14228
movslq -0x14(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rdx
movq 0x7371(%rip), %rax      # 0x14228
movslq -0x14(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
leaq 0x2de1(%rip), %rsi      # 0xfcae
movb $0x0, %al
callq 0x31d0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xce86
jmp 0xcee1
jmp 0xcee3
addq $0x90, %rsp
popq %rbp
retq