// File: sellibitze[P]secretshare-cxx/main.cpp
// Function: (anonymous namespace)::read_shares_from(std::istream&)
vector<share> read_shares_from(istream& in)
{
	unsigned k = 0;
	vector<share> result;
	string word;
	while (cin >> word) {
		auto p = text_to_share(word);
		if (result.empty()) {
			// simply copy K value for the first share
			k = p.first;
		} else {
			// enforce consistency of K value and size for all shares
			if (k != p.first ||
			    result.front().data.size() != p.second.data.size())
			{
				throw runtime_error("Incompatible shares");
			}
		}
		// check for duplicates
		bool duplicate = false;
		for (const auto& s : result) {
			if (s.xcoord == p.second.xcoord) {
				if (s.data != p.second.data) {
					throw runtime_error("Inconsistent share data");
				}
				duplicate = true;
			}
		}
		if (!duplicate) {
			result.push_back(move(p.second));
			if (result.size() == k) {
				return result;
			}
		}
	}
	throw runtime_error("Not enough shares provided");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0xb0(%rbp)
movq %rdi, %rax
movq %rax, -0xa8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movb $0x0, -0x15(%rbp)
callq 0x60c0
leaq -0x38(%rbp), %rdi
callq 0x22c0
movq 0x855c(%rip), %rdi      # 0xdfd0
leaq -0x38(%rbp), %rsi
callq 0x2240
movq %rax, -0xb8(%rbp)
jmp 0x5a86
movq -0xb8(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2220
movb %al, -0xb9(%rbp)
jmp 0x5aa4
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x5ab3
jmp 0x5d29
leaq -0x70(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x60e0
jmp 0x5ac2
movq -0xb0(%rbp), %rdi
callq 0x6720
testb $0x1, %al
jne 0x5ad4
jmp 0x5af0
movl -0x70(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0x5bab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5d95
movl -0x14(%rbp), %eax
cmpl -0x70(%rbp), %eax
jne 0x5b37
movq -0xb0(%rbp), %rdi
callq 0x6760
movq %rax, %rdi
addq $0x8, %rdi
callq 0x3090
movq %rax, -0xc8(%rbp)
leaq -0x70(%rbp), %rdi
addq $0x8, %rdi
addq $0x8, %rdi
callq 0x3090
movq %rax, %rcx
movq -0xc8(%rbp), %rax
cmpq %rcx, %rax
je 0x5ba9
movl $0x10, %edi
callq 0x20b0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xd0(%rbp)
leaq 0x392c(%rip), %rsi      # 0x9481
callq 0x2060
jmp 0x5b5c
movq -0xd0(%rbp), %rdi
movq 0x8486(%rip), %rsi      # 0xdff0
movq 0x8437(%rip), %rdx      # 0xdfa8
callq 0x2360
jmp 0x5dd1
movq -0xd0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
callq 0x2160
jmp 0x5d1e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5d1e
jmp 0x5bab
movq -0xb0(%rbp), %rax
movb $0x0, -0x71(%rbp)
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
callq 0x4d00
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rdi
callq 0x4d30
movq %rax, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x4d60
testb $0x1, %al
jne 0x5bf6
jmp 0x5cbc
leaq -0x88(%rbp), %rdi
callq 0x4da0
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movzbl (%rax), %eax
movzbl -0x68(%rbp), %ecx
cmpl %ecx, %eax
jne 0x5ca9
movq -0x98(%rbp), %rdi
addq $0x8, %rdi
leaq -0x60(%rbp), %rsi
callq 0x7ce0
movb %al, -0xd1(%rbp)
jmp 0x5c3b
movb -0xd1(%rbp), %al
testb $0x1, %al
jne 0x5c47
jmp 0x5ca5
movl $0x10, %edi
callq 0x20b0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xe0(%rbp)
leaq 0x3830(%rip), %rsi      # 0x9495
callq 0x2060
jmp 0x5c6c
movq -0xe0(%rbp), %rdi
movq 0x8376(%rip), %rsi      # 0xdff0
movq 0x8327(%rip), %rdx      # 0xdfa8
callq 0x2360
jmp 0x5dd1
movq -0xe0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
callq 0x2160
jmp 0x5d1e
movb $0x1, -0x71(%rbp)
jmp 0x5cab
leaq -0x88(%rbp), %rdi
callq 0x5020
jmp 0x5bda
testb $0x1, -0x71(%rbp)
jne 0x5cfa
movq -0xb0(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x6790
jmp 0x5cd4
movq -0xb0(%rbp), %rdi
callq 0x67c0
movl -0x14(%rbp), %ecx
cmpq %rcx, %rax
jne 0x5cf8
movb $0x1, -0x15(%rbp)
movl $0x1, -0x9c(%rbp)
jmp 0x5d04
jmp 0x5cfa
movl $0x0, -0x9c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x67e0
movl -0x9c(%rbp), %eax
testl %eax, %eax
jne 0x5d84
jmp 0x5d19
jmp 0x5a6d
leaq -0x70(%rbp), %rdi
callq 0x67e0
jmp 0x5d95
movl $0x10, %edi
callq 0x20b0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xe8(%rbp)
leaq 0x3766(%rip), %rsi      # 0x94ad
callq 0x2060
jmp 0x5d4e
movq -0xe8(%rbp), %rdi
movq 0x8294(%rip), %rsi      # 0xdff0
movq 0x8245(%rip), %rdx      # 0xdfa8
callq 0x2360
jmp 0x5dd1
movq -0xe8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
callq 0x2160
jmp 0x5d95
leaq -0x38(%rbp), %rdi
callq 0x20f0
testb $0x1, -0x15(%rbp)
jne 0x5db8
jmp 0x5dac
leaq -0x38(%rbp), %rdi
callq 0x20f0
movq -0xb0(%rbp), %rdi
callq 0x5040
jmp 0x5dc8
movq -0xb0(%rbp), %rdi
callq 0x5040
movq -0xa8(%rbp), %rax
addq $0xf0, %rsp
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x2370
nopw %cs:(%rax,%rax)