// File: /workspace/github_cpp_makefile_star2_O2/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 $0x48, %rsp
cmpl $0x0, 0x10(%rdi)
je 0x35a6
movq %rdi, %rbx
movl (%rdi), %eax
cmpl $0x2, %eax
je 0x35c2
testl %eax, %eax
je 0x35de
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
andq $0x0, 0x10(%rsp)
movq 0x8(%rbx), %rax
movq 0x8(%rax), %r14
subq (%rax), %r14
sarq $0x5, %r14
xorl %r15d, %r15d
cmpq $0xa, %r14
jb 0x3492
pushq $0xa
popq %rcx
movq %r14, %rax
xorl %edx, %edx
divq %rcx
movq %rdx, 0x18(%rsp)
pushq $0xa
popq %r12
movq %rax, %r14
jmp 0x349f
pushq $0x1
popq %r12
movq $0x0, 0x18(%rsp)
leal -0x1(%r14), %r13d
leaq 0x20(%rsp), %rbp
subl $0x1, %r12d
jb 0x34e9
pushq $0x18
popq %rdi
callq 0x2180
andq $0x0, 0x10(%rax)
movq %rax, 0x20(%rsp)
movq 0x8(%rbx), %rcx
movq %rcx, (%rax)
movl 0x10(%rbx), %ecx
movl %ecx, 0x10(%rax)
movl %r15d, 0x8(%rax)
leal (%r13,%r15), %ecx
movl %ecx, 0xc(%rax)
movq %rsp, %rdi
movq %rbp, %rsi
callq 0x3094
addl %r14d, %r15d
jmp 0x34a8
movq 0x8(%rsp), %r12
movq -0x8(%r12), %rax
movq 0x18(%rsp), %rcx
addl %ecx, 0xc(%rax)
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rbx
andq $0x0, 0x10(%rbx)
movaps %xmm0, (%rbx)
movq (%rsp), %r13
leaq 0x144(%rip), %r14       # 0x365a
leaq 0x40(%rsp), %r15
cmpq %r12, %r13
je 0x3542
movq (%r13), %rcx
movq %r15, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x22a0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3100
addq $0x8, %r13
jmp 0x351b
movq 0x20(%rsp), %rbx
movq 0x28(%rsp), %r14
cmpq %r14, %rbx
je 0x3561
movq (%rbx), %rdi
xorl %esi, %esi
callq 0x2160
addq $0x8, %rbx
jmp 0x354c
movq (%rsp), %r14
movq 0x8(%rsp), %r15
pushq $0x18
popq %rbx
cmpq %r15, %r14
je 0x3583
movq (%r14), %rdi
movq %rbx, %rsi
callq 0x2190
addq $0x8, %r14
jmp 0x356d
leaq 0x20(%rsp), %rdi
callq 0x33ea
movq %rsp, %rdi
callq 0x3408
movb $0x1, %al
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x20e0
movq %rax, %r14
leaq 0xc2f(%rip), %rsi       # 0x41e7
movq %rax, %rdi
callq 0x3644
jmp 0x35f8
pushq $0x10
popq %rdi
callq 0x20e0
movq %rax, %r14
leaq 0xc9c(%rip), %rsi       # 0x4270
movq %rax, %rdi
callq 0x3644
jmp 0x35f8
pushq $0x10
popq %rdi
callq 0x20e0
movq %rax, %r14
leaq 0xc64(%rip), %rsi       # 0x4254
movq %rax, %rdi
callq 0x3644
leaq 0x3769(%rip), %rsi      # 0x6d68
movq 0x39c2(%rip), %rdx      # 0x6fc8
movq %r14, %rdi
callq 0x2270
jmp 0x3612
jmp 0x3612
movq %rax, %rbx
movq %r14, %rdi
callq 0x2120
jmp 0x363b
jmp 0x3621
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x33ea
jmp 0x3633
movq %rax, %rbx
movq %rsp, %rdi
callq 0x3408
movq %rbx, %rdi
callq 0x2290
nop