// File: /workspace/github_cpp_makefile_star2_O2/CMU-SAFARI[P]ramulator/src/Memory.h
// Function: ramulator::Memory<ramulator::DDR3, ramulator::Controller>::send(ramulator::Request)
bool send(Request req)
    {
        req.addr_vec.resize(addr_bits.size());
        long addr = req.addr;
        int coreid = req.coreid;

        // Each transaction size is 2^tx_bits, so first clear the lowest tx_bits bits
        clear_lower_bits(addr, tx_bits);

        if (use_mapping_file){
            apply_mapping(addr, req.addr_vec);
        }
        else {
            switch(int(type)){
                case int(Type::ChRaBaRoCo):
                    for (int i = addr_bits.size() - 1; i >= 0; i--)
                        req.addr_vec[i] = slice_lower_bits(addr, addr_bits[i]);
                    break;
                case int(Type::RoBaRaCoCh):
                    req.addr_vec[0] = slice_lower_bits(addr, addr_bits[0]);
                    req.addr_vec[addr_bits.size() - 1] = slice_lower_bits(addr, addr_bits[addr_bits.size() - 1]);
                    for (int i = 1; i <= int(T::Level::Row); i++)
                        req.addr_vec[i] = slice_lower_bits(addr, addr_bits[i]);
                    break;
                default:
                    assert(false);
            }
        }

        if(ctrls[req.addr_vec[0]]->enqueue(req)) {
            // tally stats here to avoid double counting for requests that aren't enqueued
            ++num_incoming_requests;
            if (req.type == Request::Type::READ) {
              ++num_read_requests[coreid];
              ++incoming_read_reqs_per_channel[req.addr_vec[int(T::Level::Channel)]];
            }
            if (req.type == Request::Type::WRITE) {
              ++num_write_requests[coreid];
            }
            ++incoming_requests_per_channel[req.addr_vec[int(T::Level::Channel)]];
            return true;
        }

        return false;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x10(%rsi), %r14
movq 0xc30(%rdi), %rsi
subq 0xc28(%rdi), %rsi
sarq $0x2, %rsi
movq %r14, %rdi
callq 0x2149e
movq 0x8(%r15), %rsi
movb 0xc64(%rbx), %cl
sarq %cl, %rsi
movl 0x28(%r15), %ebp
cmpb $0x1, 0xc60(%rbx)
jne 0x1d78f
movq %rbx, %rdi
movq %r14, %rdx
callq 0x214d0
movq 0x10(%r15), %rax
movslq (%rax), %rax
movq 0xc08(%rbx), %rcx
movq (%rcx,%rax,8), %rdi
movq %r15, %rsi
callq 0x1fe4c
movl %eax, %r12d
testb %al, %al
je 0x1d783
movsd 0x1a8(%rbx), %xmm0
addsd 0xb3998(%rip), %xmm0    # 0xd1078
movsd %xmm0, 0x1a8(%rbx)
movl 0x2c(%r15), %eax
testl %eax, %eax
jne 0x1d738
leaq 0x1d0(%rbx), %rdi
movl %ebp, %esi
callq 0x21130
movsd 0x70(%rax), %xmm0
addsd 0xb396d(%rip), %xmm0    # 0xd1078
movsd %xmm0, 0x70(%rax)
leaq 0x478(%rbx), %rdi
movq 0x10(%r15), %rax
movl (%rax), %esi
callq 0x21130
movsd 0xb394e(%rip), %xmm0    # 0xd1078
addsd 0x70(%rax), %xmm0
movsd %xmm0, 0x70(%rax)
movl 0x2c(%r15), %eax
cmpl $0x1, %eax
jne 0x1d75d
leaq 0x280(%rbx), %rdi
movl %ebp, %esi
callq 0x21130
movsd 0x70(%rax), %xmm0
addsd 0xb3920(%rip), %xmm0    # 0xd1078
movsd %xmm0, 0x70(%rax)
addq $0x3c8, %rbx            # imm = 0x3C8
movq (%r14), %rax
movl (%rax), %esi
movq %rbx, %rdi
callq 0x21130
movsd 0x70(%rax), %xmm0
addsd 0xb38fa(%rip), %xmm0    # 0xd1078
movsd %xmm0, 0x70(%rax)
movl %r12d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl 0xb80(%rbx), %eax
cmpl $0x1, %eax
je 0x1d7f7
testl %eax, %eax
jne 0x1d86a
movq 0xc28(%rbx), %rax
movq 0xc30(%rbx), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
movl %ecx, %edx
decq %rdx
pushq $-0x1
popq %rdi
testl %edx, %edx
js 0x1d6ab
movl %edx, %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
shlq $0x2, %r8
movb (%rax,%r8), %cl
movl %edi, %r9d
shll %cl, %r9d
notl %r9d
movl %esi, %r10d
sarq %cl, %rsi
andl %r9d, %r10d
movq (%r14), %rcx
movl %r10d, (%rcx,%r8)
decq %rdx
jmp 0x1d7bf
movq 0xc28(%rbx), %rax
movb (%rax), %cl
pushq $-0x1
popq %rdx
movl %edx, %edi
shll %cl, %edi
notl %edi
movl %esi, %r8d
sarq %cl, %rsi
andl %edi, %r8d
movq (%r14), %rdi
movl %r8d, (%rdi)
movq 0xc30(%rbx), %r8
movb -0x4(%r8), %cl
subq %rax, %r8
movl %edx, %r9d
shll %cl, %r9d
movl %esi, %r10d
sarq %cl, %rsi
notl %r9d
andl %r9d, %r10d
movl %r10d, -0x4(%rdi,%r8)
pushq $0x1
popq %r8
cmpq $0x4, %r8
je 0x1d6ab
movb (%rax,%r8,4), %cl
movl %edx, %r9d
shll %cl, %r9d
movl %esi, %r10d
sarq %cl, %rsi
notl %r9d
andl %r9d, %r10d
movl %r10d, (%rdi,%r8,4)
incq %r8
jmp 0x1d841
leaq 0xb3ae8(%rip), %rdi     # 0xd1359
leaq 0xb4939(%rip), %rsi     # 0xd21b1
leaq 0xb553d(%rip), %rcx     # 0xd2dbc
movl $0x14b, %edx            # imm = 0x14B
callq 0xb210
nop