// File: CMU-SAFARI[P]ramulator/src/MemoryFactory.h
// Function: ramulator::MemoryFactory<ramulator::WideIO2>::populate_memory(ramulator::Config const&, ramulator::WideIO2*, int, int)
static Memory<T> *populate_memory(const Config& configs, T *spec, int channels, int ranks) {
        int& default_ranks = spec->org_entry.count[int(T::Level::Rank)];
        int& default_channels = spec->org_entry.count[int(T::Level::Channel)];

        if (default_channels == 0) default_channels = channels;
        if (default_ranks == 0) default_ranks = ranks;

        vector<Controller<T> *> ctrls;
        for (int c = 0; c < channels; c++){
            DRAM<T>* channel = new DRAM<T>(spec, T::Level::Channel);
            channel->id = c;
            channel->regStats("");
            ctrls.push_back(new Controller<T>(configs, channel));
        }
        return new Memory<T>(configs, ctrls);
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq -0x10(%rbp), %rax
addq $0x2898, %rax           # imm = 0x2898
addq $0x8, %rax
addq $0x4, %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
addq $0x2898, %rax           # imm = 0x2898
addq $0x8, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x1e95f3
movl -0x14(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x1e9605
movl -0x18(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
leaq -0x40(%rbp), %rdi
callq 0xec010
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x1e97a0
movl $0x8f0, %edi            # imm = 0x8F0
callq 0xc360
movq %rax, -0xb8(%rbp)
jmp 0x1e9634
movq -0xb8(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %edx, %edx
callq 0xec030
jmp 0x1e9648
movq -0xb8(%rbp), %rax
movq %rax, -0x50(%rbp)
movl -0x44(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x39c(%rax)
movq -0x50(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0xc5e0
movq -0xc0(%rbp), %rdx
leaq 0x679c6(%rip), %rsi     # 0x251052
leaq -0x80(%rbp), %rdi
callq 0x17a40
jmp 0x1e9697
movq -0xc8(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0xec610
jmp 0x1e96a9
leaq -0x80(%rbp), %rdi
callq 0xc6b8
leaq -0x81(%rbp), %rdi
callq 0xc3c0
movl $0x11e0, %edi           # imm = 0x11E0
callq 0xc360
movq %rax, -0xd0(%rbp)
jmp 0x1e96d1
movq -0xd0(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0xed6b0
jmp 0x1e96e7
movq -0xd0(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x1e9ca0
jmp 0x1e9707
jmp 0x1e9709
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x1e9615
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1e9863
movq -0xb8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
movl $0x8f0, %esi            # imm = 0x8F0
callq 0xc370
jmp 0x1e9863
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1e976d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0xc6b8
leaq -0x81(%rbp), %rdi
callq 0xc3c0
jmp 0x1e9863
movq -0xd0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
movl $0x11e0, %esi           # imm = 0x11E0
callq 0xc370
jmp 0x1e9863
movl $0xc68, %edi            # imm = 0xC68
callq 0xc360
movq %rax, -0xd8(%rbp)
jmp 0x1e97b3
movb $0x1, -0xa9(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0xf0c30
jmp 0x1e97d7
movq -0xe0(%rbp), %rsi
movq -0xd8(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
callq 0xf0d20
jmp 0x1e97f3
movb $0x0, -0xa9(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0xf34d0
leaq -0x40(%rbp), %rdi
callq 0xf34d0
movq -0xd8(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1e9845
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0xf34d0
testb $0x1, -0xa9(%rbp)
jne 0x1e9850
jmp 0x1e9861
movq -0xd8(%rbp), %rdi
movl $0xc68, %esi            # imm = 0xC68
callq 0xc370
jmp 0x1e9863
leaq -0x40(%rbp), %rdi
callq 0xf34d0
movq -0x58(%rbp), %rdi
callq 0xc5d0
nopw %cs:(%rax,%rax)
nop