// File: /workspace/github_cpp_makefile_star2_O3/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 0x2b058
movq 0x8(%r15), %rsi
movb 0xc64(%rbx), %cl
sarq %cl, %rsi
movl 0x28(%r15), %ebp
cmpb $0x1, 0xc60(%rbx)
jne 0x26aa3
movq %rbx, %rdi
movq %r14, %rdx
callq 0x2b08a
movq (%r14), %rax
jmp 0x26b6c
movl 0xb80(%rbx), %eax
cmpl $0x1, %eax
je 0x26afc
testl %eax, %eax
jne 0x26c4c
movq 0xc28(%rbx), %rdx
movq 0xc30(%rbx), %rcx
subq %rdx, %rcx
shrq $0x2, %rcx
decl %ecx
movq (%r14), %rax
js 0x26b6c
movl %ecx, %edi
movb (%rdx,%rdi,4), %cl
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
shll %cl, %r8d
movl %esi, %r9d
sarq %cl, %rsi
notl %r8d
andl %r8d, %r9d
movl %r9d, (%rax,%rdi,4)
addq $-0x1, %rdi
jb 0x26ad8
jmp 0x26b6c
movq 0xc28(%rbx), %rdx
movb (%rdx), %cl
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
shll %cl, %eax
movl %esi, %r8d
sarq %cl, %rsi
notl %eax
andl %eax, %r8d
movq (%r14), %rax
movl %r8d, (%rax)
movq 0xc30(%rbx), %r8
movb -0x4(%r8), %cl
subq %rdx, %r8
shll %cl, %edi
movl %esi, %r9d
sarq %cl, %rsi
notl %edi
andl %edi, %r9d
movl %r9d, -0x4(%rax,%r8)
movl $0x1, %edi
movb (%rdx,%rdi,4), %cl
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
shll %cl, %r8d
notl %r8d
movl %esi, %r9d
sarq %cl, %rsi
andl %r8d, %r9d
movl %r9d, (%rax,%rdi,4)
incq %rdi
cmpq $0x4, %rdi
jne 0x26b47
movslq (%rax), %rax
movq 0xc08(%rbx), %rcx
movq (%rcx,%rax,8), %rdi
movq %r15, %rsi
callq 0x297e6
movl %eax, %r12d
testb %al, %al
je 0x26c40
movsd 0x1a8(%rbx), %xmm0
addsd 0x12351b(%rip), %xmm0   # 0x14a0b8
movsd %xmm0, 0x1a8(%rbx)
movl 0x2c(%r15), %eax
testl %eax, %eax
jne 0x26bf5
leaq 0x1d0(%rbx), %rdi
movl %ebp, %esi
callq 0x2ac3a
movsd 0x70(%rax), %xmm0
addsd 0x1234f0(%rip), %xmm0   # 0x14a0b8
movsd %xmm0, 0x70(%rax)
leaq 0x478(%rbx), %rdi
movq 0x10(%r15), %rax
movl (%rax), %esi
callq 0x2ac3a
movsd 0x1234d1(%rip), %xmm0   # 0x14a0b8
addsd 0x70(%rax), %xmm0
movsd %xmm0, 0x70(%rax)
movl 0x2c(%r15), %eax
cmpl $0x1, %eax
jne 0x26c1a
leaq 0x280(%rbx), %rdi
movl %ebp, %esi
callq 0x2ac3a
movsd 0x70(%rax), %xmm0
addsd 0x1234a3(%rip), %xmm0   # 0x14a0b8
movsd %xmm0, 0x70(%rax)
addq $0x3c8, %rbx            # imm = 0x3C8
movq (%r14), %rax
movl (%rax), %esi
movq %rbx, %rdi
callq 0x2ac3a
movsd 0x70(%rax), %xmm0
addsd 0x12347d(%rip), %xmm0   # 0x14a0b8
movsd %xmm0, 0x70(%rax)
movl %r12d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x123746(%rip), %rdi    # 0x14a399
leaq 0x124597(%rip), %rsi    # 0x14b1f1
leaq 0x1251df(%rip), %rcx    # 0x14be40
movl $0x14b, %edx            # imm = 0x14B
callq 0xb200
nop