// File: /workspace/github_cpp_makefile_star2_O3/bummelbaerchen[P]e3dc/AES.cpp
// Function: AES::KeyExpansion(unsigned char const*)
void AES::KeyExpansion(const unsigned char * key)
	{
	int i;
	uint32_t temp, * Wb = reinterpret_cast<uint32_t*>(W); // todo not portable - Endian problems
	if (Nk <= 6)
		{
		// todo - memcpy
		for (i = 0; i < 4*Nk; i++)
			W[i] = key[i];
		for (i = Nk; i < Nb*(Nr+1); i++)
			{
			temp = Wb[i-1];
			if ((i%Nk) == 0)
				temp = SubByte(RotByte(temp)) ^ Rcon[i/Nk];
			Wb[i] = Wb[i - Nk]^temp;
			}
		}
	else
		{
		// todo - memcpy
		for (i = 0; i < 4*Nk; i++)
			W[i] = key[i];
		for (i = Nk; i < Nb*(Nr+1); i++)
			{
			temp = Wb[i-1];
			if ((i%Nk) == 0)
				temp = SubByte(RotByte(temp)) ^ Rcon[i/Nk];
			else if ((i%Nk) == 4)
				temp = SubByte(temp);
			Wb[i] = Wb[i - Nk]^temp;
			}
		}
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
movslq 0x4(%rdi), %rcx
movl %ecx, %r8d
cmpq $0x7, %rcx
jge 0x8649
testl %r8d, %r8d
jle 0x8599
shlq $0x2, %r8
xorl %eax, %eax
movb (%rsi,%rax), %dl
movb %dl, 0xc(%rdi,%rax)
incq %rax
cmpq %rax, %r8
jne 0x858a
movl 0x8(%rdi), %eax
incl %eax
imull (%rdi), %eax
cmpl %eax, %ecx
jge 0x8755
leaq 0x13410(%rip), %rsi     # 0x1b9c0
movl $0xff, %r8d
leaq 0xf303(%rip), %r9       # 0x178c0
movl 0x8(%rdi,%rcx,4), %r10d
movslq 0x4(%rdi), %r11
movl %ecx, %eax
cltd
idivl %r11d
testl %edx, %edx
jne 0x8616
roll $0x18, %r10d
movl %r10d, %edx
shrl $0x18, %edx
movzbl (%rdx,%rsi), %edx
movl %r10d, %ebx
shrl $0x10, %ebx
andl %r8d, %ebx
movzbl (%rbx,%rsi), %ebx
shll $0x10, %edx
shll $0x8, %ebx
orl %edx, %ebx
movl %r10d, %edx
shrl $0x8, %edx
andl %r8d, %edx
movzbl (%rdx,%rsi), %edx
orl %ebx, %edx
shll $0x8, %edx
andl %r8d, %r10d
movzbl (%r10,%rsi), %r10d
orl %edx, %r10d
cltq
xorl (%r9,%rax,4), %r10d
shlq $0x2, %r11
movq %rdi, %rax
subq %r11, %rax
xorl 0xc(%rax,%rcx,4), %r10d
movl %r10d, 0xc(%rdi,%rcx,4)
incq %rcx
movslq (%rdi), %rax
movslq 0x8(%rdi), %rdx
incq %rdx
imulq %rax, %rdx
cmpq %rdx, %rcx
jl 0x85bd
jmp 0x8755
leal (,%rcx,4), %edx
cmpl $0x2, %edx
movl $0x1, %eax
cmovgel %edx, %eax
xorl %edx, %edx
movb (%rsi,%rdx), %r9b
movb %r9b, 0xc(%rdi,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x865d
movslq (%rdi), %rax
movslq 0x8(%rdi), %rsi
incq %rsi
imulq %rax, %rsi
cmpl %esi, %r8d
jge 0x8755
movl 0x8(%rdi,%r8,4), %r9d
xorl %r10d, %r10d
leaq 0x1332c(%rip), %r11     # 0x1b9c0
movl $0xff, %ebx
leaq 0xf220(%rip), %r14      # 0x178c0
movl %r8d, %eax
cltd
idivl %ecx
cmpl $0x4, %edx
je 0x86fe
testl %edx, %edx
jne 0x873b
roll $0x18, %r9d
movl %r9d, %edx
shrl $0x18, %edx
movzbl (%rdx,%r11), %edx
movl %r9d, %r15d
shrl $0x10, %r15d
andl %ebx, %r15d
movzbl (%r15,%r11), %ebp
shll $0x10, %edx
shll $0x8, %ebp
orl %edx, %ebp
movl %r9d, %edx
shrl $0x8, %edx
andl %ebx, %edx
movzbl (%rdx,%r11), %edx
orl %ebp, %edx
shll $0x8, %edx
andl %ebx, %r9d
movzbl (%r9,%r11), %r9d
orl %edx, %r9d
cltq
xorl (%r14,%rax,4), %r9d
jmp 0x873b
movl %r9d, %eax
shrl $0x18, %eax
movzbl (%rax,%r11), %eax
movl %r9d, %edx
shrl $0x10, %edx
andl %ebx, %edx
movzbl (%rdx,%r11), %edx
shll $0x10, %eax
shll $0x8, %edx
orl %eax, %edx
movl %r9d, %eax
shrl $0x8, %eax
andl %ebx, %eax
movzbl (%rax,%r11), %eax
orl %edx, %eax
shll $0x8, %eax
andl %ebx, %r9d
movzbl (%r9,%r11), %r9d
orl %eax, %r9d
xorl 0xc(%rdi,%r10), %r9d
movl %r9d, 0xc(%rdi,%r8,4)
incq %r8
addq $0x4, %r10
cmpq %r8, %rsi
jne 0x86a0
popq %rbx
popq %r14
popq %r15
popq %rbp
retq