// File: zkl94[P]distributed-key-value-store/MP2Node.cpp
// Function: MP2Node::findNodes(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
vector<Node> MP2Node::findNodes(string key) {
    size_t pos = hashFunction(key);
    vector<Node> addr_vec;
    if (ring.size() >= 3) {
        // if pos <= min || pos > max, the leader is the min
        if (pos <= ring.at(0).getHashCode() || pos > ring.at(ring.size() - 1).getHashCode()) {
            addr_vec.emplace_back(ring.at(0));
            addr_vec.emplace_back(ring.at(1));
            addr_vec.emplace_back(ring.at(2));
        } else {
            // go through the ring until pos <= node
            for (int i = 1; i < ring.size(); i++) {
                Node addr = ring.at(i);
                if (pos <= addr.getHashCode()) {
                    addr_vec.emplace_back(addr);
                    addr_vec.emplace_back(ring.at((i + 1) % ring.size()));
                    addr_vec.emplace_back(ring.at((i + 2) % ring.size()));
                    break;
                }
            }
        }
    }
    return addr_vec;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdx, -0xa8(%rbp)
movq %rsi, %rax
movq -0xa8(%rbp), %rsi
movq %rdi, -0x90(%rbp)
movq %rdi, %rcx
movq %rcx, -0xa0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rax, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x4150
movq -0x88(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1a880
movq %rax, -0x98(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x41e0
movq -0x98(%rbp), %rax
movq -0x90(%rbp), %rdi
movq %rax, -0x20(%rbp)
movb $0x0, -0x41(%rbp)
callq 0x10bf0
movq -0x88(%rbp), %rdi
addq $0x30, %rdi
callq 0x10cc0
cmpq $0x3, %rax
jb 0x1b435
movq -0x88(%rbp), %rdi
movq -0x20(%rbp), %rax
movq %rax, -0xb8(%rbp)
addq $0x30, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x10d70
movq %rax, -0xb0(%rbp)
jmp 0x1b13a
movq -0xb0(%rbp), %rdi
callq 0x23820
movq %rax, -0xc0(%rbp)
jmp 0x1b14f
movq -0xb8(%rbp), %rax
movq -0xc0(%rbp), %rcx
cmpq %rcx, %rax
jbe 0x1b1cb
movq -0x88(%rbp), %rdi
movq -0x20(%rbp), %rax
movq %rax, -0xd8(%rbp)
addq $0x30, %rdi
movq %rdi, -0xd0(%rbp)
callq 0x10cc0
movq -0xd0(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x10d70
movq %rax, -0xc8(%rbp)
jmp 0x1b19f
movq -0xc8(%rbp), %rdi
callq 0x23820
movq %rax, -0xe0(%rbp)
jmp 0x1b1b4
movq -0xd8(%rbp), %rax
movq -0xe0(%rbp), %rcx
cmpq %rcx, %rax
jbe 0x1b279
movq -0x88(%rbp), %rdi
addq $0x30, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x10d70
movq %rax, -0xe8(%rbp)
jmp 0x1b1e8
movq -0xe8(%rbp), %rsi
movq -0x90(%rbp), %rdi
callq 0x1ed50
jmp 0x1b1fd
movq -0x88(%rbp), %rdi
addq $0x30, %rdi
movl $0x1, %esi
callq 0x10d70
movq %rax, -0xf0(%rbp)
jmp 0x1b21b
movq -0xf0(%rbp), %rsi
movq -0x90(%rbp), %rdi
callq 0x1ed50
jmp 0x1b230
movq -0x88(%rbp), %rdi
addq $0x30, %rdi
movl $0x2, %esi
callq 0x10d70
movq %rax, -0xf8(%rbp)
jmp 0x1b24e
movq -0xf8(%rbp), %rsi
movq -0x90(%rbp), %rdi
callq 0x1ed50
jmp 0x1b263
jmp 0x1b433
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1b462
movl $0x1, -0x58(%rbp)
movq -0x88(%rbp), %rdi
movslq -0x58(%rbp), %rax
movq %rax, -0x100(%rbp)
addq $0x30, %rdi
callq 0x10cc0
movq %rax, %rcx
movq -0x100(%rbp), %rax
cmpq %rcx, %rax
jae 0x1b431
movq -0x88(%rbp), %rdi
addq $0x30, %rdi
movslq -0x58(%rbp), %rsi
callq 0x10d70
movq %rax, -0x108(%rbp)
jmp 0x1b2cb
movq -0x108(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x23750
jmp 0x1b2dd
movq -0x20(%rbp), %rax
movq %rax, -0x118(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x23820
movq %rax, -0x110(%rbp)
jmp 0x1b2fa
movq -0x118(%rbp), %rax
movq -0x110(%rbp), %rcx
cmpq %rcx, %rax
ja 0x1b406
movq -0x90(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x1ed50
jmp 0x1b323
movq -0x88(%rbp), %rdi
addq $0x30, %rdi
movq %rdi, -0x130(%rbp)
movl -0x58(%rbp), %eax
incl %eax
cltq
movq %rax, -0x128(%rbp)
callq 0x10cc0
movq -0x130(%rbp), %rdi
movq %rax, %rcx
movq -0x128(%rbp), %rax
xorl %edx, %edx
divq %rcx
movq %rdx, %rsi
callq 0x10d70
movq %rax, -0x120(%rbp)
jmp 0x1b36f
movq -0x120(%rbp), %rsi
movq -0x90(%rbp), %rdi
callq 0x1ed50
jmp 0x1b384
movq -0x88(%rbp), %rdi
addq $0x30, %rdi
movq %rdi, -0x148(%rbp)
movl -0x58(%rbp), %eax
addl $0x2, %eax
cltq
movq %rax, -0x140(%rbp)
callq 0x10cc0
movq -0x148(%rbp), %rdi
movq %rax, %rcx
movq -0x140(%rbp), %rax
xorl %edx, %edx
divq %rcx
movq %rdx, %rsi
callq 0x10d70
movq %rax, -0x138(%rbp)
jmp 0x1b3d1
movq -0x138(%rbp), %rsi
movq -0x90(%rbp), %rdi
callq 0x1ed50
jmp 0x1b3e6
movl $0x2, -0x7c(%rbp)
jmp 0x1b40d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x23710
jmp 0x1b462
movl $0x0, -0x7c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x23710
movl -0x7c(%rbp), %eax
testl %eax, %eax
je 0x1b421
jmp 0x1b41f
jmp 0x1b431
jmp 0x1b423
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x1b280
jmp 0x1b433
jmp 0x1b435
movb $0x1, -0x41(%rbp)
movl $0x1, -0x7c(%rbp)
testb $0x1, -0x41(%rbp)
jne 0x1b452
movq -0x90(%rbp), %rdi
callq 0x10c60
movq -0xa0(%rbp), %rax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x90(%rbp), %rdi
callq 0x10c60
movq -0x50(%rbp), %rdi
callq 0x4550
nopw (%rax,%rax)