// File: /workspace/github_cpp_makefile_star2_O1/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 0x2528
leaq -0xf0(%rbp), %rdi
movq %r12, %rdx
callq 0x2198
movq -0x110(%rbp), %rdi
cmpq %r13, %rdi
je 0x1ef5
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 0x2528
leaq -0xc0(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
callq 0x2242
movq -0xa8(%rbp), %rdi
cmpq %r12, %rdi
je 0x1f4c
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 0x1f80
movq (%r15), %rcx
xorl %edx, %edx
movb (%rcx,%rdx), %sil
movb %sil, -0x120(%rbp,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x1f6c
leaq -0x120(%rbp), %rsi
movq %r14, %rdi
callq 0x166e
movq (%rbx), %rax
xorl %ecx, %ecx
movb (%rax,%rcx), %dl
movb %dl, -0x80(%rbp,%rcx)
incq %rcx
cmpq $0x10, %rcx
jne 0x1f94
movq -0xc0(%rbp), %r15
movq -0xb8(%rbp), %rax
movq %rax, -0x88(%rbp)
cmpq %rax, %r15
je 0x20b2
leaq -0xd0(%rbp), %rbx
leaq -0x50(%rbp), %r12
leaq -0x68(%rbp), %rdi
movq %r15, %rsi
callq 0x1d32
movq -0x68(%rbp), %rax
movq -0x60(%rbp), %rcx
subq %rax, %rcx
je 0x2004
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %edx, %edx
movb (%rax,%rdx), %sil
movb %sil, -0xd0(%rbp,%rdx)
incq %rdx
cmpq %rdx, %rcx
jne 0x1ff0
movq %r14, %rdi
movq %rbx, %rsi
leaq -0x80(%rbp), %rdx
callq 0x16de
movq %r14, %rdi
movq %rbx, %rsi
callq 0x234e
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 0x205a
movb (%rdx), %al
movb %al, (%rsi)
incq -0x48(%rbp)
jmp 0x2062
movq %r12, %rdi
callq 0x25c2
incq %r13
cmpq $0x10, %r13
jne 0x203b
movq -0x30(%rbp), %rdi
movq %r12, %rsi
callq 0x2482
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x208c
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x20a1
movq -0x58(%rbp), %rsi
subq %rdi, %rsi
callq 0x10f0
addq $0x18, %r15
cmpq -0x88(%rbp), %r15
jne 0x1fcd
leaq -0xc0(%rbp), %rdi
callq 0x24be
leaq -0xe0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20dd
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 0x2126
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
cmpq %r12, %rdi
je 0x2174
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x10f0
jmp 0x2174
movq %rax, %rbx
jmp 0x2174
movq %rax, %rbx
movq -0x110(%rbp), %rdi
jmp 0x217f
movq %rax, %rbx
jmp 0x215f
jmp 0x2132
movq %rax, %rbx
jmp 0x214a
movq %rax, %rbx
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x214a
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x215f
movq -0x58(%rbp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq -0x30(%rbp), %rdi
callq 0x24be
leaq -0xc0(%rbp), %rdi
callq 0x24be
leaq -0xe0(%rbp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x2190
movq (%r13), %rsi
incq %rsi
callq 0x10f0
movq %rbx, %rdi
callq 0x1150