// File: /workspace/github_cpp_makefile_star2_O3/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 0x8568
movl (%rbx), %ecx
movl 0x8(%rbx), %esi
movl %ecx, %eax
imull %esi, %eax
cmpl %eax, %ecx
jge 0xd211
movslq %ecx, %rdi
movb 0xc(%rbx,%rdi,4), %r11b
movb 0xd(%rbx,%rdi,4), %dl
leaq 0x1(,%rdi,4), %rax
movq %rax, 0x18(%rsp)
leaq 0x2(,%rdi,4), %rax
movq %rax, 0x10(%rsp)
movb 0xe(%rbx,%rdi,4), %r9b
leaq 0x3(,%rdi,4), %rax
movq %rax, 0x8(%rsp)
movq %rdi, 0x20(%rsp)
movb 0xf(%rbx,%rdi,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 0xce3c
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 0xce78
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 0xceb5
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 0xcef3
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 0xcf31
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 0xcf6b
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 0xcfaf
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 0xcff1
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 0xd034
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 0xd073
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 0xd0b0
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 0xd0e5
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 0xd117
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 0xd146
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 0xd176
xorb %r12b, %r11b
movb $0xe, %cl
movl $0xfffffff8, %r15d      # imm = 0xFFFFFFF8
xorl %r9d, %r9d
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 0xd1a8
xorb %r10b, %r11b
xorb %r9b, %r11b
movq 0x20(%rsp), %rdi
movb %r8b, 0xc(%rbx,%rdi,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 %rdi
movl (%rbx), %ecx
movl 0x8(%rbx), %esi
movl %ecx, %eax
imull %esi, %eax
cltq
cmpq %rax, %rdi
jl 0xcdef
cmpl $0x2, %esi
jl 0xd26d
xorl %eax, %eax
xorl %edx, %edx
testl %ecx, %ecx
jle 0xd25c
xorl %esi, %esi
movl %edx, %edi
imull %ecx, %edi
movslq %edi, %rdi
addq %rsi, %rdi
movl 0x8(%rbx), %r8d
addl %eax, %r8d
imull %ecx, %r8d
movslq %r8d, %rcx
addq %rsi, %rcx
movl 0xc(%rbx,%rdi,4), %r8d
movl 0xc(%rbx,%rcx,4), %r9d
movl %r9d, 0xc(%rbx,%rdi,4)
movl %r8d, 0xc(%rbx,%rcx,4)
movl (%rbx), %ecx
incq %rsi
cmpl %ecx, %esi
jl 0xd220
movl 0x8(%rbx), %esi
incl %edx
movl %esi, %edi
shrl $0x1f, %edi
addl %esi, %edi
sarl %edi
decl %eax
cmpl %edi, %edx
jl 0xd21a
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq