// File: /workspace/github_c_makefile_star2_O1/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 0xc2b7(%rip), %r14      # 0x111c4
movl (%r14), %esi
testl $0x2180, %esi           # imm = 0x2180
je 0x4f2c
callq 0x4cc8
testq %rax, %rax
je 0x4f2c
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x1, 0x2(%r14)
je 0x4f53
leaq 0x62eb(%rip), %rdi      # 0xb225
movl $0x10000, %esi          # imm = 0x10000
callq 0x4dcb
testq %rax, %rax
je 0x4f53
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x40, 0x1(%r14)
je 0x4f7a
leaq 0x7ab8(%rip), %rdi      # 0xca19
movl $0x4000, %esi           # imm = 0x4000
callq 0x4dcb
testq %rax, %rax
je 0x4f7a
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x10, 0x1(%r14)
je 0x4fa1
leaq 0x62c0(%rip), %rdi      # 0xb248
movl $0x1000, %esi           # imm = 0x1000
callq 0x4dcb
testq %rax, %rax
je 0x4fa1
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x8, 0x1(%r14)
je 0x4fc8
leaq 0x7a73(%rip), %rdi      # 0xca22
movl $0x800, %esi            # imm = 0x800
callq 0x4dcb
testq %rax, %rax
je 0x4fc8
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x4, 0x1(%r14)
je 0x4fef
leaq 0x7a55(%rip), %rdi      # 0xca2b
movl $0x400, %esi            # imm = 0x400
callq 0x4dcb
testq %rax, %rax
je 0x4fef
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x40, (%r14)
je 0x5015
leaq 0x61f7(%rip), %rdi      # 0xb1f3
movl $0x40, %esi
callq 0x4dcb
testq %rax, %rax
je 0x5015
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x20, (%r14)
je 0x503b
leaq 0x7a12(%rip), %rdi      # 0xca34
movl $0x20, %esi
callq 0x4dcb
testq %rax, %rax
je 0x503b
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x8, (%r14)
je 0x5061
leaq 0x79f7(%rip), %rdi      # 0xca3f
movl $0x8, %esi
callq 0x4dcb
testq %rax, %rax
je 0x5061
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x10, (%r14)
je 0x5087
leaq 0x79dc(%rip), %rdi      # 0xca4a
movl $0x10, %esi
callq 0x4dcb
testq %rax, %rax
je 0x5087
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x4, (%r14)
je 0x50ad
leaq 0x6204(%rip), %rdi      # 0xb298
movl $0x4, %esi
callq 0x4dcb
testq %rax, %rax
je 0x50ad
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x2, (%r14)
je 0x50d3
leaq 0x61d3(%rip), %rdi      # 0xb28d
movl $0x2, %esi
callq 0x4dcb
testq %rax, %rax
je 0x50d3
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x1, (%r14)
je 0x50f9
leaq 0x6161(%rip), %rdi      # 0xb241
movl $0x1, %esi
callq 0x4dcb
testq %rax, %rax
je 0x50f9
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq