// File: /workspace/github_cpp_makefile_star2_O3/lmclaramunt[P]AES-Crypto/Cipher.cpp
// Function: Cipher::decrypt(Sequence*, unsigned char**)
void Cipher::decrypt(Sequence* input, unsigned char** key){
    State state(input);
    addRoudKey(Nr, key, state.getStateArray());

    for (int i=Nr-1; i > 0; i--) {
        unsigned char** s2 = new unsigned char*[4];
        invShiftRows(state.getStateArray());
        invSubBytes(state.getStateArray());
        addRoudKey(i, key, state.getStateArray());
        invMixColumns(state.getStateArray(), s2);
        state.setStateArray(s2);
    }

    invShiftRows(state.getStateArray());
    invSubBytes(state.getStateArray());
    addRoudKey(0, 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
pushq %rax
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movq %rsp, %r12
movq %r12, %rdi
callq 0x39f8
movl 0x1c(%r15), %ebp
movq %r12, %rdi
callq 0x3a94
shll $0x2, %ebp
cmpl $0x7ffffffc, %ebp       # imm = 0x7FFFFFFC
je 0x5669
movslq %ebp, %rcx
addl $0x4, %ebp
movslq %ebp, %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 0x5645
incq %rcx
incq %rsi
cmpq %rdx, %rcx
jl 0x5643
movslq 0x1c(%r15), %rbp
movq %rsp, %r15
leaq 0x1ef9(%rip), %r13      # 0x7570
cmpq $0x1, %rbp
jle 0x5747
movl $0x20, %edi
callq 0x2030
movq %rax, %r12
movq %r15, %rdi
callq 0x3a94
movq %rax, %rsi
callq 0x54aa
movq %r15, %rdi
callq 0x3a94
decq %rbp
xorl %ecx, %ecx
xorl %edx, %edx
movq (%rax,%rcx,8), %rsi
movzbl (%rsi,%rdx), %edi
movl %edi, %r8d
andl $0xf, %r8d
andl $-0x10, %edi
addq %r13, %rdi
movb (%r8,%rdi), %dil
movb %dil, (%rsi,%rdx)
incq %rdx
cmpq $0x4, %rdx
jne 0x56ad
incq %rcx
cmpq $0x4, %rcx
jne 0x56ab
movq %r15, %rdi
callq 0x3a94
leal (,%rbp,4), %edx
cmpl $0x7ffffffc, %edx       # imm = 0x7FFFFFFC
je 0x5724
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 0x5700
incq %rcx
incq %rsi
cmpq %rdx, %rcx
jl 0x56fe
movq %r15, %rdi
callq 0x3a94
movq %rax, %rsi
movq %r12, %rdx
callq 0x5560
movq %r15, %rdi
movq %r12, %rsi
callq 0x3b10
jmp 0x5677
movq %rsp, %rdi
callq 0x3a94
movq %rax, %rsi
callq 0x54aa
movq %rsp, %rdi
callq 0x3a94
xorl %ecx, %ecx
xorl %edx, %edx
movq (%rax,%rcx,8), %rsi
movzbl (%rsi,%rdx), %edi
movl %edi, %r8d
andl $0xf, %r8d
andl $-0x10, %edi
addq %r13, %rdi
movb (%r8,%rdi), %dil
movb %dil, (%rsi,%rdx)
incq %rdx
cmpq $0x4, %rdx
jne 0x5763
incq %rcx
cmpq $0x4, %rcx
jne 0x5761
movq %rsp, %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 0x579e
incq %rcx
cmpq $0x4, %rcx
jne 0x579c
movq %rsp, %rdi
callq 0x3a98
movq %rbx, %rdi
movq %rax, %rsi
callq 0x327e
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x3a72
movq %rbx, %rdi
callq 0x3a72
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x57f7
movq %rax, %rbx
movq %rsp, %rdi
callq 0x3a72
movq %rbx, %rdi
callq 0x2400