// File: /workspace/github_c_makefile_star2_O0/mvermeulen[P]wspy/topdown.c
// Function: print_memory
void print_memory(struct counter_group *cgroup,enum output_format oformat){
  unsigned long data_cache_local=0;
  unsigned long data_cache_remote=0;
  unsigned long prefetch_local=0;
  unsigned long prefetch_remote=0;
  struct counter_info *cinfo;
  double elapsed = finish_time.tv_sec + finish_time.tv_nsec / 1000000000.0 -
    start_time.tv_sec - start_time.tv_nsec / 1000000000.0;    

  if (oformat == PRINT_CSV_HEADER){
    fprintf(outfile,"bandwidth,");
    return;
  }  

  switch(cpu_info->vendor){
  case VENDOR_INTEL:
    break;
  case VENDOR_AMD:
    if (cinfo = find_ci_label(cgroup,"ls_data_cache_refills.local_all"))
      data_cache_local = cinfo->value;
    if (cinfo = find_ci_label(cgroup,"ls_data_cache_refills.remote_all"))
      data_cache_remote = cinfo->value;
    if (cinfo = find_ci_label(cgroup,"ls_hwpref_data_cache_refills.local_all"))
      prefetch_local = cinfo->value;
    if (cinfo = find_ci_label(cgroup,"ls_hwpref_data_cache_refills.remote_all"))
      prefetch_remote = cinfo->value;        
    break;
  default:
    return;
  }

  if (csvflag){
    fprintf(outfile,"%4.1f,",(double) (data_cache_local+data_cache_remote+prefetch_local+prefetch_remote)*64.0/1024/1024/elapsed);
  } else {
    fprintf(outfile,"local bandwidth      %-14lu # %4.1f MB/s\n",
	    data_cache_local+prefetch_local,
	    (double)(data_cache_local+prefetch_local)*64.0/1024.0/1024.0/elapsed);
    fprintf(outfile,"remote bandwidth     %-14lu # %4.1f MB/s\n",
	    data_cache_remote+prefetch_remote,
	    (double)(data_cache_remote+prefetch_remote)*64.0/1024.0/1024.0/elapsed);
  }  
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
cvtsi2sdq 0x9ec8(%rip), %xmm0 # 0x14150
cvtsi2sdq 0x9ec7(%rip), %xmm1 # 0x14158
movsd 0x2f3f(%rip), %xmm2     # 0xd1d8
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
cvtsi2sdq 0x9eb6(%rip), %xmm1 # 0x14160
subsd %xmm1, %xmm0
cvtsi2sdq 0x9eb1(%rip), %xmm1 # 0x14168
movsd 0x2f19(%rip), %xmm2     # 0xd1d8
divsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
cmpl $0x2, -0xc(%rbp)
jne 0xa2ef
leaq 0x8e2f(%rip), %rax      # 0x13108
movq (%rax), %rdi
leaq 0x54f9(%rip), %rsi      # 0xf7dc
movb $0x0, %al
callq 0x31d0
jmp 0xa531
leaq 0x9e7a(%rip), %rax      # 0x14170
movq (%rax), %rax
movl (%rax), %eax
movl %eax, -0x44(%rbp)
subl $0x1, %eax
je 0xa318
jmp 0xa305
movl -0x44(%rbp), %eax
subl $0x2, %eax
jne 0xa3b2
jmp 0xa313
jmp 0xa3b7
movq -0x8(%rbp), %rdi
leaq 0x3e59(%rip), %rsi      # 0xe17c
callq 0x6930
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
je 0xa33e
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x3e68(%rip), %rsi      # 0xe1b1
callq 0x6930
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
je 0xa364
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x3e79(%rip), %rsi      # 0xe1e8
callq 0x6930
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
je 0xa38a
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x3e8f(%rip), %rsi      # 0xe224
callq 0x6930
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
je 0xa3b0
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0xa3b7
jmp 0xa531
leaq 0x8d2a(%rip), %rax      # 0x130e8
cmpl $0x0, (%rax)
je 0xa44d
leaq 0x8d3a(%rip), %rax      # 0x13108
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
addq %rcx, %rax
movq -0x28(%rbp), %rcx
addq %rcx, %rax
movq -0x30(%rbp), %rcx
addq %rcx, %rax
movq %rax, %xmm0
movaps 0x353a(%rip), %xmm1     # 0xd930
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x353e(%rip), %xmm1     # 0xd940
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x3507(%rip), %xmm1     # 0xd920
mulsd %xmm1, %xmm0
movsd 0x34f3(%rip), %xmm1     # 0xd918
divsd %xmm1, %xmm0
movsd 0x34e7(%rip), %xmm1     # 0xd918
divsd %xmm1, %xmm0
divsd -0x40(%rbp), %xmm0
leaq 0x4ce0(%rip), %rsi      # 0xf121
movb $0x1, %al
callq 0x31d0
jmp 0xa531
leaq 0x8cb4(%rip), %rax      # 0x13108
movq %rax, -0x50(%rbp)
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
movq -0x28(%rbp), %rax
addq %rax, %rdx
movq %rdx, %xmm0
movaps 0x34be(%rip), %xmm1     # 0xd930
movaps %xmm1, -0x70(%rbp)
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x34be(%rip), %xmm1     # 0xd940
movaps %xmm1, -0x60(%rbp)
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x3483(%rip), %xmm1     # 0xd920
mulsd %xmm1, %xmm0
movsd 0x347f(%rip), %xmm1     # 0xd928
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movsd -0x40(%rbp), %xmm1
divsd %xmm1, %xmm0
leaq 0x5326(%rip), %rsi      # 0xf7e7
movb $0x1, %al
callq 0x31d0
movaps -0x70(%rbp), %xmm2
movaps -0x60(%rbp), %xmm1
movq -0x50(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %rax
addq %rax, %rdx
movq %rdx, %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
movsd 0x341e(%rip), %xmm1     # 0xd920
mulsd %xmm1, %xmm0
movsd 0x340a(%rip), %xmm1     # 0xd918
divsd %xmm1, %xmm0
movsd 0x33fe(%rip), %xmm1     # 0xd918
divsd %xmm1, %xmm0
divsd -0x40(%rbp), %xmm0
leaq 0x52e7(%rip), %rsi      # 0xf811
movb $0x1, %al
callq 0x31d0
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)