// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]ramulator/src/DRAM.h
// Function: ramulator::DRAM<ramulator::DDR3>::update_serving_requests(int const*, int, long)
void DRAM<T>::update_serving_requests(const int* addr, int delta, long clk) {
  assert(id == addr[int(level)]);
  assert(delta == 1 || delta == -1);
  // update total serving requests
  if (begin_of_cur_reqcnt != -1 && cur_serving_requests > 0) {
    serving_requests += (clk - begin_of_cur_reqcnt) * cur_serving_requests;
    active_cycles += clk - begin_of_cur_reqcnt;
  }
  // update begin of current request number
  begin_of_cur_reqcnt = clk;
  cur_serving_requests += delta;
  assert(cur_serving_requests >= 0);

  if (delta == 1 && cur_serving_requests == 1) {
    // transform from inactive to active
    begin_of_serving = clk;
    if (end_of_refreshing > begin_of_serving) {
      active_refresh_overlap_cycles += end_of_refreshing - begin_of_serving;
    }
  } else if (cur_serving_requests == 0) {
    // transform from active to inactive
    assert(begin_of_serving != -1);
    assert(delta == -1);
    active_cycles += clk - begin_of_cur_reqcnt;
    end_of_serving = clk;

    for (const auto& ref: refresh_intervals) {
      active_refresh_overlap_cycles += min(end_of_serving, ref.second) - ref.first;
    }
    refresh_intervals.clear();
  }

  int child_id = addr[int(level) + 1];
  // We only count the level bank or the level higher than bank
  if (child_id < 0 || !children.size() || (int(level) > int(T::Level::Bank)) ) {
    return;
  }
  children[child_id]->update_serving_requests(addr, delta, clk);
}

// Assembly:
pushq %rbx
xorpd %xmm0, %xmm0
movl 0x39c(%rdi), %r8d
movslq 0x398(%rdi), %rax
cmpl (%rsi,%rax,4), %r8d
jne 0x28983
cmpl $-0x1, %edx
je 0x287ff
cmpl $0x1, %edx
jne 0x289a2
movq 0x418(%rdi), %r8
cmpq $-0x1, %r8
je 0x2884c
movslq 0x400(%rdi), %r9
testq %r9, %r9
jle 0x2884c
movq %rcx, %r10
subq %r8, %r10
imulq %r10, %r9
xorps %xmm1, %xmm1
cvtsi2sd %r9, %xmm1
addsd 0x2d0(%rdi), %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %r10, %xmm2
movsd %xmm1, 0x2d0(%rdi)
addsd 0x70(%rdi), %xmm2
movsd %xmm2, 0x70(%rdi)
movq %rcx, 0x418(%rdi)
movl 0x400(%rdi), %r8d
addl %edx, %r8d
movl %r8d, 0x400(%rdi)
js 0x28964
cmpl $0x1, %edx
jne 0x288a9
cmpl $0x1, %r8d
jne 0x288a9
movq %rcx, 0x408(%rdi)
movq 0x428(%rdi), %r8
subq %rcx, %r8
jle 0x2893a
xorps %xmm1, %xmm1
cvtsi2sd %r8, %xmm1
addsd 0x238(%rdi), %xmm1
movsd %xmm1, 0x238(%rdi)
jmp 0x2893a
testl %r8d, %r8d
jne 0x2893a
cmpq $-0x1, 0x408(%rdi)
je 0x289e0
cmpl $-0x1, %edx
jne 0x289c1
movsd 0x70(%rdi), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x70(%rdi)
movq %rcx, 0x410(%rdi)
movq 0x430(%rdi), %r8
movq 0x438(%rdi), %r9
cmpq %r9, %r8
je 0x2892e
movq 0x410(%rdi), %r10
movsd 0x238(%rdi), %xmm1
movq %r8, %r11
movq 0x8(%r11), %rbx
cmpq %rcx, %rbx
cmovgeq %r10, %rbx
subq (%r11), %rbx
xorps %xmm2, %xmm2
cvtsi2sd %rbx, %xmm2
addsd %xmm2, %xmm1
addq $0x10, %r11
cmpq %r9, %r11
jne 0x28903
movsd %xmm1, 0x238(%rdi)
cmpq %r8, %r9
je 0x2893a
movq %r8, 0x438(%rdi)
movslq 0x4(%rsi,%rax,4), %r8
testq %r8, %r8
js 0x28962
cmpl $0x2, %eax
jg 0x28962
movq 0x3b0(%rdi), %rax
cmpq %rax, 0x3b8(%rdi)
je 0x28962
movq (%rax,%r8,8), %rdi
jmp 0x287d9
popq %rbx
retq
leaq 0x126056(%rip), %rdi    # 0x14e9c1
leaq 0x125fbd(%rip), %rsi    # 0x14e92f
leaq 0x125fc1(%rip), %rcx    # 0x14e93a
movl $0x1a4, %edx            # imm = 0x1A4
callq 0xb200
leaq 0x125f8e(%rip), %rdi    # 0x14e918
leaq 0x125f9e(%rip), %rsi    # 0x14e92f
leaq 0x125fa2(%rip), %rcx    # 0x14e93a
movl $0x19a, %edx            # imm = 0x19A
callq 0xb200
leaq 0x125ffe(%rip), %rdi    # 0x14e9a7
leaq 0x125f7f(%rip), %rsi    # 0x14e92f
leaq 0x125f83(%rip), %rcx    # 0x14e93a
movl $0x19b, %edx            # imm = 0x19B
callq 0xb200
leaq 0x125fed(%rip), %rdi    # 0x14e9b5
leaq 0x125f60(%rip), %rsi    # 0x14e92f
leaq 0x125f64(%rip), %rcx    # 0x14e93a
movl $0x1af, %edx            # imm = 0x1AF
callq 0xb200
leaq 0x125ff4(%rip), %rdi    # 0x14e9db
leaq 0x125f41(%rip), %rsi    # 0x14e92f
leaq 0x125f45(%rip), %rcx    # 0x14e93a
movl $0x1ae, %edx            # imm = 0x1AE
callq 0xb200
nop