// File: /workspace/github_cpp_makefile_star2_O3/CMU-SAFARI[P]ramulator/src/Refresh.cpp
// Function: ramulator::Refresh<ramulator::DSARP>::Refresh(ramulator::Controller<ramulator::DSARP>*)
Refresh<DSARP>::Refresh(Controller<DSARP>* ctrl) : ctrl(ctrl) {
  clk = refreshed = 0;
  max_rank_count = ctrl->channel->children.size();
  max_bank_count = ctrl->channel->spec->org_entry.count[(int)DSARP::Level::Bank];
  max_sa_count = ctrl->channel->spec->org_entry.count[(int)DSARP::Level::SubArray];

  // Init refresh counters
  for (int r = 0; r < max_rank_count; r++) {
    bank_ref_counters.push_back(0);
    bank_refresh_backlog.push_back(new vector<int>(max_bank_count, 0));
    vector<int> sa_counters(ctrl->channel->spec->org_entry.count[(int)DSARP::Level::SubArray], 0);
    subarray_ref_counters.push_back(sa_counters);
  }

  level_chan = (int)DSARP::Level::Channel;
  level_rank = (int)DSARP::Level::Rank;
  level_bank = (int)DSARP::Level::Bank;
  level_sa   = (int)DSARP::Level::SubArray;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq 0x6fe94(%rip), %rax     # 0x19f5a8
movq %rax, (%rdi)
movq %rsi, 0x8(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rdi)
movq $0x0, 0x30(%rdi)
movups %xmm0, 0x50(%rdi)
movups %xmm0, 0x60(%rdi)
movups %xmm0, 0x70(%rdi)
movl $0x0, 0x80(%rdi)
movabsq $-0x7fffffff8, %rax     # imm = 0xFFFFFFF800000008
movq %rax, 0x84(%rdi)
movl $0xfffffffa, 0x8c(%rdi) # imm = 0xFFFFFFFA
movb $0x0, 0x90(%rdi)
movups %xmm0, 0x10(%rdi)
movq %rsi, 0x40(%rsp)
movq 0x1098(%rsi), %rax
movq 0x3b8(%rax), %rcx
subq 0x3b0(%rax), %rcx
shrq $0x3, %rcx
movl %ecx, 0x38(%rdi)
movq 0x390(%rax), %rax
movl 0x30d0(%rax), %edx
movl %edx, 0x3c(%rdi)
movl 0x30d4(%rax), %eax
movl %eax, 0x80(%rdi)
testl %ecx, %ecx
jle 0x12f8a1
leaq 0x20(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x50(%rbx), %rax
movq %rax, 0x20(%rsp)
leaq 0x68(%rbx), %rax
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
leaq 0x28(%rsp), %rbp
leaq 0xc(%rsp), %r14
leaq 0xb(%rsp), %r15
movl $0x0, 0x28(%rsp)
movq 0x28(%rbx), %rsi
cmpq 0x30(%rbx), %rsi
je 0x12f7fa
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x28(%rbx)
jmp 0x12f807
movq 0x10(%rsp), %rdi
movq %rbp, %rdx
callq 0x24ffe
movl $0x18, %edi
callq 0xb2e0
movq %rax, %r12
movslq 0x3c(%rbx), %rsi
movl $0x0, 0xc(%rsp)
movq %rax, %rdi
movq %r14, %rdx
movq %r15, %rcx
callq 0x24d76
movq %r12, 0x28(%rsp)
movq 0x20(%rsp), %rdi
movq %rbp, %rsi
callq 0x2511e
movq 0x40(%rsp), %rax
movq 0x1098(%rax), %rax
movq 0x390(%rax), %rax
movslq 0x30d4(%rax), %rsi
movl $0x0, 0xc(%rsp)
movq %rbp, %rdi
movq %r14, %rdx
movq %r15, %rcx
callq 0x24d76
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
callq 0x29d14
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x12f894
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0xb2f0
incl %r13d
cmpl 0x38(%rbx), %r13d
jl 0x12f7d8
movaps 0x2ba18(%rip), %xmm0    # 0x15b2c0
movups %xmm0, 0x40(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x12f8ce
jmp 0x12f8ce
movq %rax, %r14
movl $0x18, %esi
movq %r12, %rdi
jmp 0x12f8e8
jmp 0x12f8ce
movq %rax, %r14
jmp 0x12f8ed
movq %rax, %r14
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x12f8ed
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0xb2f0
movq 0x18(%rsp), %rdi
callq 0x24ef2
movq 0x20(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x12f910
movq 0x60(%rbx), %rsi
subq %rdi, %rsi
callq 0xb2f0
movq 0x10(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x12f929
movq 0x30(%rbx), %rsi
subq %rdi, %rsi
callq 0xb2f0
movq %r14, %rdi
callq 0xb510
nop