// File: /workspace/github_cpp_makefile_star2_O1/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 0x70d8c(%rip), %rax     # 0x1a35a8
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 0x1329ae
leaq 0x20(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x50(%rbx), %rax
movq %rax, 0x38(%rsp)
leaq 0x68(%rbx), %rax
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
leaq 0x20(%rsp), %rbp
leaq 0xf(%rsp), %r15
movl $0x0, 0x20(%rsp)
movq 0x28(%rbx), %rsi
cmpq 0x30(%rbx), %rsi
je 0x1328fd
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x28(%rbx)
jmp 0x13290a
movq 0x10(%rsp), %rdi
movq %rbp, %rdx
callq 0x24f52
movl $0x18, %edi
callq 0xb2e0
movq %rax, %r12
movslq 0x3c(%rbx), %rsi
movl $0x0, 0x8(%rsp)
movb $0x1, %r14b
movq %rax, %rdi
leaq 0x8(%rsp), %rdx
movq %r15, %rcx
callq 0x24dce
movq %r12, 0x20(%rsp)
xorl %r14d, %r14d
movq 0x38(%rsp), %rdi
movq %rbp, %rsi
callq 0x25072
movq 0x40(%rsp), %rax
movq 0x1098(%rax), %rax
movq 0x390(%rax), %rax
movslq 0x30d4(%rax), %rsi
movl $0x0, 0x8(%rsp)
movq %rbp, %rdi
leaq 0x8(%rsp), %rdx
movq %r15, %rcx
callq 0x24dce
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
callq 0x299fc
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1329a1
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0xb2f0
incl %r13d
cmpl 0x38(%rbx), %r13d
jl 0x1328db
movaps 0x2b8ab(%rip), %xmm0    # 0x15e260
movups %xmm0, 0x40(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1329cc
jmp 0x1329cc
movq %rax, %r15
jmp 0x1329fd
movq %rax, %r15
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1329fd
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
jmp 0x1329f8
movq %rax, %r15
testb %r14b, %r14b
je 0x1329fd
movl $0x18, %esi
movq %r12, %rdi
callq 0xb2f0
movq 0x18(%rsp), %rdi
callq 0x24e4c
movq 0x50(%rbx), %rdi
testq %rdi, %rdi
je 0x132a1c
movq 0x60(%rbx), %rsi
subq %rdi, %rsi
callq 0xb2f0
movq 0x10(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x132a35
movq 0x30(%rbx), %rsi
subq %rdi, %rsi
callq 0xb2f0
movq %r15, %rdi
callq 0xb510
nop