// File: /workspace/github_cpp_makefile_star2_O1/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 0x39e0
movl 0x1c(%r15), %ebp
movq %r12, %rdi
callq 0x3a7c
shll $0x2, %ebp
cmpl $0x7ffffffc, %ebp       # imm = 0x7FFFFFFC
je 0x564f
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 0x562b
incq %rcx
incq %rsi
cmpq %rdx, %rcx
jl 0x5629
movslq 0x1c(%r15), %rbp
movq %rsp, %r15
leaq 0x1eb3(%rip), %r13      # 0x7510
cmpq $0x1, %rbp
jle 0x572d
movl $0x20, %edi
callq 0x2030
movq %rax, %r12
movq %r15, %rdi
callq 0x3a7c
movq %rax, %rsi
callq 0x5490
movq %r15, %rdi
callq 0x3a7c
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 0x5693
incq %rcx
cmpq $0x4, %rcx
jne 0x5691
movq %r15, %rdi
callq 0x3a7c
leal (,%rbp,4), %edx
cmpl $0x7ffffffc, %edx       # imm = 0x7FFFFFFC
je 0x570a
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 0x56e6
incq %rcx
incq %rsi
cmpq %rdx, %rcx
jl 0x56e4
movq %r15, %rdi
callq 0x3a7c
movq %rax, %rsi
movq %r12, %rdx
callq 0x5544
movq %r15, %rdi
movq %r12, %rsi
callq 0x3af8
jmp 0x565d
movq %rsp, %rdi
callq 0x3a7c
movq %rax, %rsi
callq 0x5490
movq %rsp, %rdi
callq 0x3a7c
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 0x5749
incq %rcx
cmpq $0x4, %rcx
jne 0x5747
movq %rsp, %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 0x5784
incq %rcx
cmpq $0x4, %rcx
jne 0x5782
movq %rsp, %rdi
callq 0x3a80
movq %rbx, %rdi
movq %rax, %rsi
callq 0x327e
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x3a5a
movq %rbx, %rdi
callq 0x3a5a
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x57dd
movq %rax, %rbx
movq %rsp, %rdi
callq 0x3a5a
movq %rbx, %rdi
callq 0x2400