// File: /workspace/github_cpp_makefile_star2_O3/rellla[P]E3DC-Rscp/AES.cpp
// Function: AES::StartDecryption(unsigned char const*)
void AES::StartDecryption(const unsigned char * key)
	{
	memset(iv, 0xff, sizeof(iv));
	KeyExpansion(key);

	unsigned char a0,a1,a2,a3,b0,b1,b2,b3, * W_ptr = W;

	for (int col = Nb; col < (Nr)*Nb; col++) // do all but first and last round
		{
		a0 = W_ptr[4*col+0];
		a1 = W_ptr[4*col+1];
		a2 = W_ptr[4*col+2];
		a3 = W_ptr[4*col+3];

		b0 = GF2_8_mult(0x0E,a0)^GF2_8_mult(0x0B,a1)^
		     GF2_8_mult(0x0D,a2)^GF2_8_mult(0x09,a3);
		b1 = GF2_8_mult(0x09,a0)^GF2_8_mult(0x0E,a1)^
		     GF2_8_mult(0x0B,a2)^GF2_8_mult(0x0D,a3);
		b2 = GF2_8_mult(0x0D,a0)^GF2_8_mult(0x09,a1)^
		     GF2_8_mult(0x0E,a2)^GF2_8_mult(0x0B,a3);
		b3 = GF2_8_mult(0x0B,a0)^GF2_8_mult(0x0D,a1)^
		     GF2_8_mult(0x09,a2)^GF2_8_mult(0x0E,a3);

		W_ptr[4*col+0] = b0;
		W_ptr[4*col+1] = b1;
		W_ptr[4*col+2] = b2;
		W_ptr[4*col+3] = b3;
		}

	// we reverse the rounds to make decryption faster
	unsigned long * WL = reinterpret_cast<unsigned long*>(W);
	for (int pos = 0; pos < Nr/2; pos++)
		for (int col = 0; col < Nb; col++)
			swap(WL[col+pos*Nb],WL[col+(Nr-pos)*Nb]);
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x1fc(%rdi)
movdqu %xmm0, 0x1ec(%rdi)
callq 0x5b6c
leaq 0xc(%rbx), %rax
movl (%rbx), %edx
movq %rbx, (%rsp)
movl 0x8(%rbx), %esi
movl %edx, %ecx
imull %esi, %ecx
cmpl %ecx, %edx
jge 0xa96e
movslq %edx, %r8
movb (%rax,%r8,4), %bpl
movb 0x1(%rax,%r8,4), %dil
leaq 0x1(,%r8,4), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x2(,%r8,4), %rcx
movq %rcx, 0x10(%rsp)
movb 0x2(%rax,%r8,4), %r10b
leaq 0x3(,%r8,4), %rcx
movq %rcx, 0x8(%rsp)
movq %r8, 0x20(%rsp)
movb 0x3(%rax,%r8,4), %r8b
movb $0xe, %r9b
movl $0xfffffff8, %edx       # imm = 0xFFFFFFF8
xorl %r14d, %r14d
movl %ebp, %esi
movl %esi, %r11d
andb $0x1, %r11b
negb %r11b
andb %r9b, %r11b
xorb %r11b, %r14b
leal (%r9,%r9), %r11d
movzbl %r11b, %r15d
xorb $0x1b, %r11b
testb %r9b, %r9b
movzbl %r11b, %r9d
cmovnsl %r15d, %r9d
shrb %sil
incl %edx
jne 0xa583
movb $0xb, %r15b
movl $0xfffffff8, %edx       # imm = 0xFFFFFFF8
xorl %r9d, %r9d
movl %edi, %esi
movl %esi, %r11d
andb $0x1, %r11b
negb %r11b
andb %r15b, %r11b
xorb %r11b, %r9b
leal (%r15,%r15), %r11d
movzbl %r11b, %r12d
xorb $0x1b, %r11b
testb %r15b, %r15b
movzbl %r11b, %r15d
cmovnsl %r12d, %r15d
shrb %sil
incl %edx
jne 0xa5be
movb $0xd, %r15b
movl $0xfffffff8, %edx       # imm = 0xFFFFFFF8
xorl %r12d, %r12d
movl %r10d, %esi
movl %esi, %r11d
andb $0x1, %r11b
negb %r11b
andb %r15b, %r11b
xorb %r11b, %r12b
leal (%r15,%r15), %r11d
movzbl %r11b, %r13d
xorb $0x1b, %r11b
testb %r15b, %r15b
movzbl %r11b, %r15d
cmovnsl %r13d, %r15d
shrb %sil
incl %edx
jne 0xa5fa
xorb %r14b, %r9b
movb $0x9, %r14b
movl $0xfffffff8, %edx       # imm = 0xFFFFFFF8
xorl %r15d, %r15d
movl %r8d, %esi
movl %esi, %r11d
andb $0x1, %r11b
negb %r11b
andb %r14b, %r11b
xorb %r11b, %r15b
leal (%r14,%r14), %r11d
movzbl %r11b, %r13d
xorb $0x1b, %r11b
testb %r14b, %r14b
movzbl %r11b, %r14d
cmovnsl %r13d, %r14d
shrb %sil
incl %edx
jne 0xa639
xorb %r12b, %r9b
movb $0x9, %r14b
movl $0xfffffff8, %edx       # imm = 0xFFFFFFF8
xorl %r12d, %r12d
movl %ebp, %esi
movl %esi, %r11d
andb $0x1, %r11b
negb %r11b
andb %r14b, %r11b
xorb %r11b, %r12b
leal (%r14,%r14), %r11d
movzbl %r11b, %r13d
xorb $0x1b, %r11b
testb %r14b, %r14b
movzbl %r11b, %r14d
cmovnsl %r13d, %r14d
shrb %sil
incl %edx
jne 0xa677
movb $0xe, %r13b
movl $0xfffffff8, %edx       # imm = 0xFFFFFFF8
xorl %r14d, %r14d
movl %edi, %esi
movl %esi, %r11d
andb $0x1, %r11b
negb %r11b
andb %r13b, %r11b
xorb %r11b, %r14b
leal (,%r13,2), %r11d
movzbl %r11b, %ebx
xorb $0x1b, %r11b
testb %r13b, %r13b
movzbl %r11b, %r13d
cmovnsl %ebx, %r13d
shrb %sil
incl %edx
jne 0xa6b2
xorb %r15b, %r9b
movb $0xb, %r13b
movl $0xfffffff8, %edx       # imm = 0xFFFFFFF8
xorl %r15d, %r15d
movl %r10d, %esi
movl %esi, %r11d
andb $0x1, %r11b
negb %r11b
andb %r13b, %r11b
xorb %r11b, %r15b
leal (,%r13,2), %r11d
movzbl %r11b, %ebx
xorb $0x1b, %r11b
testb %r13b, %r13b
movzbl %r11b, %r13d
cmovnsl %ebx, %r13d
shrb %sil
incl %edx
jne 0xa6f5
xorb %r12b, %r14b
movb $0xd, %r13b
movl $0xfffffff8, %edx       # imm = 0xFFFFFFF8
xorl %r12d, %r12d
movl %r8d, %esi
movl %esi, %r11d
andb $0x1, %r11b
negb %r11b
andb %r13b, %r11b
xorb %r11b, %r12b
leal (,%r13,2), %r11d
movzbl %r11b, %ebx
xorb $0x1b, %r11b
testb %r13b, %r13b
movzbl %r11b, %r13d
cmovnsl %ebx, %r13d
shrb %sil
incl %edx
jne 0xa738
xorb %r15b, %r14b
movb $0xd, %r15b
movl $0xfffffff8, %edx       # imm = 0xFFFFFFF8
xorl %r13d, %r13d
movl %ebp, %esi
movl %esi, %r11d
andb $0x1, %r11b
negb %r11b
andb %r15b, %r11b
xorb %r11b, %r13b
leal (%r15,%r15), %r11d
movzbl %r11b, %ebx
xorb $0x1b, %r11b
testb %r15b, %r15b
movzbl %r11b, %r15d
cmovnsl %ebx, %r15d
shrb %sil
incl %edx
jne 0xa77a
movb $0x9, %sil
movl $0xfffffff8, %edx       # imm = 0xFFFFFFF8
xorl %r15d, %r15d
movl %edi, %r11d
movl %r11d, %ebx
andb $0x1, %bl
negb %bl
andb %sil, %bl
xorb %bl, %r15b
leal (%rsi,%rsi), %ebx
movzbl %bl, %ecx
xorb $0x1b, %bl
testb %sil, %sil
movzbl %bl, %esi
cmovnsl %ecx, %esi
shrb %r11b
incl %edx
jne 0xa7b6
xorb %r12b, %r14b
movb $0xe, %sil
movl $0xfffffff8, %r12d      # imm = 0xFFFFFFF8
xorl %edx, %edx
movl %r10d, %r11d
movl %r11d, %ecx
andb $0x1, %cl
negb %cl
andb %sil, %cl
xorb %cl, %dl
leal (%rsi,%rsi), %ecx
movzbl %cl, %ebx
xorb $0x1b, %cl
testb %sil, %sil
movzbl %cl, %esi
cmovnsl %ebx, %esi
shrb %r11b
incl %r12d
jne 0xa7ee
xorb %r13b, %r15b
movb $0xb, %sil
movl $0xfffffff8, %r13d      # imm = 0xFFFFFFF8
xorl %r12d, %r12d
movl %r8d, %r11d
movl %r11d, %ecx
andb $0x1, %cl
negb %cl
andb %sil, %cl
xorb %cl, %r12b
leal (%rsi,%rsi), %ecx
movzbl %cl, %ebx
xorb $0x1b, %cl
testb %sil, %sil
movzbl %cl, %esi
cmovnsl %ebx, %esi
shrb %r11b
incl %r13d
jne 0xa827
xorb %dl, %r15b
movb $0xb, %sil
movl $0xfffffff8, %edx       # imm = 0xFFFFFFF8
xorl %r13d, %r13d
movl %ebp, %ecx
andb $0x1, %cl
negb %cl
andb %sil, %cl
xorb %cl, %r13b
leal (%rsi,%rsi), %ecx
movzbl %cl, %r11d
xorb $0x1b, %cl
testb %sil, %sil
movzbl %cl, %esi
cmovnsl %r11d, %esi
shrb %bpl
incl %edx
jne 0xa85d
movb $0xd, %sil
movl $0xfffffff8, %edx       # imm = 0xFFFFFFF8
xorl %ebp, %ebp
movl %edi, %ecx
andb $0x1, %cl
negb %cl
andb %sil, %cl
xorb %cl, %bpl
leal (%rsi,%rsi), %ecx
movzbl %cl, %r11d
xorb $0x1b, %cl
testb %sil, %sil
movzbl %cl, %esi
cmovnsl %r11d, %esi
shrb %dil
incl %edx
jne 0xa88f
xorb %r12b, %r15b
movb $0x9, %sil
movl $0xfffffff8, %r11d      # imm = 0xFFFFFFF8
xorl %edx, %edx
movl %r10d, %ecx
andb $0x1, %cl
negb %cl
andb %sil, %cl
xorb %cl, %dl
leal (%rsi,%rsi), %ecx
movzbl %cl, %edi
xorb $0x1b, %cl
testb %sil, %sil
movzbl %cl, %esi
cmovnsl %edi, %esi
shrb %r10b
incl %r11d
jne 0xa8c5
xorb %r13b, %bpl
movb $0xe, %sil
movl $0xfffffff8, %r11d      # imm = 0xFFFFFFF8
xorl %r10d, %r10d
movl %r8d, %ecx
andb $0x1, %cl
negb %cl
andb %sil, %cl
xorb %cl, %r10b
leal (%rsi,%rsi), %ecx
movzbl %cl, %edi
xorb $0x1b, %cl
testb %sil, %sil
movzbl %cl, %esi
cmovnsl %edi, %esi
shrb %r8b
incl %r11d
jne 0xa8fb
xorb %dl, %bpl
xorb %r10b, %bpl
movq (%rsp), %rcx
movq 0x20(%rsp), %r8
movb %r9b, 0xc(%rcx,%r8,4)
movq 0x18(%rsp), %rdx
movb %r14b, 0xc(%rcx,%rdx)
movq 0x10(%rsp), %rdx
movb %r15b, 0xc(%rcx,%rdx)
movq 0x8(%rsp), %rdx
movb %bpl, 0xc(%rcx,%rdx)
incq %r8
movl (%rcx), %edx
movl 0x8(%rcx), %esi
movl %edx, %ecx
imull %esi, %ecx
movslq %ecx, %rcx
cmpq %rcx, %r8
jl 0xa537
cmpl $0x2, %esi
jl 0xa9c7
movslq %edx, %rcx
movl %esi, %r8d
shrl %esi
movl %ecx, %edi
imulq %rcx, %r8
movq (%rsp), %r9
leaq (%r9,%r8,8), %r8
addq $0xc, %r8
shlq $0x3, %rcx
movq %rcx, %r9
negq %r9
xorl %r10d, %r10d
testl %edx, %edx
jle 0xa9b9
xorl %r11d, %r11d
movq (%rax,%r11,8), %rbx
movq (%r8,%r11,8), %r14
movq %r14, (%rax,%r11,8)
movq %rbx, (%r8,%r11,8)
incq %r11
cmpq %r11, %rdi
jne 0xa9a1
incq %r10
addq %r9, %r8
addq %rcx, %rax
cmpq %rsi, %r10
jne 0xa99a
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq