// File: /workspace/github_cpp_makefile_star2_O3/LandonSwartz[P]TheGreatEncryptor/./EncryptionClass.cpp
// Function: encryption_base::decrypt_data()
bool decrypt_data() {
        if (this->hash_key == 0) {
            throw file_decryption_error("no hash key has been set");
            return false;
        }
        if (data_state == 0) {
            throw file_decryption_error("there is no data to decrypt");
            return false;
        } else if (data_state == 2) {
            throw file_decryption_error("the data has already been decrypted");
            return false;
        }
        
        // Set up the structs for the threads which will encrypt the data.
        vector<alg_prms *> encryption_alg_prms_vect;
        int indices_per_thread;
        int num_threads;
        int end_additional_increment = 0;
        // Ensure there will be at least one string per thread
        if (data->size() >= NUM_ENCRYPTION_THREADS) {
            indices_per_thread = (data->size()) / NUM_ENCRYPTION_THREADS;
            end_additional_increment = (data->size()) % NUM_ENCRYPTION_THREADS;
            num_threads = NUM_ENCRYPTION_THREADS;
        }
        // If there will not be one string per thread, simply use one thread
        else {
            num_threads = 1;
            indices_per_thread = data->size();
        }
        for (int i = 0; i < num_threads; i++) {
            alg_prms * alg_prms_strc = new alg_prms();
            alg_prms_strc->data = this->data;
            alg_prms_strc->hash_key = this->hash_key;
            alg_prms_strc->start_index = (i * indices_per_thread);
            alg_prms_strc->end_index = ((i + 1) * indices_per_thread) - 1;
            encryption_alg_prms_vect.push_back(alg_prms_strc);
        }
        // Add end_additional_increment
        encryption_alg_prms_vect.back()->end_index += end_additional_increment;

        // Create the threads to encrypt the data
        vector<pthread_t> encryption_threads;
        for (auto prm_vct : encryption_alg_prms_vect) {
            pthread_t new_thread;
            pthread_create(&new_thread, NULL, decryption_algorithm, prm_vct);
            encryption_threads.push_back(new_thread);
        }

        // Now that the threads are running, join them so the function will yield
        for (auto thread : encryption_threads) {
            pthread_join(thread, NULL);
        }

        // Delete the dynamically allocated structs once all thread operation has completed
        for (auto prm_vct : encryption_alg_prms_vect) {
            delete prm_vct;
        }

        // Return true to indicate the encryption was successful.
        return true;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
cmpl $0x0, 0x10(%rdi)
je 0x3be0
movq %rdi, %rbx
movl (%rdi), %eax
cmpl $0x2, %eax
je 0x3bfe
testl %eax, %eax
je 0x3c1c
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x8(%rbx), %rax
movq 0x8(%rax), %r14
subq (%rax), %r14
sarq $0x5, %r14
movl $0x1, %ebp
xorl %r13d, %r13d
cmpq $0xa, %r14
jb 0x3a74
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
movq %r14, %rax
mulq %rcx
shrq $0x3, %rdx
leal (%rdx,%rdx), %eax
leal (%rax,%rax,4), %eax
subl %eax, %r14d
movl $0xa, %ebp
movl %r14d, 0xc(%rsp)
movq %rdx, %r14
jmp 0x3a7c
movl $0x0, 0xc(%rsp)
leal -0x1(%r14), %r15d
leaq 0x10(%rsp), %r12
movl $0x18, %edi
callq 0x21c0
movq $0x0, 0x10(%rax)
movq %rax, 0x10(%rsp)
movq 0x8(%rbx), %rcx
movq %rcx, (%rax)
movl 0x10(%rbx), %ecx
movl %ecx, 0x10(%rax)
movl %r13d, 0x8(%rax)
leal (%r15,%r13), %ecx
movl %ecx, 0xc(%rax)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x3acb
movq %rax, (%rsi)
addq $0x8, 0x38(%rsp)
jmp 0x3ad8
leaq 0x30(%rsp), %rdi
movq %r12, %rdx
callq 0x3774
addl %r14d, %r13d
decl %ebp
jne 0x3a85
movq 0x38(%rsp), %r12
movq -0x8(%r12), %rax
movl 0xc(%rsp), %ecx
addl %ecx, 0xc(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x30(%rsp), %r13
cmpq %r12, %r13
je 0x3b7f
leaq 0x1a4(%rip), %rbx       # 0x3cb6
leaq 0x50(%rsp), %r14
leaq 0x10(%rsp), %r15
movq (%r13), %rcx
movq %r14, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x22e0
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x3b4c
movq 0x50(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x3b57
movq %r15, %rdi
movq %r14, %rdx
callq 0x38b0
addq $0x8, %r13
cmpq %r12, %r13
jne 0x3b1c
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r14
cmpq %r14, %rbx
je 0x3b7f
movq (%rbx), %rdi
xorl %esi, %esi
callq 0x21a0
addq $0x8, %rbx
jmp 0x3b6a
movq 0x30(%rsp), %rbx
movq 0x38(%rsp), %r14
cmpq %r14, %rbx
je 0x3ba1
movq (%rbx), %rdi
movl $0x18, %esi
callq 0x21d0
addq $0x8, %rbx
jmp 0x3b89
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3bb8
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x3bcf
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movb $0x1, %al
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x20f0
movq %rax, %r14
leaq 0x160f(%rip), %rsi      # 0x5203
movq %rax, %rdi
callq 0x3ca0
jmp 0x3c38
movl $0x10, %edi
callq 0x20f0
movq %rax, %r14
leaq 0x167a(%rip), %rsi      # 0x528c
movq %rax, %rdi
callq 0x3ca0
jmp 0x3c38
movl $0x10, %edi
callq 0x20f0
movq %rax, %r14
leaq 0x1640(%rip), %rsi      # 0x5270
movq %rax, %rdi
callq 0x3ca0
leaq 0x4121(%rip), %rsi      # 0x7d60
movq 0x4382(%rip), %rdx      # 0x7fc8
movq %r14, %rdi
callq 0x22a0
jmp 0x3c52
jmp 0x3c52
movq %rax, %rbx
movq %r14, %rdi
callq 0x2150
jmp 0x3c97
jmp 0x3c61
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3c80
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
jmp 0x3c80
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x3c97
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq %rbx, %rdi
callq 0x22c0
nop