// File: /workspace/github_c_makefile_star2_O3/mvermeulen[P]wspy/topdown.c
// Function: setup_counter_groups
void setup_counter_groups(struct counter_group **counter_group_list){

  int i,count;
  struct counter_group *cgroup;

  // note: These get pushed onto a linked list, so last listed is first printed
  if (counter_mask & (COUNTER_DCACHE|COUNTER_ICACHE|COUNTER_TLB)){
    if (cgroup = cache_counter_group("cache",counter_mask)){
      cgroup->next = *counter_group_list;
      *counter_group_list = cgroup;
    }
  }

  if (counter_mask & COUNTER_FLOAT){
    if (cgroup = raw_counter_group("float",COUNTER_FLOAT)){
      cgroup->next = *counter_group_list;
      *counter_group_list = cgroup;      
    }
  }

  if (counter_mask & COUNTER_OPCACHE){
    if (cgroup = raw_counter_group("op cache",COUNTER_OPCACHE)){
      cgroup->next = *counter_group_list;
      *counter_group_list = cgroup;      
    }    
  }
  

  if (counter_mask & COUNTER_MEMORY){
    if (cgroup = raw_counter_group("memory",COUNTER_MEMORY)){
      cgroup->next = *counter_group_list;
      *counter_group_list = cgroup;      
    }
  }

  if (counter_mask & COUNTER_L3CACHE){
    if (cgroup = raw_counter_group("l3 cache",COUNTER_L3CACHE)){
      cgroup->next = *counter_group_list;
      *counter_group_list = cgroup;      
    }    
  }  

  if (counter_mask & COUNTER_L2CACHE){
    if (cgroup = raw_counter_group("l2 cache",COUNTER_L2CACHE)){
      cgroup->next = *counter_group_list;
      *counter_group_list = cgroup;      
    }    
  }

  if (counter_mask & COUNTER_BRANCH){
    if (cgroup = raw_counter_group("branch",COUNTER_BRANCH)){
      cgroup->next = *counter_group_list;
      *counter_group_list = cgroup;      
    }        
  }

  if (counter_mask & COUNTER_TOPDOWN_OP){
    if (cgroup = raw_counter_group("topdown-op",COUNTER_TOPDOWN_OP)){
      cgroup->next = *counter_group_list;
      *counter_group_list = cgroup;      
    }
  }    
      
  if (counter_mask & COUNTER_TOPDOWN_FE){
    if (cgroup = raw_counter_group("topdown-fe",COUNTER_TOPDOWN_FE)){
      cgroup->next = *counter_group_list;
      *counter_group_list = cgroup;      
    }
  }  

  if (counter_mask & COUNTER_TOPDOWN_BE){
    if (cgroup = raw_counter_group("topdown-be",COUNTER_TOPDOWN_BE)){
      cgroup->next = *counter_group_list;
      *counter_group_list = cgroup;      
    }
  }  
  
  if (counter_mask & COUNTER_TOPDOWN2){
    if (cgroup = raw_counter_group("topdown2",COUNTER_TOPDOWN2)){
      cgroup->next = *counter_group_list;
      *counter_group_list = cgroup;      
    }
  }  
  
  if (counter_mask & COUNTER_TOPDOWN){
    if (cgroup = raw_counter_group("topdown",COUNTER_TOPDOWN)){
      cgroup->next = *counter_group_list;
      *counter_group_list = cgroup;      
    }
  }  

  if (counter_mask & COUNTER_IPC){
    if (cgroup = raw_counter_group("ipc",COUNTER_IPC)){
      cgroup->next = *counter_group_list;
      *counter_group_list = cgroup;		
    }
  }

}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0xc2b8(%rip), %r14      # 0x111c4
movl (%r14), %esi
testl $0x2180, %esi           # imm = 0x2180
je 0x4f2b
callq 0x4cc2
testq %rax, %rax
je 0x4f2b
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x1, 0x2(%r14)
je 0x4f52
leaq 0x62ec(%rip), %rdi      # 0xb225
movl $0x10000, %esi          # imm = 0x10000
callq 0x4dc5
testq %rax, %rax
je 0x4f52
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x40, 0x1(%r14)
je 0x4f79
leaq 0x7ab9(%rip), %rdi      # 0xca19
movl $0x4000, %esi           # imm = 0x4000
callq 0x4dc5
testq %rax, %rax
je 0x4f79
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x10, 0x1(%r14)
je 0x4fa0
leaq 0x62c1(%rip), %rdi      # 0xb248
movl $0x1000, %esi           # imm = 0x1000
callq 0x4dc5
testq %rax, %rax
je 0x4fa0
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x8, 0x1(%r14)
je 0x4fc7
leaq 0x7a74(%rip), %rdi      # 0xca22
movl $0x800, %esi            # imm = 0x800
callq 0x4dc5
testq %rax, %rax
je 0x4fc7
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x4, 0x1(%r14)
je 0x4fee
leaq 0x7a56(%rip), %rdi      # 0xca2b
movl $0x400, %esi            # imm = 0x400
callq 0x4dc5
testq %rax, %rax
je 0x4fee
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x40, (%r14)
je 0x5014
leaq 0x61f8(%rip), %rdi      # 0xb1f3
movl $0x40, %esi
callq 0x4dc5
testq %rax, %rax
je 0x5014
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x20, (%r14)
je 0x503a
leaq 0x7a13(%rip), %rdi      # 0xca34
movl $0x20, %esi
callq 0x4dc5
testq %rax, %rax
je 0x503a
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x8, (%r14)
je 0x5060
leaq 0x79f8(%rip), %rdi      # 0xca3f
movl $0x8, %esi
callq 0x4dc5
testq %rax, %rax
je 0x5060
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x10, (%r14)
je 0x5086
leaq 0x79dd(%rip), %rdi      # 0xca4a
movl $0x10, %esi
callq 0x4dc5
testq %rax, %rax
je 0x5086
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x4, (%r14)
je 0x50ac
leaq 0x6205(%rip), %rdi      # 0xb298
movl $0x4, %esi
callq 0x4dc5
testq %rax, %rax
je 0x50ac
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x2, (%r14)
je 0x50d2
leaq 0x61d4(%rip), %rdi      # 0xb28d
movl $0x2, %esi
callq 0x4dc5
testq %rax, %rax
je 0x50d2
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x1, (%r14)
je 0x50f8
leaq 0x6162(%rip), %rdi      # 0xb241
movl $0x1, %esi
callq 0x4dc5
testq %rax, %rax
je 0x50f8
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq