#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*/ const uint8_t;
typedef int /*<<< orphan*/ uint64_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*/ memcpy(int /*<<< orphan*/ const *,
                          int /*<<< orphan*/ const *, int /*<<< orphan*/);
int /*<<< orphan*/ memset(int /*<<< orphan*/ const *, int /*<<< orphan*/, int);
int /*<<< orphan*/ morus_stateupdate(int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ **);
void morus_enc_aut_partialblock(const uint8_t *plaintext, uint8_t *ciphertext,
                                uint64_t len, __m128i (*state)[2]) {
  uint8_t plaintextblock[32], ciphertextblock[32];
  __m128i keystream[2];
  __m128i msgblk[2];
  memset(plaintextblock, 0, 32);
  memcpy(plaintextblock, plaintext, len);
  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])));
  memcpy(ciphertext, ciphertextblock, len);
  morus_stateupdate(msgblk, state);
}


x86 assembly (clang, -O0):
<morus_enc_aut_partialblock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1070 <memcpy@plt>
lea    -0xa0(%rbp),%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,-0x130(%rbp)
lea    -0xa0(%rbp),%rdi
add    $0x40,%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,-0x12c(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x154(%rbp)
mov    -0x20(%rbp),%rax
mov    0xc(%rax),%edi
mov    $0x8,%esi
call   10c0 <_mm_slli_si128@plt>
mov    %eax,-0x158(%rbp)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%edi
mov    $0x8,%esi
call   1050 <_mm_srli_si128@plt>
mov    -0x158(%rbp),%edi
mov    %eax,%esi
call   1080 <_mm_or_si128@plt>
mov    -0x154(%rbp),%edi
mov    %eax,%esi
call   1090 <_mm_xor_si128@plt>
mov    %eax,-0x128(%rbp)
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x14c(%rbp)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%edi
mov    $0x8,%esi
call   10c0 <_mm_slli_si128@plt>
mov    %eax,-0x150(%rbp)
mov    -0x20(%rbp),%rax
mov    0xc(%rax),%edi
mov    $0x8,%esi
call   1050 <_mm_srli_si128@plt>
mov    -0x150(%rbp),%edi
mov    %eax,%esi
call   1080 <_mm_or_si128@plt>
mov    -0x14c(%rbp),%edi
mov    %eax,%esi
call   1090 <_mm_xor_si128@plt>
mov    %eax,-0x124(%rbp)
mov    -0x128(%rbp),%eax
mov    %eax,-0x148(%rbp)
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x20(%rbp),%rax
mov    0x18(%rax),%esi
call   10b0 <_mm_and_si128@plt>
mov    -0x148(%rbp),%edi
mov    %eax,%esi
call   1090 <_mm_xor_si128@plt>
mov    %eax,-0x128(%rbp)
mov    -0x124(%rbp),%eax
mov    %eax,-0x144(%rbp)
mov    -0x20(%rbp),%rax
mov    0x14(%rax),%edi
mov    -0x20(%rbp),%rax
mov    0x1c(%rax),%esi
call   10b0 <_mm_and_si128@plt>
mov    -0x144(%rbp),%edi
mov    %eax,%esi
call   1090 <_mm_xor_si128@plt>
mov    %eax,-0x124(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x140(%rbp)
mov    -0x128(%rbp),%edi
mov    -0x130(%rbp),%esi
call   1090 <_mm_xor_si128@plt>
mov    -0x140(%rbp),%rdi
mov    %eax,%esi
call   1060 <_mm_store_si128@plt>
lea    -0x120(%rbp),%rax
add    $0x40,%rax
mov    %rax,-0x138(%rbp)
mov    -0x124(%rbp),%edi
mov    -0x12c(%rbp),%esi
call   1090 <_mm_xor_si128@plt>
mov    -0x138(%rbp),%rdi
mov    %eax,%esi
call   1060 <_mm_store_si128@plt>
mov    -0x10(%rbp),%rdi
lea    -0x120(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1070 <memcpy@plt>
lea    -0x130(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10a0 <morus_stateupdate@plt>
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<morus_enc_aut_partialblock>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %rcx,%rbx
mov    %edx,%ebp
mov    %edx,0xc(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rdi,%r14
lea    0xa0(%rsp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1070 <memcpy@plt>
mov    %r12,%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,%r13d
mov    %eax,0x10(%rsp)
lea    0xe0(%rsp),%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,%r12d
mov    %eax,0x14(%rsp)
mov    (%rbx),%ebp
mov    0xc(%rbx),%edi
mov    $0x8,%esi
call   10c0 <_mm_slli_si128@plt>
mov    %eax,%r14d
mov    0x8(%rbx),%edi
mov    $0x8,%esi
call   1050 <_mm_srli_si128@plt>
mov    %r14d,%edi
mov    %eax,%esi
call   1080 <_mm_or_si128@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1090 <_mm_xor_si128@plt>
mov    %eax,%r14d
mov    0x4(%rbx),%ebp
mov    0x8(%rbx),%edi
mov    $0x8,%esi
call   10c0 <_mm_slli_si128@plt>
mov    %eax,%r15d
mov    0xc(%rbx),%edi
mov    $0x8,%esi
call   1050 <_mm_srli_si128@plt>
mov    %r15d,%edi
mov    %eax,%esi
call   1080 <_mm_or_si128@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1090 <_mm_xor_si128@plt>
mov    %eax,%r15d
mov    0x10(%rbx),%edi
mov    0x18(%rbx),%esi
call   10b0 <_mm_and_si128@plt>
mov    %r14d,%edi
mov    %eax,%esi
call   1090 <_mm_xor_si128@plt>
mov    %eax,%r14d
mov    0x14(%rbx),%edi
mov    0x1c(%rbx),%esi
call   10b0 <_mm_and_si128@plt>
mov    %r15d,%edi
mov    %eax,%esi
call   1090 <_mm_xor_si128@plt>
mov    %eax,%ebp
mov    %r14d,%edi
mov    %r13d,%esi
call   1090 <_mm_xor_si128@plt>
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <_mm_store_si128@plt>
lea    0x60(%rsp),%r15
mov    %ebp,%edi
mov    %r12d,%esi
call   1090 <_mm_xor_si128@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1060 <_mm_store_si128@plt>
mov    0x18(%rsp),%rdi
mov    %r14,%rsi
mov    0xc(%rsp),%edx
call   1070 <memcpy@plt>
lea    0x10(%rsp),%rdi
mov    %rbx,%rsi
call   10a0 <morus_stateupdate@plt>
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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