// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/aezv3/ref/rijndael-alg-fst.c
// Function: rijndaelEncryptRound
void rijndaelEncryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], int rounds) {
	int r;
	u32 s0, s1, s2, s3, t0, t1, t2, t3;

    /*
	 * map byte array block to cipher state
	 * and add initial round key:
	 */
	s0 = GETU32(block     ) ^ rk[0];
	s1 = GETU32(block +  4) ^ rk[1];
	s2 = GETU32(block +  8) ^ rk[2];
	s3 = GETU32(block + 12) ^ rk[3];
    rk += 4;

    /*
	 * Nr - 1 full rounds:
	 */
	for (r = (rounds < Nr ? rounds : Nr - 1); r > 0; r--) {
		t0 =
			Te0[(s0 >> 24)       ] ^
			Te1[(s1 >> 16) & 0xff] ^
			Te2[(s2 >>  8) & 0xff] ^
			Te3[(s3      ) & 0xff] ^
			rk[0];
		t1 =
			Te0[(s1 >> 24)       ] ^
			Te1[(s2 >> 16) & 0xff] ^
			Te2[(s3 >>  8) & 0xff] ^
			Te3[(s0      ) & 0xff] ^
			rk[1];
		t2 =
			Te0[(s2 >> 24)       ] ^
			Te1[(s3 >> 16) & 0xff] ^
			Te2[(s0 >>  8) & 0xff] ^
			Te3[(s1      ) & 0xff] ^
			rk[2];
		t3 =
			Te0[(s3 >> 24)       ] ^
			Te1[(s0 >> 16) & 0xff] ^
			Te2[(s1 >>  8) & 0xff] ^
			Te3[(s2      ) & 0xff] ^
			rk[3];

		s0 = t0;
		s1 = t1;
		s2 = t2;
		s3 = t3;
		rk += 4;

    }

    /*
	 * apply last round and
	 * map cipher state to byte array block:
	 */
	if (rounds == Nr) {
    	t0 =
    		(Te4[(s0 >> 24)       ] & 0xff000000) ^
    		(Te4[(s1 >> 16) & 0xff] & 0x00ff0000) ^
    		(Te4[(s2 >>  8) & 0xff] & 0x0000ff00) ^
    		(Te4[(s3      ) & 0xff] & 0x000000ff) ^
    		rk[0];
    	t1 =
    		(Te4[(s1 >> 24)       ] & 0xff000000) ^
    		(Te4[(s2 >> 16) & 0xff] & 0x00ff0000) ^
    		(Te4[(s3 >>  8) & 0xff] & 0x0000ff00) ^
    		(Te4[(s0      ) & 0xff] & 0x000000ff) ^
    		rk[1];
    	t2 =
    		(Te4[(s2 >> 24)       ] & 0xff000000) ^
    		(Te4[(s3 >> 16) & 0xff] & 0x00ff0000) ^
    		(Te4[(s0 >>  8) & 0xff] & 0x0000ff00) ^
    		(Te4[(s1      ) & 0xff] & 0x000000ff) ^
    		rk[2];
    	t3 =
    		(Te4[(s3 >> 24)       ] & 0xff000000) ^
    		(Te4[(s0 >> 16) & 0xff] & 0x00ff0000) ^
    		(Te4[(s1 >>  8) & 0xff] & 0x0000ff00) ^
    		(Te4[(s2      ) & 0xff] & 0x000000ff) ^
    		rk[3];
		
		s0 = t0;
		s1 = t1;
		s2 = t2;
		s3 = t3;
	}

	PUTU32(block     , s0);
	PUTU32(block +  4, s1);
	PUTU32(block +  8, s2);
	PUTU32(block + 12, s3);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movbel (%rdx), %r14d
xorl (%rdi), %r14d
movbel 0x4(%rdx), %ebx
xorl 0x4(%rdi), %ebx
movbel 0x8(%rdx), %eax
xorl 0x8(%rdi), %eax
movq %rdx, -0x38(%rsp)
movbel 0xc(%rdx), %r13d
xorl 0xc(%rdi), %r13d
leal -0x1(%rsi), %edx
cmpl %esi, %ecx
cmovll %ecx, %edx
leaq 0x10(%rdi), %r8
testl %edx, %edx
jle 0x3cb9
movq %rsi, -0x28(%rsp)
movl %ecx, -0x3c(%rsp)
movq %rdi, -0x20(%rsp)
leal -0x1(%rdx), %ecx
shlq $0x4, %rcx
movq %rcx, -0x30(%rsp)
incl %edx
movq %r14, %r10
movl $0xff, %r9d
movq %rdx, -0x10(%rsp)
movq %r8, -0x8(%rsp)
movl %r10d, %edx
movl %ebx, %r14d
movl %r10d, %ebp
shrl $0x18, %ebp
movl %ebx, %r11d
shrl $0xe, %r11d
movl $0x3fc, %ecx            # imm = 0x3FC
andl %ecx, %r11d
movl $0x3fc, %edi            # imm = 0x3FC
movl %r10d, %ecx
movq %rcx, -0x18(%rsp)
movl %r10d, %esi
shrl $0xe, %edx
andl %edi, %edx
leaq 0x2f47(%rip), %r8       # 0x6af0
movl (%rdx,%r8), %edi
movl (%r11,%r8), %r10d
leaq 0x2b38(%rip), %r12      # 0x66f0
xorl (%r12,%rbp,4), %r10d
movq %r12, %rbx
movl %eax, %r11d
shrl $0x8, %r11d
andl %r9d, %r11d
leaq 0x3320(%rip), %rcx      # 0x6ef0
xorl (%rcx,%r11,4), %r10d
movl %r13d, %r11d
andl %r9d, %r11d
leaq 0x370f(%rip), %r12      # 0x72f0
xorl (%r12,%r11,4), %r10d
movl %r14d, %edx
movl %r13d, %r15d
movl %r13d, %ebp
shrl $0x18, %r13d
xorl (%rbx,%r13,4), %edi
movq %rbx, %r13
movl %r14d, %r11d
shrl $0x8, %r14d
andl %r9d, %r14d
xorl (%rcx,%r14,4), %edi
shrl $0x18, %edx
movl %eax, %ebx
shrl $0xe, %ebx
movl $0x3fc, %r14d           # imm = 0x3FC
andl %r14d, %ebx
movl (%rbx,%r8), %ebx
xorl (%r13,%rdx,4), %ebx
movq -0x10(%rsp), %rdx
shrl $0x8, %r15d
andl %r9d, %r15d
xorl (%rcx,%r15,4), %ebx
movq %rcx, %r15
movq -0x18(%rsp), %rcx
andl %r9d, %ecx
xorl (%r12,%rcx,4), %ebx
movl %eax, %ecx
andl %r9d, %eax
xorl (%r12,%rax,4), %edi
shrl $0x18, %ecx
shrl $0xe, %ebp
andl %r14d, %ebp
movl (%rbp,%r8), %eax
movq -0x8(%rsp), %r8
xorl (%r13,%rcx,4), %eax
shrl $0x8, %esi
andl %r9d, %esi
xorl (%r15,%rsi,4), %eax
andl %r9d, %r11d
xorl (%r12,%r11,4), %eax
xorl (%r8), %r10d
xorl 0x4(%r8), %ebx
xorl 0x8(%r8), %eax
movl %edi, %r13d
xorl 0xc(%r8), %r13d
addq $0x10, %r8
decl %edx
cmpl $0x1, %edx
jg 0x3b68
movq %r10, %r14
movq -0x20(%rsp), %rcx
movq -0x30(%rsp), %rdx
leaq (%rcx,%rdx), %r8
addq $0x20, %r8
leaq (%rcx,%rdx), %rdi
addq $0x10, %rdi
movl -0x3c(%rsp), %ecx
movq -0x28(%rsp), %rsi
cmpl %esi, %ecx
jne 0x3dfa
leaq 0x15f8(%rip), %rcx      # 0x52c0
movl %r13d, %esi
movl %r13d, %r9d
movl %r13d, %r10d
shrl $0x18, %r13d
movzbl 0x3(%rcx,%r13,4), %r11d
movq %r14, %r12
movl %r12d, %edx
shrl $0x18, %edx
movzbl 0x3(%rcx,%rdx,4), %edx
shll $0x18, %edx
movl %ebx, %r14d
shrl $0xe, %r14d
movl $0x3fc, %r15d           # imm = 0x3FC
andl %r15d, %r14d
movzbl 0x2(%r14,%rcx), %r14d
shll $0x10, %r14d
orl %edx, %r14d
movl %eax, %edx
shrl $0x8, %edx
movl $0xff, %ebp
andl %ebp, %edx
movzbl 0x1(%rcx,%rdx,4), %edx
shll $0x8, %edx
orl %r14d, %edx
andl %ebp, %esi
movzbl (%rcx,%rsi,4), %esi
orl %edx, %esi
xorl (%r8), %esi
movl %ebx, %edx
shrl $0x18, %edx
movzbl 0x3(%rcx,%rdx,4), %edx
shll $0x18, %edx
movl %eax, %r8d
shrl $0xe, %r8d
andl %r15d, %r8d
movzbl 0x2(%r8,%rcx), %r8d
shll $0x10, %r8d
orl %edx, %r8d
shrl $0x8, %r9d
andl %ebp, %r9d
movzbl 0x1(%rcx,%r9,4), %edx
shll $0x8, %edx
orl %r8d, %edx
movl %r12d, %r8d
andl %ebp, %r8d
movzbl (%rcx,%r8,4), %r8d
orl %edx, %r8d
xorl 0x14(%rdi), %r8d
movl %eax, %edx
shrl $0x18, %edx
movzbl 0x3(%rcx,%rdx,4), %edx
shll $0x18, %edx
shrl $0xe, %r10d
andl %r15d, %r10d
movzbl 0x2(%r10,%rcx), %r9d
shll $0x10, %r9d
orl %edx, %r9d
movl %r12d, %edx
shrl $0x8, %edx
andl %ebp, %edx
movzbl 0x1(%rcx,%rdx,4), %edx
shll $0x8, %edx
orl %r9d, %edx
movl %ebx, %r9d
andl %ebp, %r9d
movzbl (%rcx,%r9,4), %r9d
orl %edx, %r9d
xorl 0x18(%rdi), %r9d
shll $0x18, %r11d
shrl $0xe, %r12d
andl %r15d, %r12d
movzbl 0x2(%r12,%rcx), %edx
shll $0x10, %edx
orl %r11d, %edx
shrl $0x8, %ebx
andl %ebp, %ebx
movzbl 0x1(%rcx,%rbx,4), %r10d
shll $0x8, %r10d
orl %edx, %r10d
andl %ebp, %eax
movzbl (%rcx,%rax,4), %r13d
orl %r10d, %r13d
xorl 0x1c(%rdi), %r13d
movl %esi, %r14d
movl %r8d, %ebx
movl %r9d, %eax
movq -0x38(%rsp), %rdx
movl %r14d, %ecx
shrl $0x18, %ecx
movb %cl, (%rdx)
movl %r14d, %ecx
shrl $0x10, %ecx
movb %cl, 0x1(%rdx)
movq %r14, %rcx
movb %ch, 0x2(%rdx)
movb %cl, 0x3(%rdx)
movl %ebx, %ecx
shrl $0x18, %ecx
movb %cl, 0x4(%rdx)
movl %ebx, %ecx
shrl $0x10, %ecx
movb %cl, 0x5(%rdx)
movb %bh, 0x6(%rdx)
movb %bl, 0x7(%rdx)
movl %eax, %ecx
shrl $0x18, %ecx
movb %cl, 0x8(%rdx)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x9(%rdx)
movb %ah, 0xa(%rdx)
movb %al, 0xb(%rdx)
movq %r13, %rcx
movl %ecx, %eax
shrl $0x18, %eax
movb %al, 0xc(%rdx)
movl %ecx, %eax
shrl $0x10, %eax
movb %al, 0xd(%rdx)
movb %ch, 0xe(%rdx)
movb %cl, 0xf(%rdx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq