// File: /workspace/github_cpp_makefile_star2_O1/bummelbaerchen[P]e3dc/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
	uint32_t * WL = reinterpret_cast<uint32_t*>(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 0x88a0
movslq (%rbx), %rsi
movl 0x8(%rbx), %ecx
imull %esi, %ecx
cmpl %ecx, %esi
jge 0xd550
movb 0xc(%rbx,%rsi,4), %r11b
movb 0xd(%rbx,%rsi,4), %dl
leaq 0x1(,%rsi,4), %rax
movq %rax, 0x18(%rsp)
leaq 0x2(,%rsi,4), %rax
movq %rax, 0x10(%rsp)
movb 0xe(%rbx,%rsi,4), %r9b
leaq 0x3(,%rsi,4), %rax
movq %rax, 0x8(%rsp)
movb 0xf(%rbx,%rsi,4), %dil
movb $0xe, %r14b
movl $0xfffffff8, %r8d       # imm = 0xFFFFFFF8
xorl %ebp, %ebp
movl %r11d, %ecx
movl %ecx, %r10d
andb $0x1, %r10b
negb %r10b
andb %r14b, %r10b
xorb %r10b, %bpl
leal (%r14,%r14), %r10d
movzbl %r10b, %r15d
xorb $0x1b, %r10b
testb %r14b, %r14b
movzbl %r10b, %r14d
cmovnsl %r15d, %r14d
shrb %cl
incl %r8d
jne 0xd177
movb $0xb, %r15b
movl $0xfffffff8, %r14d      # imm = 0xFFFFFFF8
xorl %r8d, %r8d
movl %edx, %ecx
movl %ecx, %r10d
andb $0x1, %r10b
negb %r10b
andb %r15b, %r10b
xorb %r10b, %r8b
leal (%r15,%r15), %r10d
movzbl %r10b, %r12d
xorb $0x1b, %r10b
testb %r15b, %r15b
movzbl %r10b, %r15d
cmovnsl %r12d, %r15d
shrb %cl
incl %r14d
jne 0xd1b3
movb $0xd, %r12b
movl $0xfffffff8, %r14d      # imm = 0xFFFFFFF8
xorl %r15d, %r15d
movl %r9d, %ecx
movl %ecx, %r10d
andb $0x1, %r10b
negb %r10b
andb %r12b, %r10b
xorb %r10b, %r15b
leal (%r12,%r12), %r10d
movzbl %r10b, %r13d
xorb $0x1b, %r10b
testb %r12b, %r12b
movzbl %r10b, %r12d
cmovnsl %r13d, %r12d
shrb %cl
incl %r14d
jne 0xd1f0
xorb %bpl, %r8b
movb $0x9, %r12b
movl $0xfffffff8, %ebp       # imm = 0xFFFFFFF8
xorl %r14d, %r14d
movl %edi, %ecx
movl %ecx, %r10d
andb $0x1, %r10b
negb %r10b
andb %r12b, %r10b
xorb %r10b, %r14b
leal (%r12,%r12), %r10d
movzbl %r10b, %r13d
xorb $0x1b, %r10b
testb %r12b, %r12b
movzbl %r10b, %r12d
cmovnsl %r13d, %r12d
shrb %cl
incl %ebp
jne 0xd22e
movq %rsi, 0x20(%rsp)
xorb %r15b, %r8b
movb $0x9, %r12b
movl $0xfffffff8, %ebp       # imm = 0xFFFFFFF8
xorl %r15d, %r15d
movl %r11d, %ecx
movl %ecx, %r10d
andb $0x1, %r10b
negb %r10b
andb %r12b, %r10b
xorb %r10b, %r15b
leal (%r12,%r12), %r10d
movzbl %r10b, %r13d
xorb $0x1b, %r10b
testb %r12b, %r12b
movzbl %r10b, %r12d
cmovnsl %r13d, %r12d
shrb %cl
incl %ebp
jne 0xd271
movb $0xe, %r13b
movl $0xfffffff8, %r12d      # imm = 0xFFFFFFF8
xorl %ebp, %ebp
movl %edx, %ecx
movl %ecx, %r10d
andb $0x1, %r10b
negb %r10b
andb %r13b, %r10b
xorb %r10b, %bpl
leal (,%r13,2), %r10d
movzbl %r10b, %esi
xorb $0x1b, %r10b
testb %r13b, %r13b
movzbl %r10b, %r13d
cmovnsl %esi, %r13d
shrb %cl
incl %r12d
jne 0xd2ab
xorb %r14b, %r8b
movb $0xb, %r13b
movl $0xfffffff8, %r12d      # imm = 0xFFFFFFF8
xorl %r14d, %r14d
movl %r9d, %ecx
movl %ecx, %esi
andb $0x1, %sil
negb %sil
andb %r13b, %sil
xorb %sil, %r14b
leal (,%r13,2), %esi
movzbl %sil, %r10d
xorb $0x1b, %sil
testb %r13b, %r13b
movzbl %sil, %r13d
cmovnsl %r10d, %r13d
shrb %cl
incl %r12d
jne 0xd2ef
xorb %r15b, %bpl
movb $0xd, %r13b
movl $0xfffffff8, %r12d      # imm = 0xFFFFFFF8
xorl %r15d, %r15d
movl %edi, %ecx
movl %ecx, %esi
andb $0x1, %sil
negb %sil
andb %r13b, %sil
xorb %sil, %r15b
leal (,%r13,2), %esi
movzbl %sil, %r10d
xorb $0x1b, %sil
testb %r13b, %r13b
movzbl %sil, %r13d
cmovnsl %r10d, %r13d
shrb %cl
incl %r12d
jne 0xd331
xorb %r14b, %bpl
movb $0xd, %r13b
movl $0xfffffff8, %r14d      # imm = 0xFFFFFFF8
xorl %r12d, %r12d
movl %r11d, %ecx
movl %ecx, %esi
andb $0x1, %sil
negb %sil
andb %r13b, %sil
xorb %sil, %r12b
leal (,%r13,2), %esi
movzbl %sil, %r10d
xorb $0x1b, %sil
testb %r13b, %r13b
movzbl %sil, %r13d
cmovnsl %r10d, %r13d
shrb %cl
incl %r14d
jne 0xd374
movb $0x9, %cl
movl $0xfffffff8, %r13d      # imm = 0xFFFFFFF8
xorl %r14d, %r14d
movl %edx, %r10d
movl %r10d, %esi
andb $0x1, %sil
negb %sil
andb %cl, %sil
xorb %sil, %r14b
leal (%rcx,%rcx), %esi
movzbl %sil, %eax
xorb $0x1b, %sil
testb %cl, %cl
movzbl %sil, %ecx
cmovnsl %eax, %ecx
shrb %r10b
incl %r13d
jne 0xd3b3
xorb %r15b, %bpl
movb $0xe, %cl
movl $0xfffffff8, %r15d      # imm = 0xFFFFFFF8
xorl %r13d, %r13d
movl %r9d, %r10d
movl %r10d, %eax
andb $0x1, %al
negb %al
andb %cl, %al
xorb %al, %r13b
leal (%rcx,%rcx), %eax
movzbl %al, %esi
xorb $0x1b, %al
testb %cl, %cl
movzbl %al, %ecx
cmovnsl %esi, %ecx
shrb %r10b
incl %r15d
jne 0xd3f0
xorb %r12b, %r14b
movb $0xb, %cl
movl $0xfffffff8, %r12d      # imm = 0xFFFFFFF8
xorl %r15d, %r15d
movl %edi, %r10d
movl %r10d, %eax
andb $0x1, %al
negb %al
andb %cl, %al
xorb %al, %r15b
leal (%rcx,%rcx), %eax
movzbl %al, %esi
xorb $0x1b, %al
testb %cl, %cl
movzbl %al, %ecx
cmovnsl %esi, %ecx
shrb %r10b
incl %r12d
jne 0xd425
xorb %r13b, %r14b
movb $0xb, %cl
movl $0xfffffff8, %r13d      # imm = 0xFFFFFFF8
xorl %r12d, %r12d
movl %r11d, %eax
andb $0x1, %al
negb %al
andb %cl, %al
xorb %al, %r12b
leal (%rcx,%rcx), %eax
movzbl %al, %esi
xorb $0x1b, %al
testb %cl, %cl
movzbl %al, %ecx
cmovnsl %esi, %ecx
shrb %r11b
incl %r13d
jne 0xd457
movb $0xd, %cl
movl $0xfffffff8, %r13d      # imm = 0xFFFFFFF8
xorl %r11d, %r11d
movl %edx, %eax
andb $0x1, %al
negb %al
andb %cl, %al
xorb %al, %r11b
leal (%rcx,%rcx), %eax
movzbl %al, %esi
xorb $0x1b, %al
testb %cl, %cl
movzbl %al, %ecx
cmovnsl %esi, %ecx
shrb %dl
incl %r13d
jne 0xd486
xorb %r15b, %r14b
movb $0x9, %cl
movl $0xfffffff8, %r15d      # imm = 0xFFFFFFF8
xorl %r10d, %r10d
movl %r9d, %eax
andb $0x1, %al
negb %al
andb %cl, %al
xorb %al, %r10b
leal (%rcx,%rcx), %eax
movzbl %al, %edx
xorb $0x1b, %al
testb %cl, %cl
movzbl %al, %ecx
cmovnsl %edx, %ecx
shrb %r9b
incl %r15d
jne 0xd4b6
xorb %r12b, %r11b
movb $0xe, %cl
movl $0xfffffff8, %r15d      # imm = 0xFFFFFFF8
xorl %r9d, %r9d
movq 0x20(%rsp), %rsi
movl %edi, %eax
andb $0x1, %al
negb %al
andb %cl, %al
xorb %al, %r9b
leal (%rcx,%rcx), %eax
movzbl %al, %edx
xorb $0x1b, %al
testb %cl, %cl
movzbl %al, %ecx
cmovnsl %edx, %ecx
shrb %dil
incl %r15d
jne 0xd4ed
xorb %r10b, %r11b
xorb %r9b, %r11b
movb %r8b, 0xc(%rbx,%rsi,4)
movq 0x18(%rsp), %rax
movb %bpl, 0xc(%rbx,%rax)
movq 0x10(%rsp), %rax
movb %r14b, 0xc(%rbx,%rax)
movq 0x8(%rsp), %rax
movb %r11b, 0xc(%rbx,%rax)
incq %rsi
movslq 0x8(%rbx), %rax
movslq (%rbx), %rcx
imulq %rax, %rcx
cmpq %rcx, %rsi
jl 0xd12f
cmpl $0x2, 0x8(%rbx)
jl 0xd5af
xorl %eax, %eax
xorl %ecx, %ecx
movl (%rbx), %esi
testl %esi, %esi
jle 0xd59b
xorl %edx, %edx
movl %ecx, %edi
imull %esi, %edi
movslq %edi, %rdi
addq %rdx, %rdi
movl 0x8(%rbx), %r8d
addl %eax, %r8d
imull %esi, %r8d
movslq %r8d, %rsi
addq %rdx, %rsi
movl 0xc(%rbx,%rdi,4), %r8d
movl 0xc(%rbx,%rsi,4), %r9d
movl %r9d, 0xc(%rbx,%rdi,4)
movl %r8d, 0xc(%rbx,%rsi,4)
movl (%rbx), %esi
incq %rdx
cmpl %esi, %edx
jl 0xd562
incl %ecx
movl 0x8(%rbx), %edx
movl %edx, %esi
shrl $0x1f, %esi
addl %edx, %esi
sarl %esi
decl %eax
cmpl %esi, %ecx
jl 0xd55a
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq