// File: /workspace/github_cpp_makefile_star2_O3/SimpleButNotNaive[P]AES/encryptor.cpp
// Function: aes_encryptor::encryption(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
vector<vector<uint8>> aes_encryptor::encryption(string p_text, string key, string init_vector) {
    string total_plain_text = padding(p_text);
    vector<vector<uint8>> text_vector = split(total_plain_text);

    vector<vector<uint8>> cipher;

    uint8 key_array[16];
    for(int i = 0;i < key.size();i++){
        key_array[i] = key[i];
    }

    generate_roundkey(key_array);

    uint8 y[16];
    for(int i = 0;i < 16;i++){
        y[i] = init_vector[i];
    }

    uint8 x[16];
    for(auto group : text_vector){
        for(int i = 0;i < group.size();i++){
            x[i] = group[i];
        }
        xor_group(x, y);
        encrypt_one_group(x);

        for(int i = 0; i < 16;i++){
            y[i] = x[i];
        }
        
        vector<uint8> one_group;
        for(int i = 0;i < 16;i++){
            one_group.push_back(y[i]);
        }
        cipher.push_back(one_group);
    }
    return cipher;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %r8, %rbx
movq %rcx, %r15
movq %rsi, %r14
movq %rdi, -0x30(%rbp)
leaq -0x100(%rbp), %r13
movq %r13, -0x10(%r13)
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
addq %rsi, %rdx
leaq -0x110(%rbp), %r12
movq %r12, %rdi
callq 0x2546
leaq -0xf0(%rbp), %rdi
movq %r12, %rdx
callq 0x21b8
movq -0x110(%rbp), %rdi
cmpq %r13, %rdi
je 0x1f15
movq -0x100(%rbp), %rsi
incq %rsi
callq 0x10f0
leaq -0x98(%rbp), %r12
movq %r12, -0x10(%r12)
movq -0xf0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
addq %rsi, %rdx
leaq -0xa8(%rbp), %rdi
callq 0x2546
leaq -0xc0(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
callq 0x225c
movq -0xa8(%rbp), %rdi
cmpq %r12, %rdi
je 0x1f6c
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x10f0
xorps %xmm0, %xmm0
movq -0x30(%rbp), %rax
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq 0x8(%r15), %rax
testq %rax, %rax
je 0x1fa0
movq (%r15), %rcx
xorl %edx, %edx
movb (%rcx,%rdx), %sil
movb %sil, -0x120(%rbp,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x1f8c
leaq -0x120(%rbp), %rsi
movq %r14, %rdi
callq 0x168e
movq (%rbx), %rax
xorl %ecx, %ecx
movb (%rax,%rcx), %dl
movb %dl, -0x80(%rbp,%rcx)
incq %rcx
cmpq $0x10, %rcx
jne 0x1fb4
movq -0xc0(%rbp), %r15
movq -0xb8(%rbp), %rax
movq %rax, -0x88(%rbp)
cmpq %rax, %r15
je 0x20d2
leaq -0xd0(%rbp), %rbx
leaq -0x50(%rbp), %r12
leaq -0x68(%rbp), %rdi
movq %r15, %rsi
callq 0x1d50
movq -0x68(%rbp), %rax
movq -0x60(%rbp), %rcx
subq %rax, %rcx
je 0x2024
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %edx, %edx
movb (%rax,%rdx), %sil
movb %sil, -0xd0(%rbp,%rdx)
incq %rdx
cmpq %rdx, %rcx
jne 0x2010
movq %r14, %rdi
movq %rbx, %rsi
leaq -0x80(%rbp), %rdx
callq 0x16fe
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2368
movaps -0xd0(%rbp), %xmm0
movaps %xmm0, -0x80(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
xorl %r13d, %r13d
leaq -0x80(,%r13), %rdx
addq %rbp, %rdx
movq -0x48(%rbp), %rsi
cmpq -0x40(%rbp), %rsi
je 0x207a
movb (%rdx), %al
movb %al, (%rsi)
incq -0x48(%rbp)
jmp 0x2082
movq %r12, %rdi
callq 0x25e4
incq %r13
cmpq $0x10, %r13
jne 0x205b
movq -0x30(%rbp), %rdi
movq %r12, %rsi
callq 0x249a
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x20ac
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x20c1
movq -0x58(%rbp), %rsi
subq %rdi, %rsi
callq 0x10f0
addq $0x18, %r15
cmpq -0x88(%rbp), %r15
jne 0x1fed
leaq -0xc0(%rbp), %rdi
callq 0x24d6
leaq -0xe0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20fd
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x10f0
movq -0x30(%rbp), %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2146
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
cmpq %r12, %rdi
je 0x2194
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x10f0
jmp 0x2194
movq %rax, %rbx
jmp 0x2194
movq %rax, %rbx
movq -0x110(%rbp), %rdi
jmp 0x219f
movq %rax, %rbx
jmp 0x217f
jmp 0x2152
movq %rax, %rbx
jmp 0x216a
movq %rax, %rbx
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x216a
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x217f
movq -0x58(%rbp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq -0x30(%rbp), %rdi
callq 0x24d6
leaq -0xc0(%rbp), %rdi
callq 0x24d6
leaq -0xe0(%rbp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x21b0
movq (%r13), %rsi
incq %rsi
callq 0x10f0
movq %rbx, %rdi
callq 0x1150