// File: rupc[P]xor-secret-sharing-scheme/main.cpp
// Function: XORSecretShares::generate_random_secret[abi:cxx11]()
std::string XORSecretShares::generate_random_secret(void)
{
    if (_init == false) {
        return "ERROR";
    }

    std::string randSecret(key_size, '0');

    for (int i = 0; i < key_size; i++) {
        randSecret[i] = std::to_string(rand() % 2)[0];
    }

    std::string res;
    switch (key_size) {
        case 64: {
            std::bitset<64> _secret_64(randSecret);
            res = _secret_64.to_string();
        }
            break;
        case 128: {
            std::bitset<128> _secret_128(randSecret);
            res = _secret_128.to_string();
        }
            break;
        case 256: {
            std::bitset<256> _secret_256(randSecret);
            res = _secret_256.to_string();
        }
            break;
        default: {
            std::bitset<32> _secret_32(randSecret);
            res = _secret_32.to_string();
        }
            break;
    }
    this->secret = res;
    return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x150(%rbp)
movq %rdi, %rax
movq %rax, -0x148(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x140(%rbp)
movb 0x4(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x2420
leaq -0x11(%rbp), %rdi
movq %rdi, -0x158(%rbp)
callq 0x2230
movq -0x150(%rbp), %rdi
movq -0x158(%rbp), %rdx
leaq 0x3c13(%rip), %rsi      # 0x6004
callq 0x21b0
jmp 0x23f8
leaq -0x11(%rbp), %rdi
callq 0x2180
jmp 0x2722
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x11(%rbp), %rdi
callq 0x2180
jmp 0x2732
movq -0x140(%rbp), %rax
movslq (%rax), %rax
movq %rax, -0x168(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x160(%rbp)
callq 0x2230
movq -0x168(%rbp), %rsi
movq -0x160(%rbp), %rcx
leaq -0x48(%rbp), %rdi
movl $0x30, %edx
callq 0x20d0
jmp 0x245f
leaq -0x49(%rbp), %rdi
callq 0x2180
movl $0x0, -0x50(%rbp)
movq -0x140(%rbp), %rcx
movl -0x50(%rbp), %eax
cmpl (%rcx), %eax
jge 0x2547
callq 0x2040
movl %eax, %esi
movl %esi, %ecx
shrl $0x1f, %ecx
movl %esi, %eax
addl %ecx, %eax
andl $-0x2, %eax
subl %eax, %esi
leaq -0x70(%rbp), %rdi
callq 0x3350
jmp 0x24a1
xorl %eax, %eax
movl %eax, %esi
leaq -0x70(%rbp), %rdi
callq 0x2240
movq %rax, -0x170(%rbp)
jmp 0x24b7
movq -0x170(%rbp), %rax
movb (%rax), %al
movb %al, -0x179(%rbp)
movslq -0x50(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x2240
movq %rax, -0x178(%rbp)
jmp 0x24dc
movq -0x178(%rbp), %rax
movb -0x179(%rbp), %cl
movb %cl, (%rax)
leaq -0x70(%rbp), %rdi
callq 0x20c0
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x246f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x49(%rbp), %rdi
callq 0x2180
jmp 0x2732
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x2717
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x20c0
jmp 0x2717
movq -0x150(%rbp), %rdi
movb $0x0, -0x71(%rbp)
callq 0x21c0
movq -0x140(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x180(%rbp)
subl $0x40, %eax
je 0x2592
jmp 0x256d
movl -0x180(%rbp), %eax
subl $0x80, %eax
je 0x25f8
jmp 0x257c
movl -0x180(%rbp), %eax
subl $0x100, %eax            # imm = 0x100
je 0x2647
jmp 0x2693
xorl %eax, %eax
movl %eax, %edx
leaq -0x80(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3470
jmp 0x25a5
leaq -0xa0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x34d0
jmp 0x25b7
movq -0x150(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x2190
leaq -0xa0(%rbp), %rdi
callq 0x20c0
jmp 0x26dd
movq -0x150(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x20c0
jmp 0x2717
xorl %eax, %eax
movl %eax, %edx
leaq -0xb0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3500
jmp 0x260e
leaq -0xd0(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x3560
jmp 0x2623
movq -0x150(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x2190
leaq -0xd0(%rbp), %rdi
callq 0x20c0
jmp 0x26dd
xorl %eax, %eax
movl %eax, %edx
leaq -0xf0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3590
jmp 0x265d
leaq -0x110(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x35f0
jmp 0x2672
movq -0x150(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x2190
leaq -0x110(%rbp), %rdi
callq 0x20c0
jmp 0x26dd
xorl %eax, %eax
movl %eax, %edx
leaq -0x118(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3620
jmp 0x26a9
leaq -0x138(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x3680
jmp 0x26be
movq -0x150(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x2190
leaq -0x138(%rbp), %rdi
callq 0x20c0
movq -0x150(%rbp), %rsi
movq -0x140(%rbp), %rdi
addq $0x8, %rdi
callq 0x2030
jmp 0x26f6
movb $0x1, -0x71(%rbp)
testb $0x1, -0x71(%rbp)
jne 0x270c
movq -0x150(%rbp), %rdi
callq 0x20c0
leaq -0x48(%rbp), %rdi
callq 0x20c0
jmp 0x2722
leaq -0x48(%rbp), %rdi
callq 0x20c0
jmp 0x2732
movq -0x148(%rbp), %rax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x2220
nopl (%rax,%rax)