// File: /workspace/github_cpp_makefile_star2_O1/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 0x5a48
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 0xfca4
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 0xfd68
callq 0x13c66
andl $0x1ff, %r15d           # imm = 0x1FF
cmpq %rax, %r15
jbe 0xfd08
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 0xfe8a
shlq $0x5, %rsi
addq %rsi, %rdi
callq 0x13c66
cmpq %rax, %r15
jbe 0xfd7a
movq 0x30(%r14), %rsi
cmpq %rsi, 0x38(%r14)
je 0xfe78
movq %rbx, %rdi
callq 0x129fa
movq 0x30(%r14), %rsi
movq 0x38(%r14), %rdx
subq %rsi, %rdx
sarq $0x5, %rdx
cmpq $0x2, %rdx
jb 0xfe7e
addq $0x20, %rsi
movq %rbx, %rdi
callq 0x129fa
movq 0x30(%r14), %rsi
movq 0x38(%r14), %rdx
subq %rsi, %rdx
sarq $0x5, %rdx
cmpq $0x2, %rdx
jbe 0xfe85
addq $0x40, %rsi
movq %rbx, %rdi
callq 0x129fa
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 0xfd68
movl $0x3, %r12d
movl $0x20, %ebp
leaq 0x8(%rsp), %r13
leaq -0x2(%r12), %rax
cmpq %rax, %rdx
jbe 0xfe67
addq %rbp, %rsi
movq %r13, %rdi
callq 0x13bf0
movq %r13, %rdi
callq 0x13c66
cmpq %rax, %r15
jbe 0xfdfd
movq %r13, %rdi
callq 0x13be4
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 0xfd9e
jmp 0xfd68
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x129fa
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 0x129fa
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 0x129fa
leaq 0x8(%rsp), %rdi
callq 0x13be4
jmp 0xfd68
leaq 0x8900(%rip), %rdi      # 0x1876e
movq %rax, %rsi
xorl %eax, %eax
callq 0x3410
xorl %esi, %esi
xorl %edx, %edx
jmp 0xfe8a
movl $0x1, %esi
jmp 0xfe8a
movl $0x2, %esi
leaq 0x88dd(%rip), %rdi      # 0x1876e
xorl %eax, %eax
callq 0x3410
jmp 0xfea4
movq %rax, %rdi
callq 0x50a6
jmp 0xfeb5
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x13be4
jmp 0xfeb8
jmp 0xfeb5
movq %rax, %r14
movq %rbx, %rdi
callq 0xb544
movq %r14, %rdi
callq 0x34b0