#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_enc_aut_step(const unsigned char *plaintextblk,
                           unsigned char *ciphertextblk, __m128i *state) {
  __m128i t, ct;
  __m128i msg = _mm_load_si128((__m128i *)plaintextblk);
  __m128i tmp = state[5];
  t = _mm_and_si128(state[2], state[3]);
  ct = _mm_xor_si128(msg, state[5]);
  ct = _mm_xor_si128(ct, state[4]);
  ct = _mm_xor_si128(ct, state[1]);
  ct = _mm_xor_si128(ct, t);
  _mm_store_si128((__m128i *)ciphertextblk, ct);
  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_enc_aut_step>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    0x14(%rax),%eax
mov    %eax,-0x28(%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    -0x24(%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    -0x10(%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    -0x28(%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    -0x24(%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_enc_aut_step>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r12
call   1030 <_mm_load_si128@plt>
mov    %eax,%r15d
mov    0x14(%rbx),%r14d
mov    0x8(%rbx),%edi
mov    0xc(%rbx),%esi
call   1070 <_mm_and_si128@plt>
mov    %eax,%ebp
mov    0x14(%rbx),%esi
mov    %r15d,%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    %ebp,%esi
call   1060 <_mm_xor_si128@plt>
mov    %r12,%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    %r15d,%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_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
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%11 = load i8*, i8** %4
%12 = bitcast i8* %11 to i32*
%13 = call i32 @_mm_load_si128(i32* %12)
store i32 %13, i32* %9
%14 = load i32*, i32** %6
%15 = getelementptr inbounds i32, i32* %14, i64 5
%16 = load i32, i32* %15
store i32 %16, i32* %10
%17 = load i32*, i32** %6
%18 = getelementptr inbounds i32, i32* %17, i64 2
%19 = load i32, i32* %18
%20 = load i32*, i32** %6
%21 = getelementptr inbounds i32, i32* %20, i64 3
%22 = load i32, i32* %21
%23 = call i32 @_mm_and_si128(i32 %19, i32 %22)
store i32 %23, i32* %7
%24 = load i32, i32* %9
%25 = load i32*, i32** %6
%26 = getelementptr inbounds i32, i32* %25, i64 5
%27 = load i32, i32* %26
%28 = call i32 @_mm_xor_si128(i32 %24, i32 %27)
store i32 %28, i32* %8
%29 = load i32, i32* %8
%30 = load i32*, i32** %6
%31 = getelementptr inbounds i32, i32* %30, i64 4
%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 1
%37 = load i32, i32* %36
%38 = call i32 @_mm_xor_si128(i32 %34, i32 %37)
store i32 %38, i32* %8
%39 = load i32, i32* %8
%40 = load i32, i32* %7
%41 = call i32 @_mm_xor_si128(i32 %39, i32 %40)
store i32 %41, i32* %8
%42 = load i8*, i8** %5
%43 = bitcast i8* %42 to i32*
%44 = load i32, i32* %8
%45 = call i32 @_mm_store_si128(i32* %43, i32 %44)
%46 = load i32*, i32** %6
%47 = getelementptr inbounds i32, i32* %46, i64 4
%48 = load i32, i32* %47
%49 = load i32*, i32** %6
%50 = getelementptr inbounds i32, i32* %49, i64 5
%51 = load i32, i32* %50
%52 = call i32 @_mm_aesenc_si128(i32 %48, i32 %51)
%53 = load i32*, i32** %6
%54 = getelementptr inbounds i32, i32* %53, i64 5
store i32 %52, i32* %54
%55 = load i32*, i32** %6
%56 = getelementptr inbounds i32, i32* %55, i64 3
%57 = load i32, i32* %56
%58 = load i32*, i32** %6
%59 = getelementptr inbounds i32, i32* %58, i64 4
%60 = load i32, i32* %59
%61 = call i32 @_mm_aesenc_si128(i32 %57, i32 %60)
%62 = load i32*, i32** %6
%63 = getelementptr inbounds i32, i32* %62, i64 4
store i32 %61, i32* %63
%64 = load i32*, i32** %6
%65 = getelementptr inbounds i32, i32* %64, i64 2
%66 = load i32, i32* %65
%67 = load i32*, i32** %6
%68 = getelementptr inbounds i32, i32* %67, i64 3
%69 = load i32, i32* %68
%70 = call i32 @_mm_aesenc_si128(i32 %66, i32 %69)
%71 = load i32*, i32** %6
%72 = getelementptr inbounds i32, i32* %71, i64 3
store i32 %70, i32* %72
%73 = load i32*, i32** %6
%74 = getelementptr inbounds i32, i32* %73, i64 1
%75 = load i32, i32* %74
%76 = load i32*, i32** %6
%77 = getelementptr inbounds i32, i32* %76, i64 2
%78 = load i32, i32* %77
%79 = call i32 @_mm_aesenc_si128(i32 %75, i32 %78)
%80 = load i32*, i32** %6
%81 = getelementptr inbounds i32, i32* %80, i64 2
store i32 %79, i32* %81
%82 = load i32*, i32** %6
%83 = getelementptr inbounds i32, i32* %82, i64 0
%84 = load i32, i32* %83
%85 = load i32*, i32** %6
%86 = getelementptr inbounds i32, i32* %85, i64 1
%87 = load i32, i32* %86
%88 = call i32 @_mm_aesenc_si128(i32 %84, i32 %87)
%89 = load i32*, i32** %6
%90 = getelementptr inbounds i32, i32* %89, i64 1
store i32 %88, i32* %90
%91 = load i32, i32* %10
%92 = load i32*, i32** %6
%93 = getelementptr inbounds i32, i32* %92, i64 0
%94 = load i32, i32* %93
%95 = call i32 @_mm_aesenc_si128(i32 %91, i32 %94)
%96 = load i32*, i32** %6
%97 = getelementptr inbounds i32, i32* %96, i64 0
store i32 %95, i32* %97
%98 = load i32*, i32** %6
%99 = getelementptr inbounds i32, i32* %98, i64 0
%100 = load i32, i32* %99
%101 = load i32, i32* %9
%102 = call i32 @_mm_xor_si128(i32 %100, i32 %101)
%103 = load i32*, i32** %6
%104 = getelementptr inbounds i32, i32* %103, i64 0
store i32 %102, i32* %104
ret void
}

LLVM IR (-O2):
define void @aegis256_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 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* %1 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 %5)
store i32 %41, i32* %2
ret void
}