#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_and_si128(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_load_si128(int /*<<< orphan*/ *);
int /*<<< orphan*/ _mm_store_si128(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_xor_si128(int /*<<< orphan*/, int /*<<< orphan*/);
void aegis128L_enc_aut_step(const unsigned char *plaintextblk,
                            unsigned char *ciphertextblk, __m128i *state) {
  __m128i ct0, ct1;
  __m128i tmp;
  __m128i msg0 = _mm_load_si128((__m128i *)plaintextblk);
  __m128i msg1 = _mm_load_si128((__m128i *)(plaintextblk + 16));
  ct0 = _mm_xor_si128(msg0, state[6]);
  ct0 = _mm_xor_si128(ct0, state[1]);
  ct1 = _mm_xor_si128(msg1, state[2]);
  ct1 = _mm_xor_si128(ct1, state[5]);
  ct0 = _mm_xor_si128(ct0, _mm_and_si128(state[2], state[3]));
  ct1 = _mm_xor_si128(ct1, _mm_and_si128(state[6], state[7]));
  _mm_store_si128((__m128i *)ciphertextblk, ct0);
  _mm_store_si128((__m128i *)(ciphertextblk + 16), ct1);
  tmp = state[7];
  state[7] = _mm_aesenc_si128(state[6], state[7]);
  state[6] = _mm_aesenc_si128(state[5], state[6]);
  state[5] = _mm_aesenc_si128(state[4], state[5]);
  state[4] = _mm_aesenc_si128(state[3], state[4]);
  state[3] = _mm_aesenc_si128(state[2], state[3]);
  state[2] = _mm_aesenc_si128(state[1], state[2]);
  state[1] = _mm_aesenc_si128(state[0], state[1]);
  state[0] = _mm_aesenc_si128(tmp, state[0]);
  state[0] = _mm_xor_si128(state[0], msg0);
  state[4] = _mm_xor_si128(state[4], msg1);
}


x86 assembly (clang, -O0):
<aegis128L_enc_aut_step>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x10,%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    0x14(%rax),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%esi
call   1070 <_mm_and_si128@plt>
mov    -0x34(%rbp),%edi
mov    %eax,%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x1c(%rax),%esi
call   1070 <_mm_and_si128@plt>
mov    -0x30(%rbp),%edi
mov    %eax,%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <_mm_store_si128@plt>
mov    -0x10(%rbp),%rdi
add    $0x10,%rdi
mov    -0x20(%rbp),%esi
call   1050 <_mm_store_si128@plt>
mov    -0x18(%rbp),%rax
mov    0x1c(%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x1c(%rax),%esi
call   1040 <_mm_aesenc_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x1c(%rax)
mov    -0x18(%rbp),%rax
mov    0x14(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%esi
call   1040 <_mm_aesenc_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x14(%rax),%esi
call   1040 <_mm_aesenc_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%esi
call   1040 <_mm_aesenc_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%esi
call   1040 <_mm_aesenc_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%esi
call   1040 <_mm_aesenc_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%esi
call   1040 <_mm_aesenc_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x24(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1040 <_mm_aesenc_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x2c(%rbp),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x10(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aegis128L_enc_aut_step>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %rdi,%rbp
call   1030 <_mm_load_si128@plt>
mov    %eax,%r15d
add    $0x10,%rbp
mov    %rbp,%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,%ebp
mov    %eax,0x4(%rsp)
mov    0x18(%rbx),%esi
mov    %r15d,%edi
call   1060 <_mm_xor_si128@plt>
mov    0x4(%rbx),%esi
mov    %eax,%edi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%r14d
mov    0x8(%rbx),%esi
mov    %ebp,%edi
call   1060 <_mm_xor_si128@plt>
mov    0x14(%rbx),%esi
mov    %eax,%edi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%r13d
mov    0x8(%rbx),%edi
mov    0xc(%rbx),%esi
call   1070 <_mm_and_si128@plt>
mov    %r14d,%edi
mov    %eax,%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%r14d
mov    0x18(%rbx),%edi
mov    0x1c(%rbx),%esi
call   1070 <_mm_and_si128@plt>
mov    %r13d,%edi
mov    %eax,%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%ebp
mov    %r12,%rdi
mov    %r14d,%esi
call   1050 <_mm_store_si128@plt>
add    $0x10,%r12
mov    %r12,%rdi
mov    %ebp,%esi
call   1050 <_mm_store_si128@plt>
mov    0x18(%rbx),%edi
mov    0x1c(%rbx),%ebp
mov    %ebp,%esi
call   1040 <_mm_aesenc_si128@plt>
mov    %eax,0x1c(%rbx)
mov    0x14(%rbx),%edi
mov    0x18(%rbx),%esi
call   1040 <_mm_aesenc_si128@plt>
mov    %eax,0x18(%rbx)
mov    0x10(%rbx),%edi
mov    0x14(%rbx),%esi
call   1040 <_mm_aesenc_si128@plt>
mov    %eax,0x14(%rbx)
mov    0xc(%rbx),%edi
mov    0x10(%rbx),%esi
call   1040 <_mm_aesenc_si128@plt>
mov    %eax,0x10(%rbx)
mov    0x8(%rbx),%edi
mov    0xc(%rbx),%esi
call   1040 <_mm_aesenc_si128@plt>
mov    %eax,0xc(%rbx)
mov    0x4(%rbx),%edi
mov    0x8(%rbx),%esi
call   1040 <_mm_aesenc_si128@plt>
mov    %eax,0x8(%rbx)
mov    (%rbx),%edi
mov    0x4(%rbx),%esi
call   1040 <_mm_aesenc_si128@plt>
mov    %eax,0x4(%rbx)
mov    (%rbx),%esi
mov    %ebp,%edi
call   1040 <_mm_aesenc_si128@plt>
mov    %eax,(%rbx)
mov    %eax,%edi
mov    %r15d,%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,(%rbx)
mov    0x10(%rbx),%edi
mov    0x4(%rsp),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x10(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @aegis128L_enc_aut_step(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%12 = load i8*, i8** %4
%13 = bitcast i8* %12 to i32*
%14 = call i32 @_mm_load_si128(i32* %13)
store i32 %14, i32* %10
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 16
%17 = bitcast i8* %16 to i32*
%18 = call i32 @_mm_load_si128(i32* %17)
store i32 %18, i32* %11
%19 = load i32, i32* %10
%20 = load i32*, i32** %6
%21 = getelementptr inbounds i32, i32* %20, i64 6
%22 = load i32, i32* %21
%23 = call i32 @_mm_xor_si128(i32 %19, i32 %22)
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = load i32*, i32** %6
%26 = getelementptr inbounds i32, i32* %25, i64 1
%27 = load i32, i32* %26
%28 = call i32 @_mm_xor_si128(i32 %24, i32 %27)
store i32 %28, i32* %7
%29 = load i32, i32* %11
%30 = load i32*, i32** %6
%31 = getelementptr inbounds i32, i32* %30, i64 2
%32 = load i32, i32* %31
%33 = call i32 @_mm_xor_si128(i32 %29, i32 %32)
store i32 %33, i32* %8
%34 = load i32, i32* %8
%35 = load i32*, i32** %6
%36 = getelementptr inbounds i32, i32* %35, i64 5
%37 = load i32, i32* %36
%38 = call i32 @_mm_xor_si128(i32 %34, i32 %37)
store i32 %38, i32* %8
%39 = load i32, i32* %7
%40 = load i32*, i32** %6
%41 = getelementptr inbounds i32, i32* %40, i64 2
%42 = load i32, i32* %41
%43 = load i32*, i32** %6
%44 = getelementptr inbounds i32, i32* %43, i64 3
%45 = load i32, i32* %44
%46 = call i32 @_mm_and_si128(i32 %42, i32 %45)
%47 = call i32 @_mm_xor_si128(i32 %39, i32 %46)
store i32 %47, i32* %7
%48 = load i32, i32* %8
%49 = load i32*, i32** %6
%50 = getelementptr inbounds i32, i32* %49, i64 6
%51 = load i32, i32* %50
%52 = load i32*, i32** %6
%53 = getelementptr inbounds i32, i32* %52, i64 7
%54 = load i32, i32* %53
%55 = call i32 @_mm_and_si128(i32 %51, i32 %54)
%56 = call i32 @_mm_xor_si128(i32 %48, i32 %55)
store i32 %56, i32* %8
%57 = load i8*, i8** %5
%58 = bitcast i8* %57 to i32*
%59 = load i32, i32* %7
%60 = call i32 @_mm_store_si128(i32* %58, i32 %59)
%61 = load i8*, i8** %5
%62 = getelementptr inbounds i8, i8* %61, i64 16
%63 = bitcast i8* %62 to i32*
%64 = load i32, i32* %8
%65 = call i32 @_mm_store_si128(i32* %63, i32 %64)
%66 = load i32*, i32** %6
%67 = getelementptr inbounds i32, i32* %66, i64 7
%68 = load i32, i32* %67
store i32 %68, i32* %9
%69 = load i32*, i32** %6
%70 = getelementptr inbounds i32, i32* %69, i64 6
%71 = load i32, i32* %70
%72 = load i32*, i32** %6
%73 = getelementptr inbounds i32, i32* %72, i64 7
%74 = load i32, i32* %73
%75 = call i32 @_mm_aesenc_si128(i32 %71, i32 %74)
%76 = load i32*, i32** %6
%77 = getelementptr inbounds i32, i32* %76, i64 7
store i32 %75, i32* %77
%78 = load i32*, i32** %6
%79 = getelementptr inbounds i32, i32* %78, i64 5
%80 = load i32, i32* %79
%81 = load i32*, i32** %6
%82 = getelementptr inbounds i32, i32* %81, i64 6
%83 = load i32, i32* %82
%84 = call i32 @_mm_aesenc_si128(i32 %80, i32 %83)
%85 = load i32*, i32** %6
%86 = getelementptr inbounds i32, i32* %85, i64 6
store i32 %84, i32* %86
%87 = load i32*, i32** %6
%88 = getelementptr inbounds i32, i32* %87, i64 4
%89 = load i32, i32* %88
%90 = load i32*, i32** %6
%91 = getelementptr inbounds i32, i32* %90, i64 5
%92 = load i32, i32* %91
%93 = call i32 @_mm_aesenc_si128(i32 %89, i32 %92)
%94 = load i32*, i32** %6
%95 = getelementptr inbounds i32, i32* %94, i64 5
store i32 %93, i32* %95
%96 = load i32*, i32** %6
%97 = getelementptr inbounds i32, i32* %96, i64 3
%98 = load i32, i32* %97
%99 = load i32*, i32** %6
%100 = getelementptr inbounds i32, i32* %99, i64 4
%101 = load i32, i32* %100
%102 = call i32 @_mm_aesenc_si128(i32 %98, i32 %101)
%103 = load i32*, i32** %6
%104 = getelementptr inbounds i32, i32* %103, i64 4
store i32 %102, i32* %104
%105 = load i32*, i32** %6
%106 = getelementptr inbounds i32, i32* %105, i64 2
%107 = load i32, i32* %106
%108 = load i32*, i32** %6
%109 = getelementptr inbounds i32, i32* %108, i64 3
%110 = load i32, i32* %109
%111 = call i32 @_mm_aesenc_si128(i32 %107, i32 %110)
%112 = load i32*, i32** %6
%113 = getelementptr inbounds i32, i32* %112, i64 3
store i32 %111, i32* %113
%114 = load i32*, i32** %6
%115 = getelementptr inbounds i32, i32* %114, i64 1
%116 = load i32, i32* %115
%117 = load i32*, i32** %6
%118 = getelementptr inbounds i32, i32* %117, i64 2
%119 = load i32, i32* %118
%120 = call i32 @_mm_aesenc_si128(i32 %116, i32 %119)
%121 = load i32*, i32** %6
%122 = getelementptr inbounds i32, i32* %121, i64 2
store i32 %120, i32* %122
%123 = load i32*, i32** %6
%124 = getelementptr inbounds i32, i32* %123, i64 0
%125 = load i32, i32* %124
%126 = load i32*, i32** %6
%127 = getelementptr inbounds i32, i32* %126, i64 1
%128 = load i32, i32* %127
%129 = call i32 @_mm_aesenc_si128(i32 %125, i32 %128)
%130 = load i32*, i32** %6
%131 = getelementptr inbounds i32, i32* %130, i64 1
store i32 %129, i32* %131
%132 = load i32, i32* %9
%133 = load i32*, i32** %6
%134 = getelementptr inbounds i32, i32* %133, i64 0
%135 = load i32, i32* %134
%136 = call i32 @_mm_aesenc_si128(i32 %132, i32 %135)
%137 = load i32*, i32** %6
%138 = getelementptr inbounds i32, i32* %137, i64 0
store i32 %136, i32* %138
%139 = load i32*, i32** %6
%140 = getelementptr inbounds i32, i32* %139, i64 0
%141 = load i32, i32* %140
%142 = load i32, i32* %10
%143 = call i32 @_mm_xor_si128(i32 %141, i32 %142)
%144 = load i32*, i32** %6
%145 = getelementptr inbounds i32, i32* %144, i64 0
store i32 %143, i32* %145
%146 = load i32*, i32** %6
%147 = getelementptr inbounds i32, i32* %146, i64 4
%148 = load i32, i32* %147
%149 = load i32, i32* %11
%150 = call i32 @_mm_xor_si128(i32 %148, i32 %149)
%151 = load i32*, i32** %6
%152 = getelementptr inbounds i32, i32* %151, i64 4
store i32 %150, i32* %152
ret void
}

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