// File: /workspace/github_cpp_makefile_star2_O1/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 0x21be2
leaq 0x189a19(%rip), %r13    # 0x1a10f8
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 0x21be2
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 0x21be2
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 0x21be2
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 0x21be2
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 0x21be2
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 0x21f42
addq $-0x50, %r12
addq $0x50, %r13
cmpq $-0x3c0, %r12           # imm = 0xFC40
jne 0x178e9
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
movl $0x0, %eax
cmpq %rdx, %rcx
je 0x17a05
xorl %esi, %esi
movl 0x4(%rcx), %eax
cmpl %eax, %esi
cmovgl %esi, %eax
addq $0x10, %rcx
movl %eax, %esi
cmpq %rdx, %rcx
jne 0x179f2
testl %eax, %eax
je 0x17a26
leaq (%r12,%r12,4), %rdi
shlq $0x4, %rdi
addq %rbp, %rdi
movl %eax, %esi
movq $-0x1, (%rsp)
movq %r13, %rdx
callq 0x2187e
incq %r12
cmpq $0xc, %r12
jne 0x179d2
incl %r14d
cmpl $0x3, %r14d
je 0x17aaa
movslq %r14d, %rax
movl 0x272c(%r15,%rax,4), %r12d
testl %r12d, %r12d
jle 0x17aaa
xorl %r13d, %r13d
movl $0x898, %edi            # imm = 0x898
callq 0xb2e0
movq %rax, %rbp
movq %rax, %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0x176bc
movq %rbp, (%rsp)
movq %rbx, 0x3a8(%rbp)
movl %r13d, 0x39c(%rbp)
movq 0x3b8(%rbx), %rsi
cmpq 0x3c0(%rbx), %rsi
je 0x17a95
movq %rbp, (%rsi)
addq $0x8, 0x3b8(%rbx)
jmp 0x17aa2
movq 0x8(%rsp), %rdi
movq %rsp, %rdx
callq 0x236de
incl %r13d
cmpl %r13d, %r12d
jne 0x17a4b
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0x17b87
movq %rax, %r14
jmp 0x17b91
movq %rax, %r14
jmp 0x17b9b
movq %rax, %r14
jmp 0x17ba5
movq %rax, %r14
jmp 0x17baf
movq %rax, %r14
movl $0x898, %esi            # imm = 0x898
movq %rbp, %rdi
callq 0xb2f0
jmp 0x17af8
jmp 0x17af5
movq %rax, %r14
leaq 0x820(%rbx), %r15
xorl %r12d, %r12d
leaq (%r15,%r12), %rdi
callq 0x220b8
addq $-0x50, %r12
cmpq $-0x3c0, %r12           # imm = 0xFC40
jne 0x17b02
jmp 0x17b3b
movq %rax, %r14
testq %r12, %r12
je 0x17b3b
negq %r12
leaq 0x460(%rbx), %r15
leaq (%r15,%r12), %rdi
callq 0x220b8
addq $-0x50, %r12
jne 0x17b2c
movq 0x10(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x17b57
movq 0x440(%rbx), %rsi
subq %rdi, %rsi
callq 0xb2f0
movq 0x18(%rsp), %rdi
callq 0x2381a
movq 0x8(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x17b7d
movq 0x3c0(%rbx), %rsi
subq %rdi, %rsi
callq 0xb2f0
movq 0x20(%rsp), %rdi
callq 0x219b2
movq 0x28(%rsp), %rdi
callq 0x219b2
movq 0x30(%rsp), %rdi
callq 0x219b2
movq 0x38(%rsp), %rdi
callq 0x219b2
movq 0x40(%rsp), %rdi
callq 0x219b2
movq %rbx, %rdi
callq 0x219b2
movq %r14, %rdi
callq 0xb510
nop