// File: /workspace/github_cpp_makefile_star2_O3/CMU-SAFARI[P]ramulator/src/DRAM.h
// Function: ramulator::DRAM<ramulator::DDR3>::DRAM(ramulator::DDR3*, ramulator::DDR3::Level)
DRAM<T>::DRAM(T* spec, typename T::Level level) :
    spec(spec), level(level), id(0), parent(NULL)
{

    state = spec->start[(int)level];
    prereq = spec->prereq[int(level)];
    rowhit = spec->rowhit[int(level)];
    rowopen = spec->rowopen[int(level)];
    lambda = spec->lambda[int(level)];
    timing = spec->timing[int(level)];

    fill_n(next, int(T::Command::MAX), -1); // initialize future
    for (int cmd = 0; cmd < int(T::Command::MAX); cmd++) {
        int dist = 0;
        for (auto& t : timing[cmd])
            dist = max(dist, t.dist);

        if (dist)
            prev[cmd].resize(dist, -1); // initialize history
    }

    // try to recursively construct my children
    int child_level = int(level) + 1;
    if (child_level == int(T::Level::Row))
        return; // stop recursion: rows are not instantiated as nodes

    int child_max = spec->org_entry.count[child_level];
    if (!child_max)
        return; // stop recursion: the number of children is unspecified

    // recursively construct my children
    for (int i = 0; i < child_max; i++) {
        DRAM<T>* child = new DRAM<T>(spec, typename T::Level(child_level));
        child->parent = this;
        child->id = i;
        children.push_back(child);
    }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
callq 0x21b38
leaq 0x185a3d(%rip), %r13    # 0x19d130
movq %r13, (%rbx)
xorl %eax, %eax
movq %rax, 0x70(%rbx)
leaq 0x88(%rbx), %rcx
movq %rcx, 0x78(%rbx)
movq %rax, 0x80(%rbx)
movb $0x0, 0x88(%rbx)
leaq 0x98(%rbx), %r12
movq %r12, %rdi
callq 0x21b38
movq %r13, 0x98(%rbx)
xorl %eax, %eax
movq %rax, 0x108(%rbx)
leaq 0x120(%rbx), %rcx
movq %rcx, 0x110(%rbx)
movq %rax, 0x118(%rbx)
movb $0x0, 0x120(%rbx)
leaq 0x130(%rbx), %rbp
movq %rbp, %rdi
movq %r12, 0x40(%rsp)
callq 0x21b38
movq %r13, 0x130(%rbx)
xorl %eax, %eax
movq %rax, 0x1a0(%rbx)
leaq 0x1b8(%rbx), %rcx
movq %rcx, 0x1a8(%rbx)
movq %rax, 0x1b0(%rbx)
movb $0x0, 0x1b8(%rbx)
leaq 0x1c8(%rbx), %rdi
movq %rdi, 0x30(%rsp)
movq %rbp, 0x38(%rsp)
callq 0x21b38
movq %r13, 0x1c8(%rbx)
xorl %eax, %eax
movq %rax, 0x238(%rbx)
leaq 0x250(%rbx), %rcx
movq %rcx, 0x240(%rbx)
movq %rax, 0x248(%rbx)
movb $0x0, 0x250(%rbx)
leaq 0x260(%rbx), %rdi
movq %rdi, 0x28(%rsp)
callq 0x21b38
movq %r13, 0x260(%rbx)
xorl %r12d, %r12d
movq %r12, 0x2d0(%rbx)
leaq 0x2e8(%rbx), %rax
movq %rax, 0x2d8(%rbx)
movq %r12, 0x2e0(%rbx)
movb $0x0, 0x2e8(%rbx)
leaq 0x2f8(%rbx), %rdi
movq %rdi, 0x20(%rsp)
callq 0x21b38
movq %r13, 0x2f8(%rbx)
movq %r12, 0x368(%rbx)
leaq 0x380(%rbx), %rax
movq %rax, 0x370(%rbx)
movq %r12, 0x378(%rbx)
movb $0x0, 0x380(%rbx)
movq %r15, 0x390(%rbx)
movl %r14d, 0x398(%rbx)
movl %r12d, 0x39c(%rbx)
leaq 0x3b0(%rbx), %rax
movq %rax, 0x8(%rsp)
leaq 0x3d0(%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0x3d8(%rbx), %rax
movl %r12d, 0x3d8(%rbx)
movq %r12, 0x3e0(%rbx)
xorps %xmm1, %xmm1
movups %xmm1, 0x3a8(%rbx)
movups %xmm1, 0x3b8(%rbx)
movq %rax, 0x3e8(%rbx)
movq %rax, 0x3f0(%rbx)
movq %r12, 0x3f8(%rbx)
movl %r12d, 0x400(%rbx)
leaq 0x430(%rbx), %rax
movq %rax, 0x10(%rsp)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x408(%rbx)
movdqu %xmm0, 0x418(%rbx)
movq $-0x1, 0x428(%rbx)
leaq 0x4b0(%rbx), %rbp
movups %xmm1, 0x440(%rbx)
movups %xmm1, 0x430(%rbx)
movq %rbp, %r13
pxor %xmm0, %xmm0
movdqu %xmm0, 0x40(%r13)
movdqu %xmm0, 0x30(%r13)
movdqu %xmm0, 0x20(%r13)
movdqu %xmm0, 0x10(%r13)
movdqu %xmm0, (%r13)
movq %r13, %rdi
xorl %esi, %esi
callq 0x21ea0
addq $-0x50, %r12
addq $0x50, %r13
cmpq $-0x3c0, %r12           # imm = 0xFC40
jne 0x178fd
movslq %r14d, %rax
movl 0x1b0(%r15,%rax,4), %ecx
movl %ecx, 0x3c8(%rbx)
leaq (%rax,%rax,2), %rcx
shlq $0x7, %rcx
leaq (%r15,%rcx), %rdx
addq $0x1e0, %rdx            # imm = 0x1E0
movq %rdx, 0x870(%rbx)
leaq 0x960(%r15,%rcx), %rdx
movq %rdx, 0x878(%rbx)
leaq 0x10e0(%r15,%rcx), %rdx
movq %rdx, 0x880(%rbx)
addq %r15, %rcx
addq $0x1e00, %rcx           # imm = 0x1E00
movq %rcx, 0x888(%rbx)
leaq (%rax,%rax,8), %rax
shlq $0x5, %rax
addq %r15, %rax
addq $0x1860, %rax           # imm = 0x1860
movq %rax, 0x890(%rbx)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x450(%rbx)
movdqu %xmm0, 0x460(%rbx)
movdqu %xmm0, 0x470(%rbx)
movdqu %xmm0, 0x480(%rbx)
movdqu %xmm0, 0x490(%rbx)
movdqu %xmm0, 0x4a0(%rbx)
xorl %r12d, %r12d
movq %rsp, %r13
movq 0x890(%rbx), %rax
leaq (%r12,%r12,2), %rdx
movq (%rax,%rdx,8), %rcx
movq 0x8(%rax,%rdx,8), %rdx
cmpq %rdx, %rcx
je 0x17a35
xorl %eax, %eax
movl %eax, %esi
movl 0x4(%rcx), %eax
cmpl %eax, %esi
cmovgl %esi, %eax
addq $0x10, %rcx
cmpq %rdx, %rcx
jne 0x17a01
testl %eax, %eax
je 0x17a35
leaq (%r12,%r12,4), %rdi
shlq $0x4, %rdi
addq %rbp, %rdi
movl %eax, %esi
movq $-0x1, (%rsp)
movq %r13, %rdx
callq 0x217f4
incq %r12
cmpq $0xc, %r12
jne 0x179e6
incl %r14d
cmpl $0x3, %r14d
je 0x17ab9
movslq %r14d, %rax
movl 0x272c(%r15,%rax,4), %r12d
testl %r12d, %r12d
jle 0x17ab9
xorl %r13d, %r13d
movl $0x898, %edi            # imm = 0x898
callq 0xb2e0
movq %rax, %rbp
movq %rax, %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0x176d0
movq %rbp, (%rsp)
movq %rbx, 0x3a8(%rbp)
movl %r13d, 0x39c(%rbp)
movq 0x3b8(%rbx), %rsi
cmpq 0x3c0(%rbx), %rsi
je 0x17aa4
movq %rbp, (%rsi)
addq $0x8, 0x3b8(%rbx)
jmp 0x17ab1
movq 0x8(%rsp), %rdi
movq %rsp, %rdx
callq 0x236f8
incl %r13d
cmpl %r13d, %r12d
jne 0x17a5a
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0x17b96
movq %rax, %r14
jmp 0x17ba0
movq %rax, %r14
jmp 0x17baa
movq %rax, %r14
jmp 0x17bb4
movq %rax, %r14
jmp 0x17bbe
movq %rax, %r14
movl $0x898, %esi            # imm = 0x898
movq %rbp, %rdi
callq 0xb2f0
jmp 0x17b07
jmp 0x17b04
movq %rax, %r14
leaq 0x820(%rbx), %r15
xorl %r12d, %r12d
leaq (%r15,%r12), %rdi
callq 0x22016
addq $-0x50, %r12
cmpq $-0x3c0, %r12           # imm = 0xFC40
jne 0x17b11
jmp 0x17b4a
movq %rax, %r14
testq %r12, %r12
je 0x17b4a
negq %r12
leaq 0x460(%rbx), %r15
leaq (%r15,%r12), %rdi
callq 0x22016
addq $-0x50, %r12
jne 0x17b3b
movq 0x10(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x17b66
movq 0x440(%rbx), %rsi
subq %rdi, %rsi
callq 0xb2f0
movq 0x18(%rsp), %rdi
callq 0x23834
movq 0x8(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x17b8c
movq 0x3c0(%rbx), %rsi
subq %rdi, %rsi
callq 0xb2f0
movq 0x20(%rsp), %rdi
callq 0x2191a
movq 0x28(%rsp), %rdi
callq 0x2191a
movq 0x30(%rsp), %rdi
callq 0x2191a
movq 0x38(%rsp), %rdi
callq 0x2191a
movq 0x40(%rsp), %rdi
callq 0x2191a
movq %rbx, %rdi
callq 0x2191a
movq %r14, %rdi
callq 0xb510