// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
cmpl $0x2, %esi
jne 0x803f
leaq 0xa0df(%rip), %rax      # 0x120f8
movq (%rax), %rcx
leaq 0x57c7(%rip), %rdi      # 0xd7ea
movl $0xa, %esi
movl $0x1, %edx
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x32c0
cvtsi2sdq 0xb0f8(%rip), %xmm3 # 0x13140
cvtsi2sdq 0xb0f7(%rip), %xmm2 # 0x13148
cvtsi2sdq 0xb0f6(%rip), %xmm4 # 0x13150
cvtsi2sdq 0xb0f5(%rip), %xmm1 # 0x13158
leaq 0xb0f6(%rip), %rax      # 0x13160
movq (%rax), %rax
movl (%rax), %eax
cmpl $0x2, %eax
je 0x80aa
cmpl $0x1, %eax
jne 0x80b7
movq %rdi, %r14
movsd %xmm4, 0x8(%rsp)
movsd %xmm3, 0x10(%rsp)
movsd %xmm1, 0x18(%rsp)
movsd %xmm2, (%rsp)
leaq 0x40f2(%rip), %rsi      # 0xc18c
callq 0x587d
testq %rax, %rax
je 0x80c5
movq 0x30(%rax), %rbx
jmp 0x80c7
xorl %r15d, %r15d
xorl %r12d, %r12d
xorl %r14d, %r14d
xorl %ebx, %ebx
jmp 0x8135
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
xorl %ebx, %ebx
leaq 0x40f3(%rip), %rsi      # 0xc1c1
movq %r14, %rdi
callq 0x587d
testq %rax, %rax
je 0x80e1
movq 0x30(%rax), %r15
jmp 0x80e4
xorl %r15d, %r15d
leaq 0x410d(%rip), %rsi      # 0xc1f8
movq %r14, %rdi
callq 0x587d
testq %rax, %rax
je 0x80fe
movq 0x30(%rax), %r12
jmp 0x8101
xorl %r12d, %r12d
leaq 0x412c(%rip), %rsi      # 0xc234
movq %r14, %rdi
callq 0x587d
testq %rax, %rax
je 0x811b
movq 0x30(%rax), %r14
jmp 0x811e
xorl %r14d, %r14d
movsd (%rsp), %xmm2
movsd 0x18(%rsp), %xmm1
movsd 0x10(%rsp), %xmm3
movsd 0x8(%rsp), %xmm4
movsd 0x30ab(%rip), %xmm0     # 0xb1e8
divsd %xmm0, %xmm2
addsd %xmm3, %xmm2
subsd %xmm4, %xmm2
divsd %xmm0, %xmm1
subsd %xmm1, %xmm2
leaq 0x9f80(%rip), %rax      # 0x120d8
cmpl $0x0, (%rax)
leaq 0x9f96(%rip), %r13      # 0x120f8
movq (%r13), %rdi
je 0x81c9
addq %r15, %r14
addq %rbx, %r12
addq %r14, %r12
movq %r12, %xmm1
punpckldq 0x37c2(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x37ca(%rip), %xmm1     # 0xb950
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x3796(%rip), %xmm0     # 0xb930
movsd 0x3796(%rip), %xmm1     # 0xb938
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
divsd %xmm2, %xmm0
leaq 0x4f7a(%rip), %rsi      # 0xd12f
movb $0x1, %al
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x31c0
addq %r12, %rbx
movq %rbx, %xmm1
punpckldq 0x3767(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x376f(%rip), %xmm1     # 0xb950
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x373b(%rip), %xmm0     # 0xb930
movsd 0x373b(%rip), %xmm1     # 0xb938
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
divsd %xmm2, %xmm0
leaq 0x55e5(%rip), %rsi      # 0xd7f5
movq %rbx, %rdx
movb $0x1, %al
movsd %xmm2, (%rsp)
callq 0x31c0
movq (%r13), %rdi
addq %r15, %r14
movq %r14, %xmm1
punpckldq 0x370d(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x3715(%rip), %xmm1     # 0xb950
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x36e1(%rip), %xmm0     # 0xb930
movsd 0x36e1(%rip), %xmm1     # 0xb938
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
divsd (%rsp), %xmm0
leaq 0x55b4(%rip), %rsi      # 0xd81f
movq %r14, %rdx
movb $0x1, %al
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x31c0