// File: /workspace/github_cpp_makefile_star2_O1/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 0x2ae26
movq 0x8(%r15), %rsi
movb 0xc64(%rbx), %cl
sarq %cl, %rsi
movl 0x28(%r15), %ebp
cmpb $0x1, 0xc60(%rbx)
jne 0x26a68
movq %rbx, %rdi
movq %r14, %rdx
callq 0x2ae58
jmp 0x26b35
movl 0xb80(%rbx), %eax
cmpl $0x1, %eax
je 0x26ac5
testl %eax, %eax
jne 0x26c15
movq 0xc28(%rbx), %rax
movq 0xc30(%rbx), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
decl %ecx
js 0x26b35
movq (%r14), %rdx
movl %ecx, %edi
incq %rdi
movb -0x4(%rax,%rdi,4), %cl
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
shll %cl, %r8d
movl %esi, %r9d
sarq %cl, %rsi
notl %r8d
andl %r8d, %r9d
movl %r9d, -0x4(%rdx,%rdi,4)
decq %rdi
jg 0x26aa0
jmp 0x26b35
movq 0xc28(%rbx), %rax
movb (%rax), %cl
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
shll %cl, %edx
movl %esi, %r8d
sarq %cl, %rsi
notl %edx
andl %edx, %r8d
movq (%r14), %rdx
movl %r8d, (%rdx)
movq 0xc30(%rbx), %r8
movb -0x4(%r8), %cl
subq %rax, %r8
shll %cl, %edi
movl %esi, %r9d
sarq %cl, %rsi
notl %edi
andl %edi, %r9d
movl %r9d, -0x4(%rdx,%r8)
movl $0x1, %edi
movb (%rax,%rdi,4), %cl
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
shll %cl, %r8d
notl %r8d
movl %esi, %r9d
sarq %cl, %rsi
andl %r8d, %r9d
movl %r9d, (%rdx,%rdi,4)
incq %rdi
cmpq $0x4, %rdi
jne 0x26b10
movq 0x10(%r15), %rax
movslq (%rax), %rax
movq 0xc08(%rbx), %rcx
movq (%rcx,%rax,8), %rdi
movq %r15, %rsi
callq 0x29416
movl %eax, %r12d
testb %al, %al
je 0x26c09
movsd 0x1a8(%rbx), %xmm0
addsd 0x12650e(%rip), %xmm0   # 0x14d078
movsd %xmm0, 0x1a8(%rbx)
cmpl $0x0, 0x2c(%r15)
jne 0x26bbc
leaq 0x1d0(%rbx), %rdi
movl %ebp, %esi
callq 0x2aa1c
movsd 0x70(%rax), %xmm0
addsd 0x1264e4(%rip), %xmm0   # 0x14d078
movsd %xmm0, 0x70(%rax)
leaq 0x478(%rbx), %rdi
movq (%r14), %rax
movl (%rax), %esi
callq 0x2aa1c
movsd 0x1264c6(%rip), %xmm0   # 0x14d078
addsd 0x70(%rax), %xmm0
movsd %xmm0, 0x70(%rax)
cmpl $0x1, 0x2c(%r15)
jne 0x26be3
leaq 0x280(%rbx), %rdi
movl %ebp, %esi
callq 0x2aa1c
movsd 0x70(%rax), %xmm0
addsd 0x12649a(%rip), %xmm0   # 0x14d078
movsd %xmm0, 0x70(%rax)
addq $0x3c8, %rbx            # imm = 0x3C8
movq (%r14), %rax
movl (%rax), %esi
movq %rbx, %rdi
callq 0x2aa1c
movsd 0x70(%rax), %xmm0
addsd 0x126474(%rip), %xmm0   # 0x14d078
movsd %xmm0, 0x70(%rax)
movl %r12d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x12673d(%rip), %rdi    # 0x14d359
leaq 0x12758e(%rip), %rsi    # 0x14e1b1
leaq 0x1281d6(%rip), %rcx    # 0x14ee00
movl $0x14b, %edx            # imm = 0x14B
callq 0xb200