// File: yasz24[P]eau2/src/network/./../application/../store/kvstore.h
// Function: KVStore::get(Key*)
Value* get(Key* key) {
        store_mtx_.lock();
        size_t target = key->node();
        //std::cout << "get: " << "key: " << key->serialize() << "\n";
        Value* val = nullptr;
        if (target == this_node_) {
            std::map<Key*, Value*, KeyCompare>::iterator iter;
            iter = local_store_.find(key);
            if (iter != local_store_.end()) {
                val = iter->second;
            }
        } else {
            Get get(key, this_node_, target, network_->msg_id);
            network_->send_msg(&get); // send get msg over the network to appropriate KVStore.
            store_mtx_.wait();
            Message* m = received_msg;
            //expect Reply or Nack.
            if (m->kind_ == MsgKind::Reply) {
                Reply* resp = dynamic_cast<Reply*>(m);
                char* serializedValue = resp->reply_msg_;
                val = new Value(serializedValue, this);
            } else if (m->kind_ == MsgKind::Nack) {
                std::cout << "unable to get key from node " << target <<"\n";
            }
            received_msg = nullptr;
        }
        store_mtx_.unlock();
        return val;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
addq $0x58, %rdi
callq 0x11df0
movq -0x10(%rbp), %rdi
callq 0x11e10
movq -0xa0(%rbp), %rcx
movq %rax, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpq 0x18(%rcx), %rax
jne 0x117f3
leaq -0x28(%rbp), %rdi
callq 0x11e30
movq -0xa0(%rbp), %rdi
addq $0x20, %rdi
leaq -0x10(%rbp), %rsi
callq 0x11e50
movq -0xa0(%rbp), %rdi
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
addq $0x20, %rdi
callq 0x11eb0
movq %rax, -0x38(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x11e80
testb $0x1, %al
jne 0x117dd
jmp 0x117ee
leaq -0x28(%rbp), %rdi
callq 0x11ee0
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x119c3
movq -0xa0(%rbp), %rax
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rcx
movq 0x18(%rax), %rdx
movq 0x50(%rax), %rax
movq 0x40(%rax), %r8
leaq -0x70(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x11f00
movq -0xa0(%rbp), %rax
movq -0xa8(%rbp), %rsi
movq 0x50(%rax), %rdi
movq (%rdi), %rax
movq 0x50(%rax), %rax
callq *%rax
jmp 0x1183b
movq -0xa0(%rbp), %rdi
addq $0x58, %rdi
callq 0x11f70
jmp 0x1184d
movq -0xa0(%rbp), %rax
movq 0xd0(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
cmpl $0x3, 0x10(%rax)
jne 0x11940
movq -0x88(%rbp), %rax
movq %rax, -0xb0(%rbp)
cmpq $0x0, %rax
je 0x118bf
movq -0xb0(%rbp), %rdi
leaq 0x28933(%rip), %rsi     # 0x3a1c8
leaq 0x2940c(%rip), %rdx     # 0x3aca8
xorl %eax, %eax
movl %eax, %ecx
callq 0x82f0
movq %rax, -0xb8(%rbp)
jmp 0x118ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x119b8
xorl %eax, %eax
movq %rax, -0xb8(%rbp)
jmp 0x118ca
movq -0xb8(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x98(%rbp)
movl $0x20, %edi
callq 0x8290
movq %rax, -0xc0(%rbp)
jmp 0x118fd
movq -0xa0(%rbp), %rdx
movq -0xc0(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x11fa0
jmp 0x11919
movq -0xc0(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x1199b
movq -0xc0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
callq 0x8260
jmp 0x119b8
movq -0x88(%rbp), %rax
cmpl $0x1, 0x10(%rax)
jne 0x11999
movq 0x2a66c(%rip), %rdi     # 0x3bfc0
leaq 0x1aca5(%rip), %rsi     # 0x2c600
callq 0x8280
movq %rax, -0xc8(%rbp)
jmp 0x11969
movq -0xc8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x80a0
movq %rax, -0xd0(%rbp)
jmp 0x11982
movq -0xd0(%rbp), %rdi
leaq 0x1a79d(%rip), %rsi     # 0x2c12d
callq 0x8280
jmp 0x11997
jmp 0x11999
jmp 0x1199b
movq -0xa0(%rbp), %rax
movq $0x0, 0xd0(%rax)
leaq -0x70(%rbp), %rdi
callq 0x121c0
jmp 0x119c3
leaq -0x70(%rbp), %rdi
callq 0x121c0
jmp 0x119e0
movq -0xa0(%rbp), %rdi
addq $0x58, %rdi
callq 0x121e0
movq -0x20(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x8400
nopl (%rax)