// File: /workspace/github_cpp_makefile_star2_O1/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 0x5dd4
leaq 0xc(%rbx), %rax
movl (%rbx), %edx
movq %rbx, (%rsp)
movl 0x8(%rbx), %esi
movl %edx, %ecx
imull %esi, %ecx
cmpl %ecx, %edx
jge 0xabdc
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 0xa7f1
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 0xa82c
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 0xa868
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 0xa8a7
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 0xa8e5
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 0xa920
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 0xa963
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 0xa9a6
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 0xa9e8
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 0xaa24
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 0xaa5c
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 0xaa95
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 0xaacb
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 0xaafd
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 0xab33
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 0xab69
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 0xa7a5
cmpl $0x2, %esi
jl 0xac35
movl %esi, %r8d
shrl %esi
movslq %edx, %rcx
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 0xac27
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 0xac0f
incq %r10
addq %r9, %r8
addq %rcx, %rax
cmpq %rsi, %r10
jne 0xac08
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq