#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 aegis256_dec_aut_step(unsigned char *plaintextblk,
                           const unsigned char *ciphertextblk, __m128i *state) {
  __m128i t;
  __m128i msg = _mm_load_si128((__m128i *)ciphertextblk);
  __m128i tmp = state[5];
  t = _mm_and_si128(state[2], state[3]);
  msg = _mm_xor_si128(msg, state[5]);
  msg = _mm_xor_si128(msg, state[4]);
  msg = _mm_xor_si128(msg, state[1]);
  msg = _mm_xor_si128(msg, t);
  _mm_store_si128((__m128i *)plaintextblk, msg);
  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], msg);
}


x86 assembly (clang, -O0):
<aegis256_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,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    0x14(%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%esi
call   1070 <_mm_and_si128@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    0x14(%rax),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1050 <_mm_store_si128@plt>
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    -0x20(%rbp),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aegis256_dec_aut_step>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%rbx
mov    %rdi,%r15
mov    %rsi,%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,%ebp
mov    0x14(%rbx),%r14d
mov    0x8(%rbx),%edi
mov    0xc(%rbx),%esi
call   1070 <_mm_and_si128@plt>
mov    %eax,%r12d
mov    0x14(%rbx),%esi
mov    %ebp,%edi
call   1060 <_mm_xor_si128@plt>
mov    0x10(%rbx),%esi
mov    %eax,%edi
call   1060 <_mm_xor_si128@plt>
mov    0x4(%rbx),%esi
mov    %eax,%edi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%edi
mov    %r12d,%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%ebp
mov    %r15,%rdi
mov    %eax,%esi
call   1050 <_mm_store_si128@plt>
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    %r14d,%edi
call   1040 <_mm_aesenc_si128@plt>
mov    %eax,(%rbx)
mov    %eax,%edi
mov    %ebp,%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,(%rbx)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @aegis256_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* %8
%13 = load i32*, i32** %6
%14 = getelementptr inbounds i32, i32* %13, i64 5
%15 = load i32, i32* %14
store i32 %15, i32* %9
%16 = load i32*, i32** %6
%17 = getelementptr inbounds i32, i32* %16, i64 2
%18 = load i32, i32* %17
%19 = load i32*, i32** %6
%20 = getelementptr inbounds i32, i32* %19, i64 3
%21 = load i32, i32* %20
%22 = call i32 @_mm_and_si128(i32 %18, i32 %21)
store i32 %22, i32* %7
%23 = load i32, i32* %8
%24 = load i32*, i32** %6
%25 = getelementptr inbounds i32, i32* %24, i64 5
%26 = load i32, i32* %25
%27 = call i32 @_mm_xor_si128(i32 %23, i32 %26)
store i32 %27, i32* %8
%28 = load i32, i32* %8
%29 = load i32*, i32** %6
%30 = getelementptr inbounds i32, i32* %29, i64 4
%31 = load i32, i32* %30
%32 = call i32 @_mm_xor_si128(i32 %28, i32 %31)
store i32 %32, i32* %8
%33 = load i32, i32* %8
%34 = load i32*, i32** %6
%35 = getelementptr inbounds i32, i32* %34, i64 1
%36 = load i32, i32* %35
%37 = call i32 @_mm_xor_si128(i32 %33, i32 %36)
store i32 %37, i32* %8
%38 = load i32, i32* %8
%39 = load i32, i32* %7
%40 = call i32 @_mm_xor_si128(i32 %38, i32 %39)
store i32 %40, i32* %8
%41 = load i8*, i8** %4
%42 = bitcast i8* %41 to i32*
%43 = load i32, i32* %8
%44 = call i32 @_mm_store_si128(i32* %42, i32 %43)
%45 = load i32*, i32** %6
%46 = getelementptr inbounds i32, i32* %45, i64 4
%47 = load i32, i32* %46
%48 = load i32*, i32** %6
%49 = getelementptr inbounds i32, i32* %48, i64 5
%50 = load i32, i32* %49
%51 = call i32 @_mm_aesenc_si128(i32 %47, i32 %50)
%52 = load i32*, i32** %6
%53 = getelementptr inbounds i32, i32* %52, i64 5
store i32 %51, i32* %53
%54 = load i32*, i32** %6
%55 = getelementptr inbounds i32, i32* %54, i64 3
%56 = load i32, i32* %55
%57 = load i32*, i32** %6
%58 = getelementptr inbounds i32, i32* %57, i64 4
%59 = load i32, i32* %58
%60 = call i32 @_mm_aesenc_si128(i32 %56, i32 %59)
%61 = load i32*, i32** %6
%62 = getelementptr inbounds i32, i32* %61, i64 4
store i32 %60, i32* %62
%63 = load i32*, i32** %6
%64 = getelementptr inbounds i32, i32* %63, i64 2
%65 = load i32, i32* %64
%66 = load i32*, i32** %6
%67 = getelementptr inbounds i32, i32* %66, i64 3
%68 = load i32, i32* %67
%69 = call i32 @_mm_aesenc_si128(i32 %65, i32 %68)
%70 = load i32*, i32** %6
%71 = getelementptr inbounds i32, i32* %70, i64 3
store i32 %69, i32* %71
%72 = load i32*, i32** %6
%73 = getelementptr inbounds i32, i32* %72, i64 1
%74 = load i32, i32* %73
%75 = load i32*, i32** %6
%76 = getelementptr inbounds i32, i32* %75, i64 2
%77 = load i32, i32* %76
%78 = call i32 @_mm_aesenc_si128(i32 %74, i32 %77)
%79 = load i32*, i32** %6
%80 = getelementptr inbounds i32, i32* %79, i64 2
store i32 %78, i32* %80
%81 = load i32*, i32** %6
%82 = getelementptr inbounds i32, i32* %81, i64 0
%83 = load i32, i32* %82
%84 = load i32*, i32** %6
%85 = getelementptr inbounds i32, i32* %84, i64 1
%86 = load i32, i32* %85
%87 = call i32 @_mm_aesenc_si128(i32 %83, i32 %86)
%88 = load i32*, i32** %6
%89 = getelementptr inbounds i32, i32* %88, i64 1
store i32 %87, i32* %89
%90 = load i32, i32* %9
%91 = load i32*, i32** %6
%92 = getelementptr inbounds i32, i32* %91, i64 0
%93 = load i32, i32* %92
%94 = call i32 @_mm_aesenc_si128(i32 %90, i32 %93)
%95 = load i32*, i32** %6
%96 = getelementptr inbounds i32, i32* %95, i64 0
store i32 %94, i32* %96
%97 = load i32*, i32** %6
%98 = getelementptr inbounds i32, i32* %97, i64 0
%99 = load i32, i32* %98
%100 = load i32, i32* %8
%101 = call i32 @_mm_xor_si128(i32 %99, i32 %100)
%102 = load i32*, i32** %6
%103 = getelementptr inbounds i32, i32* %102, i64 0
store i32 %101, i32* %103
ret void
}

LLVM IR (-O2):
define void @aegis256_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 i32, i32* %2, i64 5
%7 = load i32, i32* %6
%8 = getelementptr inbounds i32, i32* %2, i64 2
%9 = load i32, i32* %8
%10 = getelementptr inbounds i32, i32* %2, i64 3
%11 = load i32, i32* %10
%12 = tail call i32 @_mm_and_si128(i32 %9, i32 %11)
%13 = load i32, i32* %6
%14 = tail call i32 @_mm_xor_si128(i32 %5, i32 %13)
%15 = getelementptr inbounds i32, i32* %2, i64 4
%16 = load i32, i32* %15
%17 = tail call i32 @_mm_xor_si128(i32 %14, i32 %16)
%18 = getelementptr inbounds i32, i32* %2, i64 1
%19 = load i32, i32* %18
%20 = tail call i32 @_mm_xor_si128(i32 %17, i32 %19)
%21 = tail call i32 @_mm_xor_si128(i32 %20, i32 %12)
%22 = bitcast i8* %0 to i32*
%23 = tail call i32 @_mm_store_si128(i32* %22, i32 %21)
%24 = load i32, i32* %15
%25 = load i32, i32* %6
%26 = tail call i32 @_mm_aesenc_si128(i32 %24, i32 %25)
store i32 %26, i32* %6
%27 = load i32, i32* %10
%28 = load i32, i32* %15
%29 = tail call i32 @_mm_aesenc_si128(i32 %27, i32 %28)
store i32 %29, i32* %15
%30 = load i32, i32* %8
%31 = load i32, i32* %10
%32 = tail call i32 @_mm_aesenc_si128(i32 %30, i32 %31)
store i32 %32, i32* %10
%33 = load i32, i32* %18
%34 = load i32, i32* %8
%35 = tail call i32 @_mm_aesenc_si128(i32 %33, i32 %34)
store i32 %35, i32* %8
%36 = load i32, i32* %2
%37 = load i32, i32* %18
%38 = tail call i32 @_mm_aesenc_si128(i32 %36, i32 %37)
store i32 %38, i32* %18
%39 = load i32, i32* %2
%40 = tail call i32 @_mm_aesenc_si128(i32 %7, i32 %39)
store i32 %40, i32* %2
%41 = tail call i32 @_mm_xor_si128(i32 %40, i32 %21)
store i32 %41, i32* %2
ret void
}