// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/aezv3/ref/rijndael-alg-fst.c
// Function: rijndaelKeySetupEnc
int rijndaelKeySetupEnc(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits) {
   	int i = 0;
	u32 temp;

	rk[0] = GETU32(cipherKey     );
	rk[1] = GETU32(cipherKey +  4);
	rk[2] = GETU32(cipherKey +  8);
	rk[3] = GETU32(cipherKey + 12);
	if (keyBits == 128) {
		for (;;) {
			temp  = rk[3];
			rk[4] = rk[0] ^
				(Te4[(temp >> 16) & 0xff] & 0xff000000) ^
				(Te4[(temp >>  8) & 0xff] & 0x00ff0000) ^
				(Te4[(temp      ) & 0xff] & 0x0000ff00) ^
				(Te4[(temp >> 24)       ] & 0x000000ff) ^
				rcon[i];
			rk[5] = rk[1] ^ rk[4];
			rk[6] = rk[2] ^ rk[5];
			rk[7] = rk[3] ^ rk[6];
			if (++i == 10) {
				return 10;
			}
			rk += 4;
		}
	}
	rk[4] = GETU32(cipherKey + 16);
	rk[5] = GETU32(cipherKey + 20);
	if (keyBits == 192) {
		for (;;) {
			temp = rk[ 5];
			rk[ 6] = rk[ 0] ^
				(Te4[(temp >> 16) & 0xff] & 0xff000000) ^
				(Te4[(temp >>  8) & 0xff] & 0x00ff0000) ^
				(Te4[(temp      ) & 0xff] & 0x0000ff00) ^
				(Te4[(temp >> 24)       ] & 0x000000ff) ^
				rcon[i];
			rk[ 7] = rk[ 1] ^ rk[ 6];
			rk[ 8] = rk[ 2] ^ rk[ 7];
			rk[ 9] = rk[ 3] ^ rk[ 8];
			if (++i == 8) {
				return 12;
			}
			rk[10] = rk[ 4] ^ rk[ 9];
			rk[11] = rk[ 5] ^ rk[10];
			rk += 6;
		}
	}
	rk[6] = GETU32(cipherKey + 24);
	rk[7] = GETU32(cipherKey + 28);
	if (keyBits == 256) {
        for (;;) {
        	temp = rk[ 7];
        	rk[ 8] = rk[ 0] ^
        		(Te4[(temp >> 16) & 0xff] & 0xff000000) ^
        		(Te4[(temp >>  8) & 0xff] & 0x00ff0000) ^
        		(Te4[(temp      ) & 0xff] & 0x0000ff00) ^
        		(Te4[(temp >> 24)       ] & 0x000000ff) ^
        		rcon[i];
        	rk[ 9] = rk[ 1] ^ rk[ 8];
        	rk[10] = rk[ 2] ^ rk[ 9];
        	rk[11] = rk[ 3] ^ rk[10];
			if (++i == 7) {
				return 14;
			}
        	temp = rk[11];
        	rk[12] = rk[ 4] ^
        		(Te4[(temp >> 24)       ] & 0xff000000) ^
        		(Te4[(temp >> 16) & 0xff] & 0x00ff0000) ^
        		(Te4[(temp >>  8) & 0xff] & 0x0000ff00) ^
        		(Te4[(temp      ) & 0xff] & 0x000000ff);
        	rk[13] = rk[ 5] ^ rk[12];
        	rk[14] = rk[ 6] ^ rk[13];
        	rk[15] = rk[ 7] ^ rk[14];

			rk += 8;
        }
	}
	return 0;
}

