#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_SHUFFLE(int /*<<< orphan*/, int, int, int);
int /*<<< orphan*/ _mm_and_si128(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_load_si128(int /*<<< orphan*/ *);
int /*<<< orphan*/ _mm_shuffle_epi32(int /*<<< orphan*/, int /*<<< orphan*/);
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_dec_aut_step(unsigned char *plaintextblock,
                        const unsigned char *ciphertextblock, __m128i *state) {
  __m128i keystream;
  __m128i msgblk = _mm_load_si128((__m128i *)ciphertextblock);
  keystream = _mm_xor_si128(
      (state[0]), (_mm_shuffle_epi32((state[1]), _MM_SHUFFLE(0, 3, 2, 1))));
  keystream =
      _mm_xor_si128((keystream), (_mm_and_si128((state[2]), (state[3]))));
  msgblk = _mm_xor_si128((keystream), (msgblk));
  _mm_store_si128((__m128i *)plaintextblock, msgblk);
  morus_stateupdate(msgblk, state);
}


x86 assembly (clang, -O0):
<morus_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   1040 <_mm_load_si128@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x2c(%rbp)
xor    %edi,%edi
mov    $0x3,%esi
mov    $0x2,%edx
mov    $0x1,%ecx
call   1030 <_MM_SHUFFLE@plt>
mov    -0x2c(%rbp),%edi
mov    %eax,%esi
call   1060 <_mm_shuffle_epi32@plt>
mov    -0x28(%rbp),%edi
mov    %eax,%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%esi
call   1090 <_mm_and_si128@plt>
mov    -0x24(%rbp),%edi
mov    %eax,%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1050 <_mm_store_si128@plt>
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1080 <morus_stateupdate@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<morus_dec_aut_step>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <_mm_load_si128@plt>
mov    %eax,%r15d
mov    (%rbx),%r12d
mov    0x4(%rbx),%ebp
xor    %edi,%edi
mov    $0x3,%esi
mov    $0x2,%edx
mov    $0x1,%ecx
call   1030 <_MM_SHUFFLE@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1060 <_mm_shuffle_epi32@plt>
mov    %r12d,%edi
mov    %eax,%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,%ebp
mov    0x8(%rbx),%edi
mov    0xc(%rbx),%esi
call   1090 <_mm_and_si128@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,%edi
mov    %r15d,%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <_mm_store_si128@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <morus_stateupdate@plt>

LLVM IR (-O0):
define void @morus_dec_aut_step(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%9 = load i8*, i8** %5
%10 = bitcast i8* %9 to i32*
%11 = call i32 @_mm_load_si128(i32* %10)
store i32 %11, i32* %8
%12 = load i32*, i32** %6
%13 = getelementptr inbounds i32, i32* %12, i64 0
%14 = load i32, i32* %13
%15 = load i32*, i32** %6
%16 = getelementptr inbounds i32, i32* %15, i64 1
%17 = load i32, i32* %16
%18 = call i32 @_MM_SHUFFLE(i32 0, i32 3, i32 2, i32 1)
%19 = call i32 @_mm_shuffle_epi32(i32 %17, i32 %18)
%20 = call i32 @_mm_xor_si128(i32 %14, i32 %19)
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = load i32*, i32** %6
%23 = getelementptr inbounds i32, i32* %22, i64 2
%24 = load i32, i32* %23
%25 = load i32*, i32** %6
%26 = getelementptr inbounds i32, i32* %25, i64 3
%27 = load i32, i32* %26
%28 = call i32 @_mm_and_si128(i32 %24, i32 %27)
%29 = call i32 @_mm_xor_si128(i32 %21, i32 %28)
store i32 %29, i32* %7
%30 = load i32, i32* %7
%31 = load i32, i32* %8
%32 = call i32 @_mm_xor_si128(i32 %30, i32 %31)
store i32 %32, i32* %8
%33 = load i8*, i8** %4
%34 = bitcast i8* %33 to i32*
%35 = load i32, i32* %8
%36 = call i32 @_mm_store_si128(i32* %34, i32 %35)
%37 = load i32, i32* %8
%38 = load i32*, i32** %6
%39 = call i32 @morus_stateupdate(i32 %37, i32* %38)
ret void
}

LLVM IR (-O2):
define void @morus_dec_aut_step(i8* %0, i8* %1, i32* %2) {
%4 = bitcast i8* %1 to i32*
%5 = tail call i32 @_mm_load_si128(i32* %4)
%6 = load i32, i32* %2
%7 = getelementptr inbounds i32, i32* %2, i64 1
%8 = load i32, i32* %7
%9 = tail call i32 @_MM_SHUFFLE(i32 0, i32 3, i32 2, i32 1)
%10 = tail call i32 @_mm_shuffle_epi32(i32 %8, i32 %9)
%11 = tail call i32 @_mm_xor_si128(i32 %6, i32 %10)
%12 = getelementptr inbounds i32, i32* %2, i64 2
%13 = load i32, i32* %12
%14 = getelementptr inbounds i32, i32* %2, i64 3
%15 = load i32, i32* %14
%16 = tail call i32 @_mm_and_si128(i32 %13, i32 %15)
%17 = tail call i32 @_mm_xor_si128(i32 %11, i32 %16)
%18 = tail call i32 @_mm_xor_si128(i32 %17, i32 %5)
%19 = bitcast i8* %0 to i32*
%20 = tail call i32 @_mm_store_si128(i32* %19, i32 %18)
%21 = tail call i32 @morus_stateupdate(i32 %18, i32* %2)
ret void
}