#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ __m128i;

/* Variables and functions */
int /*<<< orphan*/ _mm_aesenc_si128(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_aesenclast_si128(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_load_si128(int /*<<< orphan*/ const *);
int /*<<< orphan*/ _mm_store_si128(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_xor_si128(int /*<<< orphan*/, int /*<<< orphan*/);
void aesni_encrypt1(unsigned char *out, unsigned char *n, __m128i rkeys[16]) {
  __m128i nv = _mm_load_si128((const __m128i *)n);
  int i;
  __m128i temp = _mm_xor_si128(nv, rkeys[0]);
#pragma unroll(13)
  for (i = 1; i < 14; i++) {
    temp = _mm_aesenc_si128(temp, rkeys[i]);
  }
  temp = _mm_aesenclast_si128(temp, rkeys[14]);
  _mm_store_si128((__m128i *)(out), temp);
}


x86 assembly (clang, -O0):
<aesni_encrypt1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,-0x24(%rbp)
movl   $0x1,-0x20(%rbp)
cmpl   $0xe,-0x20(%rbp)
jge    11b6 <aesni_encrypt1+0x66>
mov    -0x24(%rbp),%edi
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1050 <_mm_aesenc_si128@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1188 <aesni_encrypt1+0x38>
mov    -0x24(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    0x38(%rax),%esi
call   1040 <_mm_aesenclast_si128@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1060 <_mm_store_si128@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aesni_encrypt1>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <_mm_load_si128@plt>
mov    (%rbx),%esi
mov    %eax,%edi
call   1070 <_mm_xor_si128@plt>
mov    0x4(%rbx),%esi
mov    %eax,%edi
call   1050 <_mm_aesenc_si128@plt>
mov    0x8(%rbx),%esi
mov    %eax,%edi
call   1050 <_mm_aesenc_si128@plt>
mov    0xc(%rbx),%esi
mov    %eax,%edi
call   1050 <_mm_aesenc_si128@plt>
mov    0x10(%rbx),%esi
mov    %eax,%edi
call   1050 <_mm_aesenc_si128@plt>
mov    0x14(%rbx),%esi
mov    %eax,%edi
call   1050 <_mm_aesenc_si128@plt>
mov    0x18(%rbx),%esi
mov    %eax,%edi
call   1050 <_mm_aesenc_si128@plt>
mov    0x1c(%rbx),%esi
mov    %eax,%edi
call   1050 <_mm_aesenc_si128@plt>
mov    0x20(%rbx),%esi
mov    %eax,%edi
call   1050 <_mm_aesenc_si128@plt>
mov    0x24(%rbx),%esi
mov    %eax,%edi
call   1050 <_mm_aesenc_si128@plt>
mov    0x28(%rbx),%esi
mov    %eax,%edi
call   1050 <_mm_aesenc_si128@plt>
mov    0x2c(%rbx),%esi
mov    %eax,%edi
call   1050 <_mm_aesenc_si128@plt>
mov    0x30(%rbx),%esi
mov    %eax,%edi
call   1050 <_mm_aesenc_si128@plt>
mov    0x34(%rbx),%esi
mov    %eax,%edi
call   1050 <_mm_aesenc_si128@plt>
mov    0x38(%rbx),%esi
mov    %eax,%edi
call   1040 <_mm_aesenclast_si128@plt>
mov    %r14,%rdi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <_mm_store_si128@plt>

LLVM IR (-O0):
define void @aesni_encrypt1(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%10 = load i8*, i8** %5
%11 = bitcast i8* %10 to i32*
%12 = call i32 @_mm_load_si128(i32* %11)
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = load i32*, i32** %6
%15 = getelementptr inbounds i32, i32* %14, i64 0
%16 = load i32, i32* %15
%17 = call i32 @_mm_xor_si128(i32 %13, i32 %16)
store i32 %17, i32* %9
store i32 1, i32* %8
br label %18
18: ; preds = %29, %3
%19 = load i32, i32* %8
%20 = icmp slt i32 %19, 14
br i1 %20, label %21, label %32
21: ; preds = %18
%22 = load i32, i32* %9
%23 = load i32*, i32** %6
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
%27 = load i32, i32* %26
%28 = call i32 @_mm_aesenc_si128(i32 %22, i32 %27)
store i32 %28, i32* %9
br label %29
29: ; preds = %21
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
br label %18
32: ; preds = %18
%33 = load i32, i32* %9
%34 = load i32*, i32** %6
%35 = getelementptr inbounds i32, i32* %34, i64 14
%36 = load i32, i32* %35
%37 = call i32 @_mm_aesenclast_si128(i32 %33, i32 %36)
store i32 %37, i32* %9
%38 = load i8*, i8** %4
%39 = bitcast i8* %38 to i32*
%40 = load i32, i32* %9
%41 = call i32 @_mm_store_si128(i32* %39, i32 %40)
ret void
}

LLVM IR (-O2):
define void @aesni_encrypt1(i8* %0, i8* %1, i32* nocapture %2) {
%4 = bitcast i8* %1 to i32*
%5 = tail call i32 @_mm_load_si128(i32* %4)
%6 = load i32, i32* %2
%7 = tail call i32 @_mm_xor_si128(i32 %5, i32 %6)
%8 = getelementptr inbounds i32, i32* %2, i64 1
%9 = load i32, i32* %8
%10 = tail call i32 @_mm_aesenc_si128(i32 %7, i32 %9)
%11 = getelementptr inbounds i32, i32* %2, i64 2
%12 = load i32, i32* %11
%13 = tail call i32 @_mm_aesenc_si128(i32 %10, i32 %12)
%14 = getelementptr inbounds i32, i32* %2, i64 3
%15 = load i32, i32* %14
%16 = tail call i32 @_mm_aesenc_si128(i32 %13, i32 %15)
%17 = getelementptr inbounds i32, i32* %2, i64 4
%18 = load i32, i32* %17
%19 = tail call i32 @_mm_aesenc_si128(i32 %16, i32 %18)
%20 = getelementptr inbounds i32, i32* %2, i64 5
%21 = load i32, i32* %20
%22 = tail call i32 @_mm_aesenc_si128(i32 %19, i32 %21)
%23 = getelementptr inbounds i32, i32* %2, i64 6
%24 = load i32, i32* %23
%25 = tail call i32 @_mm_aesenc_si128(i32 %22, i32 %24)
%26 = getelementptr inbounds i32, i32* %2, i64 7
%27 = load i32, i32* %26
%28 = tail call i32 @_mm_aesenc_si128(i32 %25, i32 %27)
%29 = getelementptr inbounds i32, i32* %2, i64 8
%30 = load i32, i32* %29
%31 = tail call i32 @_mm_aesenc_si128(i32 %28, i32 %30)
%32 = getelementptr inbounds i32, i32* %2, i64 9
%33 = load i32, i32* %32
%34 = tail call i32 @_mm_aesenc_si128(i32 %31, i32 %33)
%35 = getelementptr inbounds i32, i32* %2, i64 10
%36 = load i32, i32* %35
%37 = tail call i32 @_mm_aesenc_si128(i32 %34, i32 %36)
%38 = getelementptr inbounds i32, i32* %2, i64 11
%39 = load i32, i32* %38
%40 = tail call i32 @_mm_aesenc_si128(i32 %37, i32 %39)
%41 = getelementptr inbounds i32, i32* %2, i64 12
%42 = load i32, i32* %41
%43 = tail call i32 @_mm_aesenc_si128(i32 %40, i32 %42)
%44 = getelementptr inbounds i32, i32* %2, i64 13
%45 = load i32, i32* %44
%46 = tail call i32 @_mm_aesenc_si128(i32 %43, i32 %45)
%47 = getelementptr inbounds i32, i32* %2, i64 14
%48 = load i32, i32* %47
%49 = tail call i32 @_mm_aesenclast_si128(i32 %46, i32 %48)
%50 = bitcast i8* %0 to i32*
%51 = tail call i32 @_mm_store_si128(i32* %50, i32 %49)
ret void
}