// Assembly:
pushq %rbx
movl (%rsi), %eax
movbel %eax, (%rdi)
movl 0x4(%rsi), %eax
movbel %eax, 0x4(%rdi)
movl 0x8(%rsi), %eax
movbel %eax, 0x8(%rdi)
movl 0xc(%rsi), %eax
movbel %eax, 0xc(%rdi)
cmpl $0x80, %edx
jne 0x2cd3
xorl %eax, %eax
leaq 0x2690(%rip), %rcx      # 0x52c0
movl $0xff, %edx
leaq 0x2a84(%rip), %rsi      # 0x56c0
movl 0xc(%rdi,%rax,4), %r8d
movl %r8d, %r9d
shrl $0xe, %r9d
andl $0x3fc, %r9d            # imm = 0x3FC
movzbl 0x3(%r9,%rcx), %r9d
shll $0x18, %r9d
xorl (%rdi,%rax,4), %r9d
movl %r8d, %r10d
shrl $0x8, %r10d
andl %edx, %r10d
movzbl 0x2(%rcx,%r10,4), %r10d
shll $0x10, %r10d
movl %r8d, %r11d
andl %edx, %r11d
movzbl 0x1(%rcx,%r11,4), %r11d
shll $0x8, %r11d
xorl %r10d, %r11d
movl %r8d, %r10d
shrl $0x18, %r10d
movzbl (%rcx,%r10,4), %r10d
xorl %r11d, %r10d
xorl %r9d, %r10d
xorl (%rax,%rsi), %r10d
movl %r10d, 0x10(%rdi,%rax,4)
xorl 0x4(%rdi,%rax,4), %r10d
movl %r10d, 0x14(%rdi,%rax,4)
xorl 0x8(%rdi,%rax,4), %r10d
movl %r10d, 0x18(%rdi,%rax,4)
xorl %r8d, %r10d
movl %r10d, 0x1c(%rdi,%rax,4)
addq $0x4, %rax
cmpq $0x28, %rax
jne 0x2c3c
movl $0xa, %eax
jmp 0x2ee9
movl 0x10(%rsi), %eax
movbel %eax, 0x10(%rdi)
movl 0x14(%rsi), %eax
movbel %eax, 0x14(%rdi)
cmpl $0xc0, %edx
jne 0x2da6
addq $0x2c, %rdi
xorl %eax, %eax
leaq 0x25c4(%rip), %rcx      # 0x52c0
movl $0xff, %edx
leaq 0x29b8(%rip), %rsi      # 0x56c0
movl -0x18(%rdi), %r8d
movl %r8d, %r9d
shrl $0xe, %r9d
andl $0x3fc, %r9d            # imm = 0x3FC
movzbl 0x3(%r9,%rcx), %r10d
shll $0x18, %r10d
xorl -0x2c(%rdi), %r10d
movl %r8d, %r9d
shrl $0x8, %r9d
andl %edx, %r9d
movzbl 0x2(%rcx,%r9,4), %r9d
shll $0x10, %r9d
movl %r8d, %r11d
andl %edx, %r11d
movzbl 0x1(%rcx,%r11,4), %r11d
shll $0x8, %r11d
xorl %r9d, %r11d
movl %r8d, %r9d
shrl $0x18, %r9d
movzbl (%rcx,%r9,4), %r9d
xorl %r11d, %r9d
xorl %r10d, %r9d
xorl (%rax,%rsi), %r9d
movl %r9d, -0x14(%rdi)
xorl -0x28(%rdi), %r9d
movl %r9d, -0x10(%rdi)
xorl -0x24(%rdi), %r9d
movl %r9d, -0xc(%rdi)
xorl -0x20(%rdi), %r9d
movl %r9d, -0x8(%rdi)
cmpq $0x1c, %rax
je 0x2edd
xorl -0x1c(%rdi), %r9d
movl %r9d, -0x4(%rdi)
xorl %r8d, %r9d
movl %r9d, (%rdi)
addq $0x4, %rax
addq $0x18, %rdi
jmp 0x2d08
movl 0x18(%rsi), %eax
movbel %eax, 0x18(%rdi)
movl 0x1c(%rsi), %eax
movbel %eax, 0x1c(%rdi)
xorl %eax, %eax
cmpl $0x100, %edx            # imm = 0x100
jne 0x2ee9
xorl %eax, %eax
leaq 0x24f3(%rip), %rcx      # 0x52c0
movl $0xff, %edx
leaq 0x28e7(%rip), %rsi      # 0x56c0
movl 0x1c(%rdi,%rax,8), %r8d
movl %r8d, %r9d
shrl $0xe, %r9d
andl $0x3fc, %r9d            # imm = 0x3FC
movzbl 0x3(%r9,%rcx), %r10d
shll $0x18, %r10d
xorl (%rdi,%rax,8), %r10d
movl %r8d, %r9d
shrl $0x8, %r9d
andl %edx, %r9d
movzbl 0x2(%rcx,%r9,4), %r9d
shll $0x10, %r9d
movl %r8d, %r11d
andl %edx, %r11d
movzbl 0x1(%rcx,%r11,4), %r11d
shll $0x8, %r11d
xorl %r9d, %r11d
movl %r8d, %r9d
shrl $0x18, %r9d
movzbl (%rcx,%r9,4), %r9d
xorl %r11d, %r9d
xorl %r10d, %r9d
xorl (%rax,%rsi), %r9d
movl %r9d, 0x20(%rdi,%rax,8)
xorl 0x4(%rdi,%rax,8), %r9d
movl %r9d, 0x24(%rdi,%rax,8)
xorl 0x8(%rdi,%rax,8), %r9d
movl %r9d, 0x28(%rdi,%rax,8)
xorl 0xc(%rdi,%rax,8), %r9d
movl %r9d, 0x2c(%rdi,%rax,8)
cmpq $0x18, %rax
je 0x2ee4
movl %r9d, %r10d
shrl $0x18, %r10d
movzbl 0x3(%rcx,%r10,4), %r10d
shll $0x18, %r10d
xorl 0x10(%rdi,%rax,8), %r10d
movl %r9d, %r11d
shrl $0xe, %r11d
andl $0x3fc, %r11d           # imm = 0x3FC
movzbl 0x2(%r11,%rcx), %r11d
shll $0x10, %r11d
movl %r9d, %ebx
shrl $0x8, %ebx
andl %edx, %ebx
movzbl 0x1(%rcx,%rbx,4), %ebx
shll $0x8, %ebx
xorl %r11d, %ebx
andl %edx, %r9d
movzbl (%rcx,%r9,4), %r9d
xorl %ebx, %r9d
xorl %r10d, %r9d
movl %r9d, 0x30(%rdi,%rax,8)
xorl 0x14(%rdi,%rax,8), %r9d
movl %r9d, 0x34(%rdi,%rax,8)
xorl 0x18(%rdi,%rax,8), %r9d
movl %r9d, 0x38(%rdi,%rax,8)
xorl %r8d, %r9d
movl %r9d, 0x3c(%rdi,%rax,8)
addq $0x4, %rax
jmp 0x2dd9
movl $0xc, %eax
jmp 0x2ee9
movl $0xe, %eax
popq %rbx
retq