// File: /workspace/github_cpp_makefile_star2_O2/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, (%rsp)
movq %r8, %r13
movq %rdx, 0x8(%rsp)
leaq 0x28(%rsp), %r12
movq %r12, -0x10(%r12)
andq $0x0, -0x8(%r12)
movq %rsi, %r15
movq %rdi, %rbx
xorl %ebp, %ebp
movb %bpl, (%r12)
leaq 0x18(%rsp), %r14
movq %rcx, 0x10(%rsp)
movq %rcx, %rdi
movq %r14, %rsi
callq 0x6490
movq %r14, %rdi
callq 0x6788
movq %r12, (%r14)
andq $0x0, 0x8(%r14)
movb %bpl, 0x10(%r14)
leaq 0x18(%rsp), %r14
movq %r13, %rdi
movq %r14, %rsi
callq 0x6490
movq %r14, %rdi
callq 0x6788
leaq 0x8(%rbx), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x1642a
movq (%rax), %r12
testq %r12, %r12
je 0x1604f
movq 0x40(%r12), %rax
movq 0x48(%r12), %rcx
movq %rcx, 0x48(%rax)
movq %rax, 0x40(%rcx)
cmpb $0x0, (%rsp)
jne 0x16031
leaq 0x20(%r12), %rdi
movq 0x8(%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 %r13d, %r13d
jmp 0x160ed
movq 0x10(%rsp), %rdi
movq %r13, (%rsp)
movq 0x48(%rbx), %rax
cmpq %rax, 0x40(%rbx)
sete %r13b
je 0x16074
movq -0x8(%rax), %r12
addq $-0x8, %rax
movq %rax, 0x48(%rbx)
jmp 0x160af
movq 0x60(%rbx), %rax
movq 0x40(%rax), %r12
movq %r12, %rsi
callq 0x6240
leaq 0x20(%r12), %rsi
movq (%rsp), %rdi
callq 0x6240
movq 0x40(%r12), %rax
movq 0x48(%r12), %rcx
movq %rcx, 0x48(%rax)
movq %rax, 0x40(%rcx)
movq %r14, %rdi
movq %r12, %rsi
callq 0x16874
movq %r12, %rdi
movq %r15, %rsi
callq 0x6240
leaq 0x20(%r12), %rdi
movq 0x8(%rsp), %rsi
callq 0x6240
movq %r14, %rdi
movq %r15, %rsi
callq 0x1642a
movq %r12, (%rax)
movq 0x58(%rbx), %rax
movq %rax, 0x40(%r12)
movq 0x48(%rax), %rcx
movq %rcx, 0x48(%r12)
movq %r12, 0x48(%rax)
movq 0x48(%r12), %rax
movq %r12, 0x40(%rax)
movl %r13d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq