#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*/ uint8_t;
typedef int /*<<< orphan*/ __m128i;

/* Variables and functions */
int /*<<< orphan*/ _mm_and_si128(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_load_si128(int /*<<< orphan*/ *);
int /*<<< orphan*/ _mm_or_si128(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_slli_si128(int /*<<< orphan*/, int);
int /*<<< orphan*/ _mm_srli_si128(int /*<<< orphan*/, int);
int /*<<< orphan*/ _mm_store_si128(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_xor_si128(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ morus_stateupdate(int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ **);
void morus_enc_aut_step(const uint8_t *plaintextblock, uint8_t *ciphertextblock,
                        __m128i (*state)[2]) {
  __m128i keystream[2];
  __m128i msgblk[2];
  msgblk[0] = _mm_load_si128((__m128i *)plaintextblock);
  msgblk[1] = _mm_load_si128((__m128i *)(plaintextblock + 16));
  keystream[0] = _mm_xor_si128(
      (state[0][0]), (_mm_or_si128((_mm_slli_si128(state[1][1], 8)),
                                   (_mm_srli_si128(state[1][0], 8)))));
  keystream[1] = _mm_xor_si128(
      (state[0][1]), (_mm_or_si128((_mm_slli_si128(state[1][0], 8)),
                                   (_mm_srli_si128(state[1][1], 8)))));
  keystream[0] = _mm_xor_si128((keystream[0]),
                               (_mm_and_si128((state[2][0]), (state[3][0]))));
  keystream[1] = _mm_xor_si128((keystream[1]),
                               (_mm_and_si128((state[2][1]), (state[3][1]))));
  _mm_store_si128((__m128i *)ciphertextblock,
                  _mm_xor_si128((keystream[0]), (msgblk[0])));
  _mm_store_si128((__m128i *)(ciphertextblock + 16),
                  _mm_xor_si128((keystream[1]), (msgblk[1])));
  morus_stateupdate(msgblk, state);
}


x86 assembly (clang, -O0):
<morus_enc_aut_step>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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    $0x40,%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%edi
mov    $0x8,%esi
call   10a0 <_mm_slli_si128@plt>
mov    %eax,-0x50(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
mov    $0x8,%esi
call   1040 <_mm_srli_si128@plt>
mov    -0x50(%rbp),%edi
mov    %eax,%esi
call   1060 <_mm_or_si128@plt>
mov    -0x4c(%rbp),%edi
mov    %eax,%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
mov    $0x8,%esi
call   10a0 <_mm_slli_si128@plt>
mov    %eax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%edi
mov    $0x8,%esi
call   1040 <_mm_srli_si128@plt>
mov    -0x48(%rbp),%edi
mov    %eax,%esi
call   1060 <_mm_or_si128@plt>
mov    -0x44(%rbp),%edi
mov    %eax,%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%esi
call   1090 <_mm_and_si128@plt>
mov    -0x40(%rbp),%edi
mov    %eax,%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x14(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x1c(%rax),%esi
call   1090 <_mm_and_si128@plt>
mov    -0x3c(%rbp),%edi
mov    %eax,%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1070 <_mm_xor_si128@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
call   1050 <_mm_store_si128@plt>
mov    -0x10(%rbp),%rax
add    $0x40,%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1070 <_mm_xor_si128@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
call   1050 <_mm_store_si128@plt>
lea    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <morus_stateupdate@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<morus_enc_aut_step>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%rbp
call   1030 <_mm_load_si128@plt>
mov    %eax,%r12d
mov    %eax,0x10(%rsp)
add    $0x40,%rbp
mov    %rbp,%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,0xc(%rsp)
mov    %eax,0x14(%rsp)
mov    (%rbx),%r13d
mov    0xc(%rbx),%edi
mov    $0x8,%esi
call   10a0 <_mm_slli_si128@plt>
mov    %eax,%ebp
mov    0x8(%rbx),%edi
mov    $0x8,%esi
call   1040 <_mm_srli_si128@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1060 <_mm_or_si128@plt>
mov    %r13d,%edi
mov    %eax,%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,%r13d
mov    0x4(%rbx),%ebp
mov    0x8(%rbx),%edi
mov    $0x8,%esi
call   10a0 <_mm_slli_si128@plt>
mov    %eax,%r15d
mov    0xc(%rbx),%edi
mov    $0x8,%esi
call   1040 <_mm_srli_si128@plt>
mov    %r15d,%edi
mov    %eax,%esi
call   1060 <_mm_or_si128@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,%r15d
mov    0x10(%rbx),%edi
mov    0x18(%rbx),%esi
call   1090 <_mm_and_si128@plt>
mov    %r13d,%edi
mov    %eax,%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,%r13d
mov    0x14(%rbx),%edi
mov    0x1c(%rbx),%esi
call   1090 <_mm_and_si128@plt>
mov    %r15d,%edi
mov    %eax,%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,%ebp
mov    %r13d,%edi
mov    %r12d,%esi
call   1070 <_mm_xor_si128@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <_mm_store_si128@plt>
add    $0x40,%r14
mov    %ebp,%edi
mov    0xc(%rsp),%esi
call   1070 <_mm_xor_si128@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <_mm_store_si128@plt>
lea    0x10(%rsp),%rdi
mov    %rbx,%rsi
call   1080 <morus_stateupdate@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @morus_enc_aut_step(i32* %0, i32* %1, [2 x i32]* %2) {
%4 = alloca [2 x i32]
%5 = bitcast [2 x i32]* %4 to i8*
%6 = tail call i32 @_mm_load_si128(i32* %0)
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
store i32 %6, i32* %7
%8 = getelementptr inbounds i32, i32* %0, i64 16
%9 = tail call i32 @_mm_load_si128(i32* %8)
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
store i32 %9, i32* %10
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%12 = load i32, i32* %11
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 1, i64 1
%14 = load i32, i32* %13
%15 = tail call i32 @_mm_slli_si128(i32 %14, i32 8)
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 1, i64 0
%17 = load i32, i32* %16
%18 = tail call i32 @_mm_srli_si128(i32 %17, i32 8)
%19 = tail call i32 @_mm_or_si128(i32 %15, i32 %18)
%20 = tail call i32 @_mm_xor_si128(i32 %12, i32 %19)
%21 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%22 = load i32, i32* %21
%23 = load i32, i32* %16
%24 = tail call i32 @_mm_slli_si128(i32 %23, i32 8)
%25 = load i32, i32* %13
%26 = tail call i32 @_mm_srli_si128(i32 %25, i32 8)
%27 = tail call i32 @_mm_or_si128(i32 %24, i32 %26)
%28 = tail call i32 @_mm_xor_si128(i32 %22, i32 %27)
%29 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 2, i64 0
%30 = load i32, i32* %29
%31 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 3, i64 0
%32 = load i32, i32* %31
%33 = tail call i32 @_mm_and_si128(i32 %30, i32 %32)
%34 = tail call i32 @_mm_xor_si128(i32 %20, i32 %33)
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 2, i64 1
%36 = load i32, i32* %35
%37 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 3, i64 1
%38 = load i32, i32* %37
%39 = tail call i32 @_mm_and_si128(i32 %36, i32 %38)
%40 = tail call i32 @_mm_xor_si128(i32 %28, i32 %39)
%41 = tail call i32 @_mm_xor_si128(i32 %34, i32 %6)
%42 = tail call i32 @_mm_store_si128(i32* %1, i32 %41)
%43 = getelementptr inbounds i32, i32* %1, i64 16
%44 = tail call i32 @_mm_xor_si128(i32 %40, i32 %9)
%45 = tail call i32 @_mm_store_si128(i32* %43, i32 %44)
%46 = bitcast [2 x i32]* %2 to i32**
%47 = call i32 @morus_stateupdate(i32* %7, i32** %46)
ret void
}