#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*/ const);
int /*<<< orphan*/ _mm_aesenclast_si128(int /*<<< orphan*/,
                                        int /*<<< orphan*/ const);
int /*<<< orphan*/ _mm_load_si128(int /*<<< orphan*/ const *);
int /*<<< orphan*/ _mm_set_epi8(int, int, int, int, int, int, int, int, int,
                                int, int, int, int, int, int,
                                int /*<<< orphan*/);
int /*<<< orphan*/ _mm_shuffle_epi8(int /*<<< orphan*/,
                                    int /*<<< orphan*/ const);
int /*<<< orphan*/ _mm_store_si128(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_xor_si128(int /*<<< orphan*/, int /*<<< orphan*/ const);
void aesni_encrypt2(unsigned char *out, unsigned int *n,
                    const __m128i rkeys[16]) {
  const __m128i pt =
      _mm_set_epi8(12, 13, 14, 15, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0);
  __m128i nv0 = _mm_shuffle_epi8(_mm_load_si128((const __m128i *)n), pt);
  n[3]++;
  __m128i nv1 = _mm_shuffle_epi8(_mm_load_si128((const __m128i *)n), pt);
  n[3]++;
  int i;
  __m128i temp0 = _mm_xor_si128(nv0, rkeys[0]);
  __m128i temp1 = _mm_xor_si128(nv1, rkeys[0]);
  for (i = 1; i < 14; i++) {
    temp0 = _mm_aesenc_si128(temp0, rkeys[i]);
    temp1 = _mm_aesenc_si128(temp1, rkeys[i]);
  }
  temp0 = _mm_aesenclast_si128(temp0, rkeys[14]);
  temp1 = _mm_aesenclast_si128(temp1, rkeys[14]);
  _mm_store_si128((__m128i *)(out + (0 * 16)), temp0);
  _mm_store_si128((__m128i *)(out + (1 * 16)), temp1);
}


x86 assembly (clang, -O0):
<aesni_encrypt2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0xc,%edi
mov    $0xd,%esi
mov    $0xe,%edx
mov    $0xf,%ecx
mov    $0xb,%r8d
mov    $0xa,%r9d
xor    %eax,%eax
movl   $0x9,(%rsp)
movl   $0x8,0x8(%rsp)
movl   $0x7,0x10(%rsp)
movl   $0x6,0x18(%rsp)
movl   $0x5,0x20(%rsp)
movl   $0x4,0x28(%rsp)
movl   $0x3,0x30(%rsp)
movl   $0x2,0x38(%rsp)
movl   $0x1,0x40(%rsp)
movl   $0x0,0x48(%rsp)
call   1080 <_mm_set_epi8@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,%edi
mov    -0x1c(%rbp),%esi
call   1050 <_mm_shuffle_epi8@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%ecx
add    $0x1,%ecx
mov    %ecx,0xc(%rax)
mov    -0x10(%rbp),%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,%edi
mov    -0x1c(%rbp),%esi
call   1050 <_mm_shuffle_epi8@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%ecx
add    $0x1,%ecx
mov    %ecx,0xc(%rax)
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1090 <_mm_xor_si128@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1090 <_mm_xor_si128@plt>
mov    %eax,-0x30(%rbp)
movl   $0x1,-0x28(%rbp)
cmpl   $0xe,-0x28(%rbp)
jge    12b3 <aesni_encrypt2+0x143>
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    126f <aesni_encrypt2+0xff>
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    0x38(%rax),%esi
call   1040 <_mm_aesenclast_si128@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    0x38(%rax),%esi
call   1040 <_mm_aesenclast_si128@plt>
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1070 <_mm_store_si128@plt>
mov    -0x8(%rbp),%rdi
add    $0x10,%rdi
mov    -0x30(%rbp),%esi
call   1070 <_mm_store_si128@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aesni_encrypt2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    $0xc,%edi
mov    $0xd,%esi
mov    $0xe,%edx
mov    $0xf,%ecx
mov    $0xb,%r8d
mov    $0xa,%r9d
push   $0x0
push   $0x1
push   $0x2
push   $0x3
push   $0x4
push   $0x5
push   $0x6
push   $0x7
push   $0x8
push   $0x9
call   1080 <_mm_set_epi8@plt>
add    $0x50,%rsp
mov    %eax,%ebp
mov    %r15,%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,%edi
mov    %ebp,%esi
call   1050 <_mm_shuffle_epi8@plt>
mov    %eax,%r12d
addl   $0x1,0xc(%r15)
mov    %r15,%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,%edi
mov    %ebp,%esi
call   1050 <_mm_shuffle_epi8@plt>
mov    %eax,%r13d
addl   $0x1,0xc(%r15)
mov    (%rbx),%esi
mov    %r12d,%edi
call   1090 <_mm_xor_si128@plt>
mov    %eax,%ebp
mov    (%rbx),%esi
mov    %r13d,%edi
call   1090 <_mm_xor_si128@plt>
mov    %eax,%r15d
mov    0x4(%rbx),%esi
mov    %ebp,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%ebp
mov    0x4(%rbx),%esi
mov    %r15d,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%r15d
mov    0x8(%rbx),%esi
mov    %ebp,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%ebp
mov    0x8(%rbx),%esi
mov    %r15d,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%r15d
mov    0xc(%rbx),%esi
mov    %ebp,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%ebp
mov    0xc(%rbx),%esi
mov    %r15d,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%r15d
mov    0x10(%rbx),%esi
mov    %ebp,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%esi
mov    %r15d,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%r15d
mov    0x14(%rbx),%esi
mov    %ebp,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%ebp
mov    0x14(%rbx),%esi
mov    %r15d,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%r15d
mov    0x18(%rbx),%esi
mov    %ebp,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%ebp
mov    0x18(%rbx),%esi
mov    %r15d,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%r15d
mov    0x1c(%rbx),%esi
mov    %ebp,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%ebp
mov    0x1c(%rbx),%esi
mov    %r15d,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%r15d
mov    0x20(%rbx),%esi
mov    %ebp,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%ebp
mov    0x20(%rbx),%esi
mov    %r15d,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%r15d
mov    0x24(%rbx),%esi
mov    %ebp,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%ebp
mov    0x24(%rbx),%esi
mov    %r15d,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%r15d
mov    0x28(%rbx),%esi
mov    %ebp,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%ebp
mov    0x28(%rbx),%esi
mov    %r15d,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%r15d
mov    0x2c(%rbx),%esi
mov    %ebp,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%ebp
mov    0x2c(%rbx),%esi
mov    %r15d,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%r15d
mov    0x30(%rbx),%esi
mov    %ebp,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%ebp
mov    0x30(%rbx),%esi
mov    %r15d,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%r15d
mov    0x34(%rbx),%esi
mov    %ebp,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%ebp
mov    0x34(%rbx),%esi
mov    %r15d,%edi
call   1060 <_mm_aesenc_si128@plt>
mov    %eax,%r15d
mov    0x38(%rbx),%esi
mov    %ebp,%edi
call   1040 <_mm_aesenclast_si128@plt>
mov    %eax,%ebp
mov    0x38(%rbx),%esi
mov    %r15d,%edi
call   1040 <_mm_aesenclast_si128@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    %ebp,%esi
call   1070 <_mm_store_si128@plt>
add    $0x10,%r14
mov    %r14,%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <_mm_store_si128@plt>

LLVM IR (-O0):
define void @aesni_encrypt2(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%13 = call i32 @_mm_set_epi8(i32 12, i32 13, i32 14, i32 15, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0)
store i32 %13, i32* %7
%14 = load i32*, i32** %5
%15 = call i32 @_mm_load_si128(i32* %14)
%16 = load i32, i32* %7
%17 = call i32 @_mm_shuffle_epi8(i32 %15, i32 %16)
store i32 %17, i32* %8
%18 = load i32*, i32** %5
%19 = getelementptr inbounds i32, i32* %18, i64 3
%20 = load i32, i32* %19
%21 = add i32 %20, 1
store i32 %21, i32* %19
%22 = load i32*, i32** %5
%23 = call i32 @_mm_load_si128(i32* %22)
%24 = load i32, i32* %7
%25 = call i32 @_mm_shuffle_epi8(i32 %23, i32 %24)
store i32 %25, i32* %9
%26 = load i32*, i32** %5
%27 = getelementptr inbounds i32, i32* %26, i64 3
%28 = load i32, i32* %27
%29 = add i32 %28, 1
store i32 %29, i32* %27
%30 = load i32, i32* %8
%31 = load i32*, i32** %6
%32 = getelementptr inbounds i32, i32* %31, i64 0
%33 = load i32, i32* %32
%34 = call i32 @_mm_xor_si128(i32 %30, i32 %33)
store i32 %34, i32* %11
%35 = load i32, i32* %9
%36 = load i32*, i32** %6
%37 = getelementptr inbounds i32, i32* %36, i64 0
%38 = load i32, i32* %37
%39 = call i32 @_mm_xor_si128(i32 %35, i32 %38)
store i32 %39, i32* %12
store i32 1, i32* %10
br label %40
40: ; preds = %58, %3
%41 = load i32, i32* %10
%42 = icmp slt i32 %41, 14
br i1 %42, label %43, label %61
43: ; preds = %40
%44 = load i32, i32* %11
%45 = load i32*, i32** %6
%46 = load i32, i32* %10
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %45, i64 %47
%49 = load i32, i32* %48
%50 = call i32 @_mm_aesenc_si128(i32 %44, i32 %49)
store i32 %50, i32* %11
%51 = load i32, i32* %12
%52 = load i32*, i32** %6
%53 = load i32, i32* %10
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i32, i32* %52, i64 %54
%56 = load i32, i32* %55
%57 = call i32 @_mm_aesenc_si128(i32 %51, i32 %56)
store i32 %57, i32* %12
br label %58
58: ; preds = %43
%59 = load i32, i32* %10
%60 = add nsw i32 %59, 1
store i32 %60, i32* %10
br label %40
61: ; preds = %40
%62 = load i32, i32* %11
%63 = load i32*, i32** %6
%64 = getelementptr inbounds i32, i32* %63, i64 14
%65 = load i32, i32* %64
%66 = call i32 @_mm_aesenclast_si128(i32 %62, i32 %65)
store i32 %66, i32* %11
%67 = load i32, i32* %12
%68 = load i32*, i32** %6
%69 = getelementptr inbounds i32, i32* %68, i64 14
%70 = load i32, i32* %69
%71 = call i32 @_mm_aesenclast_si128(i32 %67, i32 %70)
store i32 %71, i32* %12
%72 = load i8*, i8** %4
%73 = getelementptr inbounds i8, i8* %72, i64 0
%74 = bitcast i8* %73 to i32*
%75 = load i32, i32* %11
%76 = call i32 @_mm_store_si128(i32* %74, i32 %75)
%77 = load i8*, i8** %4
%78 = getelementptr inbounds i8, i8* %77, i64 16
%79 = bitcast i8* %78 to i32*
%80 = load i32, i32* %12
%81 = call i32 @_mm_store_si128(i32* %79, i32 %80)
ret void
}

LLVM IR (-O2):
define void @aesni_encrypt2(i8* %0, i32* %1, i32* nocapture %2) {
%4 = tail call i32 @_mm_set_epi8(i32 12, i32 13, i32 14, i32 15, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0)
%5 = tail call i32 @_mm_load_si128(i32* %1)
%6 = tail call i32 @_mm_shuffle_epi8(i32 %5, i32 %4)
%7 = getelementptr inbounds i32, i32* %1, i64 3
%8 = load i32, i32* %7
%9 = add i32 %8, 1
store i32 %9, i32* %7
%10 = tail call i32 @_mm_load_si128(i32* %1)
%11 = tail call i32 @_mm_shuffle_epi8(i32 %10, i32 %4)
%12 = load i32, i32* %7
%13 = add i32 %12, 1
store i32 %13, i32* %7
%14 = load i32, i32* %2
%15 = tail call i32 @_mm_xor_si128(i32 %6, i32 %14)
%16 = load i32, i32* %2
%17 = tail call i32 @_mm_xor_si128(i32 %11, i32 %16)
%18 = getelementptr inbounds i32, i32* %2, i64 1
%19 = load i32, i32* %18
%20 = tail call i32 @_mm_aesenc_si128(i32 %15, i32 %19)
%21 = load i32, i32* %18
%22 = tail call i32 @_mm_aesenc_si128(i32 %17, i32 %21)
%23 = getelementptr inbounds i32, i32* %2, i64 2
%24 = load i32, i32* %23
%25 = tail call i32 @_mm_aesenc_si128(i32 %20, i32 %24)
%26 = load i32, i32* %23
%27 = tail call i32 @_mm_aesenc_si128(i32 %22, i32 %26)
%28 = getelementptr inbounds i32, i32* %2, i64 3
%29 = load i32, i32* %28
%30 = tail call i32 @_mm_aesenc_si128(i32 %25, i32 %29)
%31 = load i32, i32* %28
%32 = tail call i32 @_mm_aesenc_si128(i32 %27, i32 %31)
%33 = getelementptr inbounds i32, i32* %2, i64 4
%34 = load i32, i32* %33
%35 = tail call i32 @_mm_aesenc_si128(i32 %30, i32 %34)
%36 = load i32, i32* %33
%37 = tail call i32 @_mm_aesenc_si128(i32 %32, i32 %36)
%38 = getelementptr inbounds i32, i32* %2, i64 5
%39 = load i32, i32* %38
%40 = tail call i32 @_mm_aesenc_si128(i32 %35, i32 %39)
%41 = load i32, i32* %38
%42 = tail call i32 @_mm_aesenc_si128(i32 %37, i32 %41)
%43 = getelementptr inbounds i32, i32* %2, i64 6
%44 = load i32, i32* %43
%45 = tail call i32 @_mm_aesenc_si128(i32 %40, i32 %44)
%46 = load i32, i32* %43
%47 = tail call i32 @_mm_aesenc_si128(i32 %42, i32 %46)
%48 = getelementptr inbounds i32, i32* %2, i64 7
%49 = load i32, i32* %48
%50 = tail call i32 @_mm_aesenc_si128(i32 %45, i32 %49)
%51 = load i32, i32* %48
%52 = tail call i32 @_mm_aesenc_si128(i32 %47, i32 %51)
%53 = getelementptr inbounds i32, i32* %2, i64 8
%54 = load i32, i32* %53
%55 = tail call i32 @_mm_aesenc_si128(i32 %50, i32 %54)
%56 = load i32, i32* %53
%57 = tail call i32 @_mm_aesenc_si128(i32 %52, i32 %56)
%58 = getelementptr inbounds i32, i32* %2, i64 9
%59 = load i32, i32* %58
%60 = tail call i32 @_mm_aesenc_si128(i32 %55, i32 %59)
%61 = load i32, i32* %58
%62 = tail call i32 @_mm_aesenc_si128(i32 %57, i32 %61)
%63 = getelementptr inbounds i32, i32* %2, i64 10
%64 = load i32, i32* %63
%65 = tail call i32 @_mm_aesenc_si128(i32 %60, i32 %64)
%66 = load i32, i32* %63
%67 = tail call i32 @_mm_aesenc_si128(i32 %62, i32 %66)
%68 = getelementptr inbounds i32, i32* %2, i64 11
%69 = load i32, i32* %68
%70 = tail call i32 @_mm_aesenc_si128(i32 %65, i32 %69)
%71 = load i32, i32* %68
%72 = tail call i32 @_mm_aesenc_si128(i32 %67, i32 %71)
%73 = getelementptr inbounds i32, i32* %2, i64 12
%74 = load i32, i32* %73
%75 = tail call i32 @_mm_aesenc_si128(i32 %70, i32 %74)
%76 = load i32, i32* %73
%77 = tail call i32 @_mm_aesenc_si128(i32 %72, i32 %76)
%78 = getelementptr inbounds i32, i32* %2, i64 13
%79 = load i32, i32* %78
%80 = tail call i32 @_mm_aesenc_si128(i32 %75, i32 %79)
%81 = load i32, i32* %78
%82 = tail call i32 @_mm_aesenc_si128(i32 %77, i32 %81)
%83 = getelementptr inbounds i32, i32* %2, i64 14
%84 = load i32, i32* %83
%85 = tail call i32 @_mm_aesenclast_si128(i32 %80, i32 %84)
%86 = load i32, i32* %83
%87 = tail call i32 @_mm_aesenclast_si128(i32 %82, i32 %86)
%88 = bitcast i8* %0 to i32*
%89 = tail call i32 @_mm_store_si128(i32* %88, i32 %85)
%90 = getelementptr inbounds i8, i8* %0, i64 16
%91 = bitcast i8* %90 to i32*
%92 = tail call i32 @_mm_store_si128(i32* %91, i32 %87)
ret void
}