// File: /workspace/github_cpp_makefile_star2_O2/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 $0x58, %rsp
movl %edx, 0x4(%rsp)
movq %rsi, 0x8(%rsp)
movq %rdi, %rbx
callq 0x186fa
leaq 0x98(%rbx), %r14
movq %r14, %rdi
callq 0x186fa
leaq 0x130(%rbx), %r15
movq %r15, %rdi
movq %r14, 0x50(%rsp)
callq 0x186fa
leaq 0x1c8(%rbx), %r13
movq %r13, %rdi
movq %r15, 0x48(%rsp)
callq 0x186fa
leaq 0x260(%rbx), %rbp
movq %rbp, %rdi
movq %r13, 0x40(%rsp)
callq 0x186fa
movq %rbp, 0x38(%rsp)
leaq 0x2f8(%rbx), %rdi
movq %rdi, 0x30(%rsp)
callq 0x186fa
movq 0x8(%rsp), %rax
movq %rax, 0x390(%rbx)
movl 0x4(%rsp), %eax
movl %eax, 0x398(%rbx)
andl $0x0, 0x39c(%rbx)
leaq 0x3b0(%rbx), %rax
movq %rax, 0x18(%rsp)
andl $0x0, 0x3d8(%rbx)
leaq 0x3d8(%rbx), %rax
andq $0x0, 0x3e0(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x3a8(%rbx)
movups %xmm0, 0x3b8(%rbx)
movq %rax, 0x3e8(%rbx)
movq %rax, 0x3f0(%rbx)
andq $0x0, 0x3f8(%rbx)
leaq 0x3d0(%rbx), %rax
movq %rax, 0x28(%rsp)
andl $0x0, 0x400(%rbx)
leaq 0x430(%rbx), %rax
movq %rax, 0x20(%rsp)
pcmpeqd %xmm1, %xmm1
movdqu %xmm1, 0x408(%rbx)
movdqu %xmm1, 0x418(%rbx)
orq $-0x1, 0x428(%rbx)
leaq 0x4b0(%rbx), %rbp
movups %xmm0, 0x430(%rbx)
movups %xmm0, 0x440(%rbx)
xorl %r14d, %r14d
movq %rbp, %r13
movq %r13, %rdi
callq 0x18d38
addq $-0x50, %r14
addq $0x50, %r13
cmpq $-0x3c0, %r14           # imm = 0xFC40
jne 0x13e7e
movslq 0x4(%rsp), %rax
movq 0x8(%rsp), %rsi
movl 0x1b0(%rsi,%rax,4), %ecx
movl %ecx, 0x3c8(%rbx)
imulq $0x180, %rax, %rcx      # imm = 0x180
leaq (%rsi,%rcx), %rdx
addq $0x1e0, %rdx            # imm = 0x1E0
movq %rdx, 0x870(%rbx)
leaq 0x960(%rsi,%rcx), %rdx
movq %rdx, 0x878(%rbx)
leaq 0x10e0(%rsi,%rcx), %rdx
movq %rdx, 0x880(%rbx)
addq %rsi, %rcx
addq $0x1e00, %rcx           # imm = 0x1E00
movq %rcx, 0x888(%rbx)
imulq $0x120, %rax, %rax      # imm = 0x120
addq %rsi, %rax
addq $0x1860, %rax           # imm = 0x1860
movq %rax, 0x890(%rbx)
movl $0x450, %eax            # imm = 0x450
cmpq $0x4b0, %rax            # imm = 0x4B0
je 0x13f25
orq $-0x1, (%rbx,%rax)
addq $0x8, %rax
jmp 0x13f12
xorl %r14d, %r14d
leaq 0x10(%rsp), %r13
cmpq $0xc, %r14
je 0x13f7c
movq 0x890(%rbx), %rax
imulq $0x18, %r14, %rdx
movq (%rax,%rdx), %rcx
movq 0x8(%rax,%rdx), %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
je 0x13f5c
movl 0x4(%rcx), %esi
cmpl %esi, %eax
cmovlel %esi, %eax
addq $0x10, %rcx
jmp 0x13f49
testl %eax, %eax
je 0x13f77
imulq $0x50, %r14, %rdi
addq %rbp, %rdi
movl %eax, %esi
orq $-0x1, 0x10(%rsp)
movq %r13, %rdx
callq 0x1865c
incq %r14
jmp 0x13f2d
movl 0x4(%rsp), %eax
incl %eax
cmpl $0x3, %eax
je 0x13ff4
movl %eax, %r12d
cltq
movq 0x8(%rsp), %rcx
movl 0x272c(%rcx,%rax,4), %r14d
testl %r14d, %r14d
je 0x13ff4
xorl %r15d, %r15d
testl %r14d, %r14d
cmovlel %r15d, %r14d
leaq 0x10(%rsp), %r13
cmpl %r15d, %r14d
je 0x13ff4
movl $0x898, %edi            # imm = 0x898
callq 0xb2d0
movq %rax, %rbp
movq %rax, %rdi
movq 0x8(%rsp), %rsi
movl %r12d, %edx
callq 0x13d42
movq %rbp, 0x10(%rsp)
movq %rbx, 0x3a8(%rbp)
movl %r15d, 0x39c(%rbp)
movq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x186c6
incl %r15d
jmp 0x13fad
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
jmp 0x140ad
movq %rax, %r15
jmp 0x140b7
movq %rax, %r15
jmp 0x140c1
movq %rax, %r15
jmp 0x140cb
movq %rax, %r15
jmp 0x140d5
movq %rax, %r15
movl $0x898, %esi            # imm = 0x898
movq %rbp, %rdi
callq 0xb2e0
jmp 0x14042
jmp 0x1403f
movq %rax, %r15
leaq 0x820(%rbx), %r14
xorl %r12d, %r12d
leaq (%r14,%r12), %rdi
callq 0x18f40
addq $-0x50, %r12
cmpq $-0x3c0, %r12           # imm = 0xFC40
jne 0x1404c
jmp 0x14085
movq %rax, %r15
testq %r14, %r14
je 0x14085
negq %r14
leaq 0x460(%rbx), %r12
leaq (%r12,%r14), %rdi
callq 0x18f40
addq $-0x50, %r14
jne 0x14076
movq 0x20(%rsp), %rdi
callq 0x1a6ee
movq 0x28(%rsp), %rdi
callq 0x1a722
movq 0x18(%rsp), %rdi
callq 0x1a77a
movq 0x30(%rsp), %rdi
callq 0x186e4
movq 0x38(%rsp), %rdi
callq 0x186e4
movq 0x40(%rsp), %rdi
callq 0x186e4
movq 0x48(%rsp), %rdi
callq 0x186e4
movq 0x50(%rsp), %rdi
callq 0x186e4
movq %rbx, %rdi
callq 0x186e4
movq %r15, %rdi
callq 0xb4d0
nop