// File: /workspace/github_c_makefile_star2_O2/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 0xb340(%rip), %r14      # 0x101d4
movl (%r14), %esi
testw $0x2180, %si            # imm = 0x2180
je 0x4eb2
callq 0x4c57
testq %rax, %rax
je 0x4eb2
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x1, 0x2(%r14)
je 0x4ed9
leaq 0x5365(%rip), %rdi      # 0xa225
movl $0x10000, %esi          # imm = 0x10000
callq 0x4d52
testq %rax, %rax
je 0x4ed9
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x40, 0x1(%r14)
je 0x4f00
leaq 0x6b32(%rip), %rdi      # 0xba19
movl $0x4000, %esi           # imm = 0x4000
callq 0x4d52
testq %rax, %rax
je 0x4f00
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x10, 0x1(%r14)
je 0x4f27
leaq 0x533a(%rip), %rdi      # 0xa248
movl $0x1000, %esi           # imm = 0x1000
callq 0x4d52
testq %rax, %rax
je 0x4f27
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x8, 0x1(%r14)
je 0x4f4e
leaq 0x6aed(%rip), %rdi      # 0xba22
movl $0x800, %esi            # imm = 0x800
callq 0x4d52
testq %rax, %rax
je 0x4f4e
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x4, 0x1(%r14)
je 0x4f75
leaq 0x6acf(%rip), %rdi      # 0xba2b
movl $0x400, %esi            # imm = 0x400
callq 0x4d52
testq %rax, %rax
je 0x4f75
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x40, (%r14)
je 0x4f99
leaq 0x5271(%rip), %rdi      # 0xa1f3
pushq $0x40
popq %rsi
callq 0x4d52
testq %rax, %rax
je 0x4f99
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x20, (%r14)
je 0x4fbd
leaq 0x6a8e(%rip), %rdi      # 0xba34
pushq $0x20
popq %rsi
callq 0x4d52
testq %rax, %rax
je 0x4fbd
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x8, (%r14)
je 0x4fe1
leaq 0x6a75(%rip), %rdi      # 0xba3f
pushq $0x8
popq %rsi
callq 0x4d52
testq %rax, %rax
je 0x4fe1
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x10, (%r14)
je 0x5005
leaq 0x6a5c(%rip), %rdi      # 0xba4a
pushq $0x10
popq %rsi
callq 0x4d52
testq %rax, %rax
je 0x5005
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x4, (%r14)
je 0x5029
leaq 0x5286(%rip), %rdi      # 0xa298
pushq $0x4
popq %rsi
callq 0x4d52
testq %rax, %rax
je 0x5029
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x2, (%r14)
je 0x504d
leaq 0x5257(%rip), %rdi      # 0xa28d
pushq $0x2
popq %rsi
callq 0x4d52
testq %rax, %rax
je 0x504d
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
testb $0x1, (%r14)
je 0x5071
leaq 0x51e7(%rip), %rdi      # 0xa241
pushq $0x1
popq %rsi
callq 0x4d52
testq %rax, %rax
je 0x5071
movq (%rbx), %rcx
movq %rcx, 0x20(%rax)
movq %rax, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq