// File: /workspace/github_cpp_makefile_star2_O3/tonymuu[P]distributed-kv-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 < (int)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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x5a4e
movq (%r15), %rdi
movq 0x8(%r15), %rsi
movl $0xc70f6907, %edx       # imm = 0xC70F6907
callq 0x3090
movq %rax, %r15
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0xf9a0
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32c0
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movq 0x30(%r14), %rdi
movq 0x38(%r14), %rax
subq %rdi, %rax
cmpq $0x41, %rax
jb 0xfa64
callq 0x1398a
andl $0x1ff, %r15d           # imm = 0x1FF
cmpq %rax, %r15
jbe 0xfa04
movq 0x30(%r14), %rdi
movq 0x38(%r14), %rax
movq %rax, %rdx
subq %rdi, %rdx
sarq $0x5, %rdx
leaq -0x1(%rdx), %rsi
cmpq %rdi, %rax
je 0xfb86
shlq $0x5, %rsi
addq %rsi, %rdi
callq 0x1398a
cmpq %rax, %r15
jbe 0xfa76
movq 0x30(%r14), %rsi
cmpq %rsi, 0x38(%r14)
je 0xfb74
movq %rbx, %rdi
callq 0x126fa
movq 0x30(%r14), %rsi
movq 0x38(%r14), %rdx
subq %rsi, %rdx
sarq $0x5, %rdx
cmpq $0x2, %rdx
jb 0xfb7a
addq $0x20, %rsi
movq %rbx, %rdi
callq 0x126fa
movq 0x30(%r14), %rsi
movq 0x38(%r14), %rdx
subq %rsi, %rdx
sarq $0x5, %rdx
cmpq $0x2, %rdx
jbe 0xfb81
addq $0x40, %rsi
movq %rbx, %rdi
callq 0x126fa
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x30(%r14), %rsi
movq 0x38(%r14), %rdx
subq %rsi, %rdx
sarq $0x5, %rdx
cmpl $0x2, %edx
jl 0xfa64
movl $0x3, %r12d
movl $0x20, %ebp
leaq 0x8(%rsp), %r13
leaq -0x2(%r12), %rax
cmpq %rax, %rdx
jbe 0xfb63
addq %rbp, %rsi
movq %r13, %rdi
callq 0x13914
movq %r13, %rdi
callq 0x1398a
cmpq %rax, %r15
jbe 0xfaf9
movq %r13, %rdi
callq 0x13908
movq 0x30(%r14), %rsi
movq 0x38(%r14), %rax
subq %rsi, %rax
movq %rax, %rdx
sarq $0x5, %rdx
shrq $0x5, %rax
cltq
leaq 0x1(%r12), %rcx
decq %r12
addq $0x20, %rbp
cmpq %rax, %r12
movq %rcx, %r12
jl 0xfa9a
jmp 0xfa64
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x126fa
leaq -0x1(%r12), %rax
movq 0x30(%r14), %rsi
movq 0x38(%r14), %rcx
subq %rsi, %rcx
sarq $0x5, %rcx
xorl %edx, %edx
divq %rcx
shlq $0x5, %rdx
addq %rdx, %rsi
movq %rbx, %rdi
callq 0x126fa
movq 0x30(%r14), %rsi
movq 0x38(%r14), %rcx
subq %rsi, %rcx
sarq $0x5, %rcx
movq %r12, %rax
xorl %edx, %edx
divq %rcx
shlq $0x5, %rdx
addq %rdx, %rsi
movq %rbx, %rdi
callq 0x126fa
leaq 0x8(%rsp), %rdi
callq 0x13908
jmp 0xfa64
leaq 0x7c04(%rip), %rdi      # 0x1776e
movq %rax, %rsi
xorl %eax, %eax
callq 0x3410
xorl %esi, %esi
xorl %edx, %edx
jmp 0xfb86
movl $0x1, %esi
jmp 0xfb86
movl $0x2, %esi
leaq 0x7be1(%rip), %rdi      # 0x1776e
xorl %eax, %eax
callq 0x3410
jmp 0xfba0
movq %rax, %rdi
callq 0x50a1
jmp 0xfbb1
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x13908
jmp 0xfbb4
jmp 0xfbb1
movq %rax, %r14
movq %rbx, %rdi
callq 0xb4a6
movq %r14, %rdi
callq 0x34b0