// File: rupc[P]xor-secret-sharing-scheme/main.cpp
// Function: XORSecretShares::split[abi:cxx11](unsigned long)
std::vector<std::string> XORSecretShares::split(size_t n) {
    std::vector<std::string> shadows(n);

    if (_init == false) {
        std::cerr << "ERROR" << std::endl;
        return shadows;
    }

    for (int i = 0; i < n - 1; i++) {
        std::string randSecret(key_size, '0');
        for (int j = 0; j < key_size; j++) {
            randSecret[j] = std::to_string(rand() % 2)[0];
        }
        shadows[i] = randSecret;
    }

    std::string last_secret = this->secret;

    for (int i = 0; i < n - 1; i++) {
        switch (key_size) {
            case 64: {
                std::bitset<64> _last_secret_64(last_secret);
                std::bitset<64> _secret_64(shadows[i]);
                last_secret = (_last_secret_64^=_secret_64).to_string();
            }
                break;
            case 128: {
                std::bitset<128> _last_secret_128(last_secret);
                std::bitset<128> _secret_128(shadows[i]);
                last_secret = (_last_secret_128^=_secret_128).to_string();
            }
                break;
            case 256: {
                std::bitset<256> _last_secret_256(last_secret);
                std::bitset<256> _secret_256(shadows[i]);
                last_secret = (_last_secret_256^=_secret_256).to_string();
            }
                break;
            default: {
                std::bitset<64> _last_secret_64(last_secret);
                std::bitset<64> _secret_64(shadows[i]);
                last_secret = (_last_secret_64^=_secret_64).to_string();
            }
                break;
        }
    }

    shadows[shadows.size() - 1] = last_secret;

    return shadows;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movq %rdi, -0x1c0(%rbp)
movq %rdi, %rax
movq %rax, -0x1d0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movb $0x0, -0x19(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x1b8(%rbp)
leaq -0x1a(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
callq 0x36b0
movq -0x1c0(%rbp), %rdi
movq -0x1b8(%rbp), %rsi
movq -0x1b0(%rbp), %rdx
callq 0x36d0
jmp 0x27ae
leaq -0x1a(%rbp), %rdi
callq 0x3740
movq -0x1c8(%rbp), %rax
movb 0x4(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x2837
movq 0x681e(%rip), %rdi      # 0x8ff0
leaq 0x382b(%rip), %rsi      # 0x6004
callq 0x2150
movq %rax, -0x1d8(%rbp)
jmp 0x27e7
movq -0x1d8(%rbp), %rdi
movq 0x67cb(%rip), %rsi      # 0x8fc0
callq 0x2170
jmp 0x27fc
movb $0x1, -0x19(%rbp)
movl $0x1, -0x30(%rbp)
jmp 0x2cc9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x1a(%rbp), %rdi
callq 0x3740
jmp 0x2cf7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x2ceb
movl $0x0, -0x34(%rbp)
movslq -0x34(%rbp), %rax
movq -0x18(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x29b7
movq -0x1c8(%rbp), %rax
movslq (%rax), %rax
movq %rax, -0x1e8(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x2230
movq -0x1e8(%rbp), %rsi
movq -0x1e0(%rbp), %rcx
leaq -0x58(%rbp), %rdi
movl $0x30, %edx
callq 0x20d0
jmp 0x2892
leaq -0x59(%rbp), %rdi
callq 0x2180
movl $0x0, -0x60(%rbp)
movq -0x1c8(%rbp), %rcx
movl -0x60(%rbp), %eax
cmpl (%rcx), %eax
jge 0x2974
callq 0x2040
movl %eax, %esi
movl %esi, %ecx
shrl $0x1f, %ecx
movl %esi, %eax
addl %ecx, %eax
andl $-0x2, %eax
subl %eax, %esi
leaq -0x80(%rbp), %rdi
callq 0x3350
jmp 0x28d4
xorl %eax, %eax
movl %eax, %esi
leaq -0x80(%rbp), %rdi
callq 0x2240
movq %rax, -0x1f0(%rbp)
jmp 0x28ea
movq -0x1f0(%rbp), %rax
movb (%rax), %al
movb %al, -0x1f9(%rbp)
movslq -0x60(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x2240
movq %rax, -0x1f8(%rbp)
jmp 0x290f
movq -0x1f8(%rbp), %rax
movb -0x1f9(%rbp), %cl
movb %cl, (%rax)
leaq -0x80(%rbp), %rdi
callq 0x20c0
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x28a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x59(%rbp), %rdi
callq 0x2180
jmp 0x2ceb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x29a9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x20c0
jmp 0x29a9
movq -0x1c0(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x3760
movq %rax, %rdi
leaq -0x58(%rbp), %rsi
callq 0x2030
jmp 0x2992
leaq -0x58(%rbp), %rdi
callq 0x20c0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x283e
leaq -0x58(%rbp), %rdi
callq 0x20c0
jmp 0x2ceb
movq -0x1c8(%rbp), %rsi
addq $0x8, %rsi
leaq -0xa0(%rbp), %rdi
callq 0x2080
jmp 0x29d0
movl $0x0, -0xa4(%rbp)
movslq -0xa4(%rbp), %rax
movq -0x18(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x2c83
movq -0x1c8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x200(%rbp)
subl $0x40, %eax
je 0x2a31
jmp 0x2a08
movl -0x200(%rbp), %eax
subl $0x80, %eax
je 0x2ad7
jmp 0x2a1b
movl -0x200(%rbp), %eax
subl $0x100, %eax            # imm = 0x100
je 0x2b60
jmp 0x2be9
xorl %eax, %eax
movl %eax, %edx
leaq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3470
jmp 0x2a4a
movq -0x1c0(%rbp), %rdi
movslq -0xa4(%rbp), %rsi
callq 0x3760
movq %rax, %rsi
xorl %eax, %eax
movl %eax, %edx
leaq -0xb8(%rbp), %rdi
callq 0x3470
jmp 0x2a72
leaq -0xb0(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x3780
movq %rax, %rsi
leaq -0xd8(%rbp), %rdi
callq 0x34d0
jmp 0x2a96
leaq -0xa0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x2190
leaq -0xd8(%rbp), %rdi
callq 0x20c0
jmp 0x2c6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x20c0
jmp 0x2ceb
xorl %eax, %eax
movl %eax, %edx
leaq -0xe8(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3500
jmp 0x2af0
movq -0x1c0(%rbp), %rdi
movslq -0xa4(%rbp), %rsi
callq 0x3760
movq %rax, %rsi
xorl %eax, %eax
movl %eax, %edx
leaq -0xf8(%rbp), %rdi
callq 0x3500
jmp 0x2b18
leaq -0xe8(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x37b0
movq %rax, %rsi
leaq -0x118(%rbp), %rdi
callq 0x3560
jmp 0x2b3c
leaq -0xa0(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x2190
leaq -0x118(%rbp), %rdi
callq 0x20c0
jmp 0x2c6d
xorl %eax, %eax
movl %eax, %edx
leaq -0x138(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3590
jmp 0x2b79
movq -0x1c0(%rbp), %rdi
movslq -0xa4(%rbp), %rsi
callq 0x3760
movq %rax, %rsi
xorl %eax, %eax
movl %eax, %edx
leaq -0x158(%rbp), %rdi
callq 0x3590
jmp 0x2ba1
leaq -0x138(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x37e0
movq %rax, %rsi
leaq -0x178(%rbp), %rdi
callq 0x35f0
jmp 0x2bc5
leaq -0xa0(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x2190
leaq -0x178(%rbp), %rdi
callq 0x20c0
jmp 0x2c6d
xorl %eax, %eax
movl %eax, %edx
leaq -0x180(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3470
jmp 0x2c02
movq -0x1c0(%rbp), %rdi
movslq -0xa4(%rbp), %rsi
callq 0x3760
movq %rax, %rsi
xorl %eax, %eax
movl %eax, %edx
leaq -0x188(%rbp), %rdi
callq 0x3470
jmp 0x2c2a
leaq -0x180(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x3780
movq %rax, %rsi
leaq -0x1a8(%rbp), %rdi
callq 0x34d0
jmp 0x2c4e
leaq -0xa0(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x2190
leaq -0x1a8(%rbp), %rdi
callq 0x20c0
jmp 0x2c6f
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x29da
movq -0x1c0(%rbp), %rdi
callq 0x3810
movq -0x1c0(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x3760
movq %rax, %rdi
leaq -0xa0(%rbp), %rsi
callq 0x2030
jmp 0x2cb2
movb $0x1, -0x19(%rbp)
movl $0x1, -0x30(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x20c0
testb $0x1, -0x19(%rbp)
jne 0x2cdb
movq -0x1c0(%rbp), %rdi
callq 0x3830
movq -0x1d0(%rbp), %rax
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
movq -0x1c0(%rbp), %rdi
callq 0x3830
movq -0x28(%rbp), %rdi
callq 0x2220