// File: /workspace/github_cpp_makefile_star2_O1/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 0x39e0
movq %r12, %rdi
callq 0x3a7c
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 0x5290
incq %rcx
cmpq $0x4, %rcx
jne 0x528e
cmpl $0x2, 0x1c(%r15)
jl 0x539c
movl $0x1, %ebp
leaq 0x8(%rsp), %r12
leaq 0x2142(%rip), %rbx      # 0x7410
movl $0x20, %edi
callq 0x2030
movq %rax, %r13
movq %r12, %rdi
callq 0x3a7c
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 0x52eb
incq %rcx
cmpq $0x4, %rcx
jne 0x52e5
movq %r12, %rdi
callq 0x3a7c
movq %rax, %rsi
callq 0x500e
movq %r12, %rdi
callq 0x3a7c
movq %rax, %rsi
movq %r13, %rdx
callq 0x514c
movq %r12, %rdi
movq %r13, %rsi
callq 0x3af8
movq %r12, %rdi
callq 0x3a7c
leal (,%rbp,4), %edx
cmpl $0x7ffffffc, %edx       # imm = 0x7FFFFFFC
je 0x538c
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 0x5368
incq %rcx
incq %rsi
cmpq %rdx, %rcx
jl 0x5366
incq %rbp
movslq 0x1c(%r15), %rax
cmpq %rax, %rbp
jl 0x52ce
leaq 0x8(%rsp), %rdi
callq 0x3a7c
xorl %ecx, %ecx
leaq 0x2061(%rip), %rdx      # 0x7410
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 0x53b5
incq %rcx
cmpq $0x4, %rcx
jne 0x53af
leaq 0x8(%rsp), %rdi
callq 0x3a7c
movq %rax, %rsi
callq 0x500e
movl 0x1c(%r15), %ebx
leaq 0x8(%rsp), %rdi
callq 0x3a7c
shll $0x2, %ebx
cmpl $0x7ffffffc, %ebx       # imm = 0x7FFFFFFC
je 0x543e
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 0x541a
incq %rcx
incq %rsi
cmpq %rdx, %rcx
jl 0x5418
leaq 0x8(%rsp), %rdi
callq 0x3a80
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x327e
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x3a5a
movq %rbx, %rdi
callq 0x3a5a
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x547b
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3a5a
movq %rbx, %rdi
callq 0x2400