// File: /workspace/github_cpp_makefile_star2_O3/yangwanyuan[P]HLKVDS/./src/include/LRUMap.h
// Function: dslab::LRUMap<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>::Put(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, bool)
bool LRUMap<K,D>::Put(K key , D data, K& update_key, D& update_data, bool same){
    update_key = K();
    update_data = D();
    Node<K,D> *node = cached_map[key];
    bool poped;
    if(node){//key exist
        detach(node);
	if(!same){
	        node->data = data;
	}
        attach(node);
	poped = false;//no data poped out
    }
    else{
        if(free_entries.empty()){
            node = tail->prev;
	    update_key = node->key;
	    update_data = node->data;
            detach(node);
            cached_map.erase(node->key);
	    poped = true;//data poped out
        }
        else{
            node = free_entries.back();
            free_entries.pop_back();
	    poped = false;//no data poped out
        }
        node->key = key;
        node->data = data;
        cached_map[key] = node;
        attach(node);
    }
    return poped;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r9d, 0xc(%rsp)
movq %r8, %r13
movq %rcx, %r14
movq %rdx, 0x10(%rsp)
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x28(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq $0x0, -0x8(%rbp)
movb $0x0, (%rbp)
leaq 0x18(%rsp), %r12
movq %rcx, %rdi
movq %r12, %rsi
callq 0x64a0
movq (%r12), %rdi
cmpq %rbp, %rdi
je 0x18ceb
callq 0x63f0
leaq 0x18(%rsp), %r12
movq %rbp, (%r12)
movq $0x0, 0x8(%r12)
movb $0x0, 0x10(%r12)
movq %r13, %rdi
movq %r12, %rsi
callq 0x64a0
movq (%r12), %rdi
cmpq %rbp, %rdi
je 0x18d1c
callq 0x63f0
leaq 0x8(%rbx), %rbp
movq %rbp, %rdi
movq %r15, %rsi
callq 0x1911a
movq (%rax), %r12
testq %r12, %r12
je 0x18d78
movq 0x40(%r12), %rax
movq 0x48(%r12), %rcx
movq %rcx, 0x48(%rax)
movq %rax, 0x40(%rcx)
cmpb $0x0, 0xc(%rsp)
jne 0x18d5b
leaq 0x20(%r12), %rdi
movq 0x10(%rsp), %rsi
callq 0x6240
movq 0x58(%rbx), %rax
movq %rax, 0x40(%r12)
movq 0x48(%rax), %rcx
movq %rcx, 0x48(%r12)
movq %r12, 0x48(%rax)
xorl %eax, %eax
jmp 0x18e16
movq 0x48(%rbx), %rax
cmpq %rax, 0x40(%rbx)
sete %cl
movl %ecx, 0xc(%rsp)
je 0x18d97
movq -0x8(%rax), %r12
addq $-0x8, %rax
movq %rax, 0x48(%rbx)
jmp 0x18dd4
movq 0x60(%rbx), %rax
movq 0x40(%rax), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x6240
leaq 0x20(%r12), %rsi
movq %r13, %rdi
callq 0x6240
movq 0x40(%r12), %rax
movq 0x48(%r12), %rcx
movq %rcx, 0x48(%rax)
movq %rax, 0x40(%rcx)
movq %rbp, %rdi
movq %r12, %rsi
callq 0x1954a
movq %r12, %rdi
movq %r15, %rsi
callq 0x6240
leaq 0x20(%r12), %rdi
movq 0x10(%rsp), %rsi
callq 0x6240
movq %rbp, %rdi
movq %r15, %rsi
callq 0x1911a
movq %r12, (%rax)
movq 0x58(%rbx), %rax
movq %rax, 0x40(%r12)
movq 0x48(%rax), %rcx
movq %rcx, 0x48(%r12)
movq %r12, 0x48(%rax)
movl 0xc(%rsp), %eax
movq 0x48(%r12), %rcx
movq %r12, 0x40(%rcx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq