// File: /workspace/github_c_makefile_star2_O2/mjosaarinen[P]brutus/crypto_aead/shellaes128v1d5n64/ref/aes.c
// Function: aesEncrypt
void aesEncrypt(const u32 rk[/*4*(Nr + 1)*/], const u8 pt[], u8 ct[]) {

	u32 s0, s1, s2, s3, t0, t1, t2, t3;
    int r;
    int Nr=10;

    /*
	 * map byte array block to cipher state
	 * and add initial round key:
	 */

	s0 = GETU32(pt     ) ^ rk[0];
	s1 = GETU32(pt +  4) ^ rk[1];
	s2 = GETU32(pt +  8) ^ rk[2];
	s3 = GETU32(pt + 12) ^ rk[3];

    r = Nr >> 1;
    for (;;) {
        t0 =
            Te0[(s0 >> 24)       ] ^
            Te1[(s1 >> 16) & 0xff] ^
            Te2[(s2 >>  8) & 0xff] ^
            Te3[(s3      ) & 0xff] ^
            rk[4];
        t1 =
            Te0[(s1 >> 24)       ] ^
            Te1[(s2 >> 16) & 0xff] ^
            Te2[(s3 >>  8) & 0xff] ^
            Te3[(s0      ) & 0xff] ^
            rk[5];
        t2 =
            Te0[(s2 >> 24)       ] ^
            Te1[(s3 >> 16) & 0xff] ^
            Te2[(s0 >>  8) & 0xff] ^
            Te3[(s1      ) & 0xff] ^
            rk[6];
        t3 =
            Te0[(s3 >> 24)       ] ^
            Te1[(s0 >> 16) & 0xff] ^
            Te2[(s1 >>  8) & 0xff] ^
            Te3[(s2      ) & 0xff] ^
            rk[7];

        rk += 8;
        if (--r == 0) {
            break;
        }

        s0 =
            Te0[(t0 >> 24)       ] ^
            Te1[(t1 >> 16) & 0xff] ^
            Te2[(t2 >>  8) & 0xff] ^
            Te3[(t3      ) & 0xff] ^
            rk[0];
        s1 =
            Te0[(t1 >> 24)       ] ^
            Te1[(t2 >> 16) & 0xff] ^
            Te2[(t3 >>  8) & 0xff] ^
            Te3[(t0      ) & 0xff] ^
            rk[1];
        s2 =
            Te0[(t2 >> 24)       ] ^
            Te1[(t3 >> 16) & 0xff] ^
            Te2[(t0 >>  8) & 0xff] ^
            Te3[(t1      ) & 0xff] ^
            rk[2];
        s3 =
            Te0[(t3 >> 24)       ] ^
            Te1[(t0 >> 16) & 0xff] ^
            Te2[(t1 >>  8) & 0xff] ^
            Te3[(t2      ) & 0xff] ^
            rk[3];

    }

    /*
	 * apply last round and
	 * map cipher state to byte array block:
	 */
	s0 =
		(Te4[(t0 >> 24)       ] & 0xff000000) ^
		(Te4[(t1 >> 16) & 0xff] & 0x00ff0000) ^
		(Te4[(t2 >>  8) & 0xff] & 0x0000ff00) ^
		(Te4[(t3      ) & 0xff] & 0x000000ff) ^
		rk[0];

	PUTU32(ct     , s0);
	s1 =
		(Te4[(t1 >> 24)       ] & 0xff000000) ^
		(Te4[(t2 >> 16) & 0xff] & 0x00ff0000) ^
		(Te4[(t3 >>  8) & 0xff] & 0x0000ff00) ^
		(Te4[(t0      ) & 0xff] & 0x000000ff) ^
		rk[1];
	PUTU32(ct +  4, s1);
	s2 =
		(Te4[(t2 >> 24)       ] & 0xff000000) ^
		(Te4[(t3 >> 16) & 0xff] & 0x00ff0000) ^
		(Te4[(t0 >>  8) & 0xff] & 0x0000ff00) ^
		(Te4[(t1      ) & 0xff] & 0x000000ff) ^
		rk[2];
	PUTU32(ct +  8, s2);
	s3 =
		(Te4[(t3 >> 24)       ] & 0xff000000) ^
		(Te4[(t0 >> 16) & 0xff] & 0x00ff0000) ^
		(Te4[(t1 >>  8) & 0xff] & 0x0000ff00) ^
		(Te4[(t2      ) & 0xff] & 0x000000ff) ^
		rk[3];
	PUTU32(ct + 12, s3);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movbel (%rsi), %r13d
xorl (%rdi), %r13d
movbel 0x4(%rsi), %ebp
xorl 0x4(%rdi), %ebp
movbel 0x8(%rsi), %r9d
movq %rdx, -0x8(%rsp)
movq %rdi, -0x10(%rsp)
xorl 0x8(%rdi), %r9d
movbel 0xc(%rsi), %edx
xorl %r8d, %r8d
movl $0xff, %r11d
movq -0x10(%rsp), %rbx
xorl 0xc(%rbx,%r8), %edx
movl %r13d, %ecx
shrl $0x18, %ecx
movl %ebp, %eax
shrl $0xe, %eax
movl $0x3fc, %esi            # imm = 0x3FC
andl %esi, %eax
movl $0x3fc, %r12d           # imm = 0x3FC
leaq 0x51aa(%rip), %r14      # 0x7830
movl (%rax,%r14), %eax
leaq 0x4d9f(%rip), %r10      # 0x7430
xorl (%r10,%rcx,4), %eax
movl %r9d, %ecx
shrl $0x8, %ecx
andl %r11d, %ecx
leaq 0x558b(%rip), %r15      # 0x7c30
xorl (%r15,%rcx,4), %eax
movl %edx, %ecx
andl %r11d, %ecx
leaq 0x597b(%rip), %rdi      # 0x8030
xorl (%rdi,%rcx,4), %eax
movl %ebp, %esi
shrl $0x18, %esi
movl %r9d, %ecx
shrl $0xe, %ecx
andl %r12d, %ecx
movl (%rcx,%r14), %ecx
xorl (%r10,%rsi,4), %ecx
movl %edx, %esi
shrl $0x8, %esi
andl %r11d, %esi
xorl (%r15,%rsi,4), %ecx
movl %r13d, %esi
andl %r11d, %esi
xorl (%rdi,%rsi,4), %ecx
movl %r9d, %r12d
shrl $0x18, %r12d
movl %edx, %esi
shrl $0xe, %esi
movl $0x3fc, %edi            # imm = 0x3FC
andl %edi, %esi
movl (%rsi,%r14), %esi
xorl (%r10,%r12,4), %esi
movl %r13d, %r12d
shrl $0x8, %r12d
andl %r11d, %r12d
xorl (%r15,%r12,4), %esi
movl %ebp, %r12d
andl %r11d, %r12d
leaq 0x5917(%rip), %rdi      # 0x8030
xorl (%rdi,%r12,4), %esi
shrl $0x18, %edx
shrl $0xe, %r13d
movl $0x3fc, %r12d           # imm = 0x3FC
andl %r12d, %r13d
movl (%r13,%r14), %r12d
xorl (%r10,%rdx,4), %r12d
shrl $0x8, %ebp
andl %r11d, %ebp
xorl (%r15,%rbp,4), %r12d
xorl 0x10(%rbx,%r8), %eax
xorl 0x14(%rbx,%r8), %ecx
xorl 0x18(%rbx,%r8), %esi
andl %r11d, %r9d
xorl (%rdi,%r9,4), %r12d
xorl 0x1c(%rbx,%r8), %r12d
movl %eax, %r9d
shrl $0x18, %r9d
cmpl $0x80, %r8d
je 0x284b
movl %ecx, %edx
shrl $0xe, %edx
movl $0x3fc, %ebx            # imm = 0x3FC
andl %ebx, %edx
leaq 0x50ae(%rip), %r14      # 0x7830
movl (%rdx,%r14), %r13d
leaq 0x4ca3(%rip), %r10      # 0x7430
xorl (%r10,%r9,4), %r13d
movl %esi, %edx
shrl $0x8, %edx
andl %r11d, %edx
leaq 0x5490(%rip), %r15      # 0x7c30
xorl (%r15,%rdx,4), %r13d
movl %r12d, %edx
andl %r11d, %edx
leaq 0x587f(%rip), %rdi      # 0x8030
xorl (%rdi,%rdx,4), %r13d
movl %ecx, %edx
shrl $0x18, %edx
movl %esi, %r9d
shrl $0xe, %r9d
andl %ebx, %r9d
movl (%r9,%r14), %ebp
xorl (%r10,%rdx,4), %ebp
movl %r12d, %edx
shrl $0x8, %edx
andl %r11d, %edx
xorl (%r15,%rdx,4), %ebp
movl %eax, %edx
andl %r11d, %edx
xorl (%rdi,%rdx,4), %ebp
movl %esi, %edx
shrl $0x18, %edx
movl %r12d, %r9d
shrl $0xe, %r9d
andl %ebx, %r9d
movl (%r9,%r14), %r9d
xorl (%r10,%rdx,4), %r9d
movl %eax, %edx
shrl $0x8, %edx
andl %r11d, %edx
xorl (%r15,%rdx,4), %r9d
movl %ecx, %edx
andl %r11d, %edx
xorl (%rdi,%rdx,4), %r9d
shrl $0x18, %r12d
shrl $0xe, %eax
andl %ebx, %eax
movl (%rax,%r14), %edx
xorl (%r10,%r12,4), %edx
shrl $0x8, %ecx
andl %r11d, %ecx
xorl (%r15,%rcx,4), %edx
andl %r11d, %esi
xorl (%rdi,%rsi,4), %edx
movq -0x10(%rsp), %rax
xorl 0x20(%rax,%r8), %r13d
xorl 0x24(%rax,%r8), %ebp
xorl 0x28(%rax,%r8), %r9d
addq $0x20, %r8
jmp 0x265d
leaq 0x37ae(%rip), %rdx      # 0x6000
movzbl 0x3(%rdx,%r9,4), %r8d
shll $0x18, %r8d
movl %ecx, %r10d
shrl $0xe, %r10d
movl $0x3fc, %r9d            # imm = 0x3FC
andl %r9d, %r10d
movzbl 0x2(%r10,%rdx), %r10d
shll $0x10, %r10d
orl %r8d, %r10d
movl %esi, %r11d
shrl $0x8, %r11d
movl $0xff, %r8d
andl %r8d, %r11d
movzbl 0x1(%rdx,%r11,4), %r11d
shll $0x8, %r11d
orl %r10d, %r11d
movl %r12d, %r10d
andl %r8d, %r10d
movzbl (%rdx,%r10,4), %r10d
orl %r11d, %r10d
movq -0x10(%rsp), %rdi
xorl 0xa0(%rdi), %r10d
movq -0x8(%rsp), %rbx
movbel %r10d, (%rbx)
movl %ecx, %r10d
shrl $0x18, %r10d
movzbl 0x3(%rdx,%r10,4), %r10d
shll $0x18, %r10d
movl %esi, %r11d
shrl $0xe, %r11d
andl %r9d, %r11d
movzbl 0x2(%r11,%rdx), %r11d
shll $0x10, %r11d
orl %r10d, %r11d
movl %r12d, %r10d
shrl $0x8, %r10d
andl %r8d, %r10d
movzbl 0x1(%rdx,%r10,4), %r10d
shll $0x8, %r10d
orl %r11d, %r10d
movl %eax, %r11d
andl %r8d, %r11d
movzbl (%rdx,%r11,4), %r11d
orl %r10d, %r11d
xorl 0xa4(%rdi), %r11d
movbel %r11d, 0x4(%rbx)
movl %esi, %r10d
shrl $0x18, %r10d
movzbl 0x3(%rdx,%r10,4), %r10d
shll $0x18, %r10d
movl %r12d, %r11d
shrl $0xe, %r11d
andl %r9d, %r11d
movzbl 0x2(%r11,%rdx), %r11d
shll $0x10, %r11d
orl %r10d, %r11d
movl %eax, %r10d
shrl $0x8, %r10d
andl %r8d, %r10d
movzbl 0x1(%rdx,%r10,4), %r10d
shll $0x8, %r10d
orl %r11d, %r10d
movl %ecx, %r11d
andl %r8d, %r11d
movzbl (%rdx,%r11,4), %r11d
orl %r10d, %r11d
xorl 0xa8(%rdi), %r11d
movbel %r11d, 0x8(%rbx)
shrl $0x18, %r12d
movzbl 0x3(%rdx,%r12,4), %r10d
shll $0x18, %r10d
shrl $0xe, %eax
andl %r9d, %eax
movzbl 0x2(%rax,%rdx), %eax
shll $0x10, %eax
orl %r10d, %eax
shrl $0x8, %ecx
andl %r8d, %ecx
movzbl 0x1(%rdx,%rcx,4), %ecx
shll $0x8, %ecx
orl %eax, %ecx
andl %r8d, %esi
movzbl (%rdx,%rsi,4), %eax
orl %ecx, %eax
xorl 0xac(%rdi), %eax
movbel %eax, 0xc(%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq