// File: sellibitze[P]secretshare-cxx/main.cpp
// Function: (anonymous namespace)::text_to_share(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
pair<unsigned,share> text_to_share(string const& t)
{
	istringstream in (t);
	int k, n;
	char m1, m2;
	if (in >> k >> m1 >> n >> m2 && m1=='-' && m2=='-') {
		if (k<0 || n<0 || k>255 || n>255) {
			throw runtime_error("Illegal K,N values in share");
		}
		string remainder;
		in >> remainder;
		auto pos = remainder.find('-');
		auto dat = base64_dec(remainder.substr(0, pos));
		if (pos != string::npos) {
			pos += 1; // ignore -
			if (pos+4 > remainder.size()) {
				throw runtime_error("encoded CRC-24 must be four characters long");
			}
			auto crc_found = remainder.substr(pos, pos+4);
			auto crc_computed = crc24_to_text(compute_crc24(k, n, dat));
			if (crc_found != crc_computed) {
				throw runtime_error("CRC-24 mismatch");
			}
		}
		share s = { octet(n), move(dat) };
		return make_pair(unsigned(k), move(s));
	} else {
		throw runtime_error("Parsing share error");
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x340, %rsp            # imm = 0x340
movq %rdi, -0x2c0(%rbp)
movq %rdi, %rax
movq %rax, -0x2b8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x190(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
movl $0x8, %edx
callq 0x2350
movq -0x2b0(%rbp), %rdi
leaq -0x194(%rbp), %rsi
callq 0x20e0
movq %rax, -0x2a8(%rbp)
jmp 0x613c
movq -0x2a8(%rbp), %rdi
leaq -0x199(%rbp), %rsi
callq 0x2280
movq %rax, -0x2c8(%rbp)
jmp 0x6158
movq -0x2c8(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x20e0
movq %rax, -0x2d0(%rbp)
jmp 0x6174
movq -0x2d0(%rbp), %rdi
leaq -0x19a(%rbp), %rsi
callq 0x2280
movq %rax, -0x2d8(%rbp)
jmp 0x6190
movq -0x2d8(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2220
movb %al, -0x2d9(%rbp)
jmp 0x61ae
movb -0x2d9(%rbp), %al
testb $0x1, %al
jne 0x61bd
jmp 0x669c
movsbl -0x199(%rbp), %eax
cmpl $0x2d, %eax
jne 0x669c
movsbl -0x19a(%rbp), %eax
cmpl $0x2d, %eax
jne 0x669c
cmpl $0x0, -0x194(%rbp)
jl 0x6207
cmpl $0x0, -0x198(%rbp)
jl 0x6207
cmpl $0xff, -0x194(%rbp)
jg 0x6207
cmpl $0xff, -0x198(%rbp)
jle 0x6285
movl $0x10, %edi
callq 0x20b0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2e8(%rbp)
leaq 0x32a3(%rip), %rsi      # 0x94c8
callq 0x2060
jmp 0x622c
movq -0x2e8(%rbp), %rdi
movq 0x7db6(%rip), %rsi      # 0xdff0
movq 0x7d67(%rip), %rdx      # 0xdfa8
callq 0x2360
jmp 0x6713
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
jmp 0x66fb
movq -0x2e8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
callq 0x2160
jmp 0x66fb
leaq -0x1d0(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
callq 0x22c0
movq -0x2f0(%rbp), %rsi
leaq -0x190(%rbp), %rdi
callq 0x2240
jmp 0x62ad
xorl %eax, %eax
movl %eax, %edx
movq %rdx, -0x2f8(%rbp)
leaq -0x1d0(%rbp), %rdi
movq %rdi, -0x300(%rbp)
movl $0x2d, %esi
callq 0x2260
movq -0x300(%rbp), %rsi
movq -0x2f8(%rbp), %rdx
movq %rax, -0x1d8(%rbp)
movq -0x1d8(%rbp), %rcx
leaq -0x210(%rbp), %rdi
callq 0x21e0
jmp 0x62fa
leaq -0x1f0(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x2700
jmp 0x630f
leaq -0x210(%rbp), %rdi
callq 0x20f0
cmpq $-0x1, -0x1d8(%rbp)
je 0x658e
movq -0x1d8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1d8(%rbp)
movq -0x1d8(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x308(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x2150
movq %rax, %rcx
movq -0x308(%rbp), %rax
cmpq %rcx, %rax
jbe 0x6424
movl $0x10, %edi
callq 0x20b0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x310(%rbp)
leaq 0x315a(%rip), %rsi      # 0x94e4
callq 0x2060
jmp 0x6391
movq -0x310(%rbp), %rdi
movq 0x7c51(%rip), %rsi      # 0xdff0
movq 0x7c02(%rip), %rdx      # 0xdfa8
callq 0x2360
jmp 0x6713
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
jmp 0x668e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x20f0
jmp 0x668e
movq -0x310(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
callq 0x2160
jmp 0x6682
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
jmp 0x6682
movq -0x1d8(%rbp), %rdx
movq %rdx, %rcx
addq $0x4, %rcx
leaq -0x230(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x21e0
jmp 0x6447
movl -0x194(%rbp), %eax
movl %eax, -0x318(%rbp)
movl -0x198(%rbp), %eax
movl %eax, -0x314(%rbp)
leaq -0x260(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x7120
jmp 0x6474
movl -0x314(%rbp), %esi
movl -0x318(%rbp), %edi
movq -0x260(%rbp), %rdx
movq -0x258(%rbp), %rcx
callq 0x5990
movl %eax, -0x31c(%rbp)
jmp 0x649b
movl -0x31c(%rbp), %esi
leaq -0x250(%rbp), %rdi
callq 0x5920
jmp 0x64af
leaq -0x230(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x7d10
testb $0x1, %al
jne 0x64cb
jmp 0x6557
movl $0x10, %edi
callq 0x20b0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x328(%rbp)
leaq 0x3027(%rip), %rsi      # 0x9510
callq 0x2060
jmp 0x64f0
movq -0x328(%rbp), %rdi
movq 0x7af2(%rip), %rsi      # 0xdff0
movq 0x7aa3(%rip), %rdx      # 0xdfa8
callq 0x2360
jmp 0x6713
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
jmp 0x657d
movq -0x328(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
callq 0x2160
jmp 0x6571
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
jmp 0x6571
leaq -0x250(%rbp), %rdi
callq 0x20f0
leaq -0x230(%rbp), %rdi
callq 0x20f0
jmp 0x658e
leaq -0x250(%rbp), %rdi
callq 0x20f0
leaq -0x230(%rbp), %rdi
callq 0x20f0
jmp 0x6682
movzbl -0x198(%rbp), %eax
movl %eax, -0x334(%rbp)
leaq -0x298(%rbp), %rdi
movq %rdi, -0x330(%rbp)
leaq -0x1f0(%rbp), %rsi
callq 0x7d40
movl -0x334(%rbp), %esi
movq -0x330(%rbp), %rdx
leaq -0x280(%rbp), %rdi
callq 0x6850
jmp 0x65d0
leaq -0x298(%rbp), %rdi
callq 0x2d50
movq -0x2c0(%rbp), %rdi
movl -0x194(%rbp), %eax
movl %eax, -0x29c(%rbp)
leaq -0x29c(%rbp), %rsi
leaq -0x280(%rbp), %rdx
callq 0x6890
jmp 0x6604
leaq -0x280(%rbp), %rdi
callq 0x51e0
leaq -0x1f0(%rbp), %rdi
callq 0x2d50
leaq -0x1d0(%rbp), %rdi
callq 0x20f0
leaq -0x190(%rbp), %rdi
callq 0x20a0
movq -0x2b8(%rbp), %rax
addq $0x340, %rsp            # imm = 0x340
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
leaq -0x298(%rbp), %rdi
callq 0x2d50
jmp 0x6682
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
leaq -0x280(%rbp), %rdi
callq 0x51e0
leaq -0x1f0(%rbp), %rdi
callq 0x2d50
leaq -0x1d0(%rbp), %rdi
callq 0x20f0
jmp 0x66fb
movl $0x10, %edi
callq 0x20b0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x340(%rbp)
leaq 0x2e66(%rip), %rsi      # 0x9520
callq 0x2060
jmp 0x66c1
movq -0x340(%rbp), %rdi
movq 0x7921(%rip), %rsi      # 0xdff0
movq 0x78d2(%rip), %rdx      # 0xdfa8
callq 0x2360
jmp 0x6713
movq -0x340(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
callq 0x2160
leaq -0x190(%rbp), %rdi
callq 0x20a0
movq -0x1a8(%rbp), %rdi
callq 0x2370
nopw %cs:(%rax,%rax)