// File: /workspace/github_cpp_makefile_star2_O1/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:
movslq 0x4(%rdi), %rcx
cmpq $0x7, %rcx
jge 0x897e
testl %ecx, %ecx
jle 0x88cc
leal (,%rcx,4), %eax
xorl %edx, %edx
movb (%rsi,%rdx), %r8b
movb %r8b, 0xc(%rdi,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x88bb
movl 0x8(%rdi), %eax
incl %eax
imull (%rdi), %eax
cmpl %eax, %ecx
jge 0x897d
leaq 0x130dd(%rip), %rsi     # 0x1b9c0
movl $0xff, %r8d
leaq 0xefd0(%rip), %r9       # 0x178c0
movl 0x8(%rdi,%rcx,4), %r10d
movslq 0x4(%rdi), %r11
movl %ecx, %eax
cltd
idivl %r11d
testl %edx, %edx
jne 0x894f
roll $0x18, %r10d
movl %r10d, %eax
shrl $0x18, %eax
movzbl (%rax,%rsi), %eax
movl %r10d, %edx
shrl $0x10, %edx
andl %r8d, %edx
movzbl (%rdx,%rsi), %edx
shll $0x10, %eax
shll $0x8, %edx
orl %eax, %edx
movl %r10d, %eax
shrl $0x8, %eax
andl %r8d, %eax
movzbl (%rax,%rsi), %eax
orl %edx, %eax
shll $0x8, %eax
andl %r8d, %r10d
movzbl (%r10,%rsi), %r10d
orl %eax, %r10d
movl %ecx, %eax
cltd
idivl %r11d
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 0x88f0
retq
leal (,%rcx,4), %edx
cmpl $0x2, %edx
movl $0x1, %eax
cmovgel %edx, %eax
xorl %edx, %edx
movb (%rsi,%rdx), %r8b
movb %r8b, 0xc(%rdi,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x8992
movslq (%rdi), %rax
movslq 0x8(%rdi), %rsi
incq %rsi
imulq %rax, %rsi
cmpl %esi, %ecx
jge 0x897d
pushq %r14
pushq %rbx
movslq 0x4(%rdi), %r8
movl 0x8(%rdi,%rcx,4), %r9d
movq %r8, %rax
shlq $0x2, %rax
negq %rax
leaq (%rdi,%rax), %r10
addq $0xc, %r10
leaq 0x12fe6(%rip), %r11     # 0x1b9c0
movl $0xff, %ebx
leaq 0xeeda(%rip), %r14      # 0x178c0
movl %ecx, %eax
cltd
idivl %r8d
cmpl $0x4, %edx
je 0x8a48
testl %edx, %edx
jne 0x8a85
roll $0x18, %r9d
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
movl %ecx, %eax
cltd
idivl %r8d
cltq
xorl (%r14,%rax,4), %r9d
jmp 0x8a85
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 (%r10,%rcx,4), %r9d
movl %r9d, 0xc(%rdi,%rcx,4)
incq %rcx
cmpq %rcx, %rsi
jne 0x89e6
popq %rbx
popq %r14
retq