#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_dec_aut_step(unsigned char *plaintextblk,
                            const unsigned char *ciphertextblk,
                            __m128i *state) {
  __m128i msg0 = _mm_load_si128((__m128i *)ciphertextblk);
  __m128i msg1 = _mm_load_si128((__m128i *)(ciphertextblk + 16));
  __m128i tmp;
  msg0 = _mm_xor_si128(msg0, state[6]);
  msg0 = _mm_xor_si128(msg0, state[1]);
  msg1 = _mm_xor_si128(msg1, state[2]);
  msg1 = _mm_xor_si128(msg1, state[5]);
  msg0 = _mm_xor_si128(msg0, _mm_and_si128(state[2], state[3]));
  msg1 = _mm_xor_si128(msg1, _mm_and_si128(state[6], state[7]));
  _mm_store_si128((__m128i *)plaintextblk, msg0);
  _mm_store_si128((__m128i *)(plaintextblk + 16), msg1);
  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_dec_aut_step>:
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    -0x10(%rbp),%rdi
add    $0x10,%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%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    -0x20(%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,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%esi
call   1070 <_mm_and_si128@plt>
mov    -0x2c(%rbp),%edi
mov    %eax,%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x1c(%rax),%esi
call   1070 <_mm_and_si128@plt>
mov    -0x28(%rbp),%edi
mov    %eax,%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <_mm_store_si128@plt>
mov    -0x8(%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    -0x1c(%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    -0x20(%rbp),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x10(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aegis128L_dec_aut_step>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %rdi,%r12
mov    %rsi,%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,%r14d
add    $0x10,%rbp
mov    %rbp,%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,%ebp
mov    0x18(%rbx),%esi
mov    %r14d,%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,%ebp
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    %ebp,%edi
mov    %eax,%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%r15d
mov    %r12,%rdi
mov    %r14d,%esi
call   1050 <_mm_store_si128@plt>
add    $0x10,%r12
mov    %r12,%rdi
mov    %r15d,%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    %r14d,%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,(%rbx)
mov    0x10(%rbx),%edi
mov    %r15d,%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x10(%rbx)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @aegis128L_dec_aut_step(i8* %0, i8* %1, i32* nocapture %2) {
%4 = bitcast i8* %1 to i32*
%5 = tail call i32 @_mm_load_si128(i32* %4)
%6 = getelementptr inbounds i8, i8* %1, 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* %0 to i32*
%32 = tail call i32 @_mm_store_si128(i32* %31, i32 %25)
%33 = getelementptr inbounds i8, i8* %0, 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 %25)
store i32 %60, i32* %2
%61 = load i32, i32* %42
%62 = tail call i32 @_mm_xor_si128(i32 %61, i32 %30)
store i32 %62, i32* %42
ret void
}