// File: CMU-SAFARI[P]ramulator/src/Memory.h
// Function: ramulator::Memory<ramulator::DDR3, ramulator::Controller>::finish()
void finish(void) {
      dram_capacity = max_address;
      int *sz = spec->org_entry.count;
      maximum_bandwidth = spec->speed_entry.rate * 1e6 * spec->channel_width * sz[int(T::Level::Channel)] / 8;
      long dram_cycles = num_dram_cycles.value();
      for (auto ctrl : ctrls) {
        long read_req = long(incoming_read_reqs_per_channel[ctrl->channel->id].value());
        ctrl->finish(read_req, dram_cycles);
      }

      // finalize average queueing requests
      in_queue_req_num_avg = in_queue_req_num_sum.value() / dram_cycles;
      in_queue_read_req_num_avg = in_queue_read_req_num_sum.value() / dram_cycles;
      in_queue_write_req_num_avg = in_queue_write_req_num_sum.value() / dram_cycles;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x68(%rbp)
movq %rdi, %rsi
addq $0xb48, %rsi            # imm = 0xB48
addq $0x8, %rdi
callq 0x386a0
movq -0x68(%rbp), %rdi
movq 0xc20(%rdi), %rax
addq $0x2724, %rax           # imm = 0x2724
addq $0x8, %rax
movq %rax, -0x10(%rbp)
movq 0xc20(%rdi), %rax
cvtsi2sdl 0x2d68(%rax), %xmm0
movsd 0x2161c1(%rip), %xmm1   # 0x24f018
mulsd %xmm1, %xmm0
movq 0xc20(%rdi), %rax
cvtsi2sdl 0x2744(%rax), %xmm1
mulsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
cvtsi2sdl (%rax), %xmm1
mulsd %xmm1, %xmm0
movsd 0x21618e(%rip), %xmm1   # 0x24f010
divsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
addq $0x5c0, %rdi            # imm = 0x5C0
leaq -0x18(%rbp), %rsi
callq 0x485b0
movq -0x68(%rbp), %rdi
addq $0xa0, %rdi
callq 0x485e0
movq -0x68(%rbp), %rax
cvttsd2si %xmm0, %rcx
movq %rcx, -0x20(%rbp)
addq $0xc08, %rax            # imm = 0xC08
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x36f70
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0x36e00
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x3fd70
testb $0x1, %al
jne 0x38eef
jmp 0x38f4e
leaq -0x30(%rbp), %rdi
callq 0x3fdb0
movq -0x68(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x40(%rbp)
addq $0x478, %rdi            # imm = 0x478
movq -0x40(%rbp), %rax
movq 0x1098(%rax), %rax
movl 0x39c(%rax), %esi
callq 0x41b70
movq %rax, %rdi
movq (%rdi), %rax
callq *0x58(%rax)
cvttsd2si %xmm0, %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x48600
leaq -0x30(%rbp), %rdi
callq 0x3fe20
jmp 0x38edc
movq -0x68(%rbp), %rdi
addq $0x658, %rdi            # imm = 0x658
callq 0x485e0
movq -0x68(%rbp), %rdi
cvtsi2sdq -0x20(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
addq $0x820, %rdi            # imm = 0x820
leaq -0x50(%rbp), %rsi
callq 0x485b0
movq -0x68(%rbp), %rdi
addq $0x6f0, %rdi            # imm = 0x6F0
callq 0x485e0
movq -0x68(%rbp), %rdi
cvtsi2sdq -0x20(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
addq $0x8b8, %rdi            # imm = 0x8B8
leaq -0x58(%rbp), %rsi
callq 0x485b0
movq -0x68(%rbp), %rdi
addq $0x788, %rdi            # imm = 0x788
callq 0x485e0
movq -0x68(%rbp), %rdi
cvtsi2sdq -0x20(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
addq $0x950, %rdi            # imm = 0x950
leaq -0x60(%rbp), %rsi
callq 0x485b0
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)