// File: /workspace/github_cpp_makefile_star2_O3/lmclaramunt[P]AES-Crypto/Cipher.cpp
// Function: Cipher::encrypt(Sequence*, unsigned char**)
void Cipher::encrypt(Sequence* input, unsigned char** key) {
    State state(input);
    addRoudKey(0, key, state.getStateArray());
    
    for (int i=1; i < Nr; i++) {
        unsigned char** s2 = new unsigned char*[4];
        subBytes(state.getStateArray());
        shiftRows(state.getStateArray());
        mixColumns(state.getStateArray(), s2);
        state.setStateArray(s2);
        addRoudKey(i, key, state.getStateArray());
    }

    subBytes(state.getStateArray());
    shiftRows(state.getStateArray());
    addRoudKey(Nr, key, state.getStateArray());
    input->updateSequence(state.toSequence());

    /* State cleanup as it can leave traces in memory */
    state.~State();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r14
movq %rdi, %r15
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %rsi, 0x10(%rsp)
callq 0x39f8
movq %r12, %rdi
callq 0x3a94
xorl %ecx, %ecx
xorl %edx, %edx
movq (%r14,%rcx,8), %rsi
movb (%rsi,%rdx), %sil
movq (%rax,%rdx,8), %rdi
xorb %sil, (%rdi,%rcx)
incq %rdx
cmpq $0x4, %rdx
jne 0x52aa
incq %rcx
cmpq $0x4, %rcx
jne 0x52a8
cmpl $0x2, 0x1c(%r15)
jl 0x53b6
movl $0x1, %ebp
leaq 0x8(%rsp), %r12
leaq 0x2188(%rip), %rbx      # 0x7470
movl $0x20, %edi
callq 0x2030
movq %rax, %r13
movq %r12, %rdi
callq 0x3a94
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
xorl %esi, %esi
movzbl (%rdx,%rsi), %edi
movl %edi, %r8d
andl $0xf, %r8d
andl $-0x10, %edi
addq %rbx, %rdi
movb (%r8,%rdi), %dil
movb %dil, (%rdx,%rsi)
incq %rsi
cmpq $0x4, %rsi
jne 0x5305
incq %rcx
cmpq $0x4, %rcx
jne 0x52ff
movq %r12, %rdi
callq 0x3a94
movq %rax, %rsi
callq 0x5020
movq %r12, %rdi
callq 0x3a94
movq %rax, %rsi
movq %r13, %rdx
callq 0x5160
movq %r12, %rdi
movq %r13, %rsi
callq 0x3b10
movq %r12, %rdi
callq 0x3a94
leal (,%rbp,4), %edx
cmpl $0x7ffffffc, %edx       # imm = 0x7FFFFFFC
je 0x53a6
movslq %edx, %rcx
addl $0x4, %edx
movslq %edx, %rdx
xorl %esi, %esi
xorl %edi, %edi
movq (%r14,%rcx,8), %r8
movb (%r8,%rdi), %r8b
movq (%rax,%rdi,8), %r9
xorb %r8b, (%r9,%rsi)
incq %rdi
cmpq $0x4, %rdi
jne 0x5382
incq %rcx
incq %rsi
cmpq %rdx, %rcx
jl 0x5380
incq %rbp
movslq 0x1c(%r15), %rax
cmpq %rax, %rbp
jl 0x52e8
leaq 0x8(%rsp), %rdi
callq 0x3a94
xorl %ecx, %ecx
leaq 0x20a7(%rip), %rdx      # 0x7470
movq (%rax,%rcx,8), %rsi
xorl %edi, %edi
movzbl (%rsi,%rdi), %r8d
movl %r8d, %r9d
andl $0xf, %r9d
andl $-0x10, %r8d
addq %rdx, %r8
movb (%r9,%r8), %r8b
movb %r8b, (%rsi,%rdi)
incq %rdi
cmpq $0x4, %rdi
jne 0x53cf
incq %rcx
cmpq $0x4, %rcx
jne 0x53c9
leaq 0x8(%rsp), %rdi
callq 0x3a94
movq %rax, %rsi
callq 0x5020
movl 0x1c(%r15), %ebx
leaq 0x8(%rsp), %rdi
callq 0x3a94
shll $0x2, %ebx
cmpl $0x7ffffffc, %ebx       # imm = 0x7FFFFFFC
je 0x5458
movslq %ebx, %rcx
addl $0x4, %ebx
movslq %ebx, %rdx
xorl %esi, %esi
xorl %edi, %edi
movq (%r14,%rcx,8), %r8
movb (%r8,%rdi), %r8b
movq (%rax,%rdi,8), %r9
xorb %r8b, (%r9,%rsi)
incq %rdi
cmpq $0x4, %rdi
jne 0x5434
incq %rcx
incq %rsi
cmpq %rdx, %rcx
jl 0x5432
leaq 0x8(%rsp), %rdi
callq 0x3a98
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x327e
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x3a72
movq %rbx, %rdi
callq 0x3a72
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5495
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3a72
movq %rbx, %rdi
callq 0x2400