#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_load_si128(int /*<<< orphan*/ *);
int /*<<< orphan*/ _mm_set_epi32(int, int, int, int);
int /*<<< orphan*/ _mm_set_epi8(int, int, int, int, int, int, int, int, int,
                                int, int, int, int, int, int, int);
int /*<<< orphan*/ _mm_setzero_si128();
int /*<<< orphan*/ _mm_xor_si128(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ morus_stateupdate(int /*<<< orphan*/, int /*<<< orphan*/ *);
void morus_initialization(const unsigned char *key, const unsigned char *iv,
                          __m128i *state) {
  int i;
  __m128i tmp = _mm_setzero_si128();
  state[0] = _mm_load_si128((__m128i *)iv);
  state[1] = _mm_load_si128((__m128i *)key);
  state[2] = _mm_set_epi32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff);
  state[3] = _mm_set_epi8(0x62, 0x79, 0xe9, 0x90, 0x59, 0x37, 0x22, 0x15, 0x0d,
                          0x08, 0x05, 0x03, 0x02, 0x01, 0x1, 0x0);
  state[4] = _mm_set_epi8(0xdd, 0x28, 0xb5, 0x73, 0x42, 0x31, 0x11, 0x20, 0xf1,
                          0x2f, 0xc2, 0x6d, 0x55, 0x18, 0x3d, 0xdb);
  for (i = 0; i < 16; i++)
    morus_stateupdate(tmp, state);
  state[1] = _mm_xor_si128((state[1]), (_mm_load_si128((__m128i *)key)));
}


x86 assembly (clang, -O0):
<morus_initialization>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x0,%al
call   1040 <_mm_setzero_si128@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    $0xffffffff,%ecx
mov    %ecx,%edi
mov    %ecx,%esi
mov    %ecx,%edx
call   1050 <_mm_set_epi32@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    $0x62,%edi
mov    $0x79,%esi
mov    $0xe9,%edx
mov    $0x90,%ecx
mov    $0x59,%r8d
mov    $0x37,%r9d
xor    %eax,%eax
movl   $0x22,(%rsp)
movl   $0x15,0x8(%rsp)
movl   $0xd,0x10(%rsp)
movl   $0x8,0x18(%rsp)
movl   $0x5,0x20(%rsp)
movl   $0x3,0x28(%rsp)
movl   $0x2,0x30(%rsp)
movl   $0x1,0x38(%rsp)
movl   $0x1,0x40(%rsp)
movl   $0x0,0x48(%rsp)
call   1060 <_mm_set_epi8@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    $0xdd,%edi
mov    $0x28,%esi
mov    $0xb5,%edx
mov    $0x73,%ecx
mov    $0x42,%r8d
mov    $0x31,%r9d
movl   $0x11,(%rsp)
movl   $0x20,0x8(%rsp)
movl   $0xf1,0x10(%rsp)
movl   $0x2f,0x18(%rsp)
movl   $0xc2,0x20(%rsp)
movl   $0x6d,0x28(%rsp)
movl   $0x55,0x30(%rsp)
movl   $0x18,0x38(%rsp)
movl   $0x3d,0x40(%rsp)
movl   $0xdb,0x48(%rsp)
call   1060 <_mm_set_epi8@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x10(%rax)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    12e4 <morus_initialization+0x184>
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1080 <morus_stateupdate@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12c0 <morus_initialization+0x160>
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <_mm_load_si128@plt>
mov    -0x24(%rbp),%edi
mov    %eax,%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<morus_initialization>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r14
xor    %eax,%eax
call   1040 <_mm_setzero_si128@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,(%rbx)
mov    %r14,%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,0x4(%rbx)
mov    $0xffffffff,%edi
mov    $0xffffffff,%esi
mov    $0xffffffff,%edx
mov    $0xffffffff,%ecx
call   1050 <_mm_set_epi32@plt>
mov    %eax,0x8(%rbx)
mov    $0x62,%edi
mov    $0x79,%esi
mov    $0xe9,%edx
mov    $0x90,%ecx
mov    $0x59,%r8d
mov    $0x37,%r9d
push   $0x0
push   $0x1
push   $0x1
push   $0x2
push   $0x3
push   $0x5
push   $0x8
push   $0xd
push   $0x15
push   $0x22
call   1060 <_mm_set_epi8@plt>
add    $0x50,%rsp
mov    %eax,0xc(%rbx)
mov    $0xdd,%edi
mov    $0x28,%esi
mov    $0xb5,%edx
mov    $0x73,%ecx
mov    $0x42,%r8d
mov    $0x31,%r9d
push   $0xdb
push   $0x3d
push   $0x18
push   $0x55
push   $0x6d
push   $0xc2
push   $0x2f
push   $0xf1
push   $0x20
push   $0x11
call   1060 <_mm_set_epi8@plt>
add    $0x50,%rsp
mov    %eax,0x10(%rbx)
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <morus_stateupdate@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <morus_stateupdate@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <morus_stateupdate@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <morus_stateupdate@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <morus_stateupdate@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <morus_stateupdate@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <morus_stateupdate@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <morus_stateupdate@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <morus_stateupdate@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <morus_stateupdate@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <morus_stateupdate@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <morus_stateupdate@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <morus_stateupdate@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <morus_stateupdate@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <morus_stateupdate@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <morus_stateupdate@plt>
mov    0x4(%rbx),%ebp
mov    %r14,%rdi
call   1030 <_mm_load_si128@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,0x4(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @morus_initialization(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 = call i32 (...) @_mm_setzero_si128()
store i32 %9, i32* %8
%10 = load i8*, i8** %5
%11 = bitcast i8* %10 to i32*
%12 = call i32 @_mm_load_si128(i32* %11)
%13 = load i32*, i32** %6
%14 = getelementptr inbounds i32, i32* %13, i64 0
store i32 %12, i32* %14
%15 = load i8*, i8** %4
%16 = bitcast i8* %15 to i32*
%17 = call i32 @_mm_load_si128(i32* %16)
%18 = load i32*, i32** %6
%19 = getelementptr inbounds i32, i32* %18, i64 1
store i32 %17, i32* %19
%20 = call i32 @_mm_set_epi32(i32 -1, i32 -1, i32 -1, i32 -1)
%21 = load i32*, i32** %6
%22 = getelementptr inbounds i32, i32* %21, i64 2
store i32 %20, i32* %22
%23 = call i32 @_mm_set_epi8(i32 98, i32 121, i32 233, i32 144, i32 89, i32 55, i32 34, i32 21, i32 13, i32 8, i32 5, i32 3, i32 2, i32 1, i32 1, i32 0)
%24 = load i32*, i32** %6
%25 = getelementptr inbounds i32, i32* %24, i64 3
store i32 %23, i32* %25
%26 = call i32 @_mm_set_epi8(i32 221, i32 40, i32 181, i32 115, i32 66, i32 49, i32 17, i32 32, i32 241, i32 47, i32 194, i32 109, i32 85, i32 24, i32 61, i32 219)
%27 = load i32*, i32** %6
%28 = getelementptr inbounds i32, i32* %27, i64 4
store i32 %26, i32* %28
store i32 0, i32* %7
br label %29
29: ; preds = %36, %3
%30 = load i32, i32* %7
%31 = icmp slt i32 %30, 16
br i1 %31, label %32, label %39
32: ; preds = %29
%33 = load i32, i32* %8
%34 = load i32*, i32** %6
%35 = call i32 @morus_stateupdate(i32 %33, i32* %34)
br label %36
36: ; preds = %32
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %29
39: ; preds = %29
%40 = load i32*, i32** %6
%41 = getelementptr inbounds i32, i32* %40, i64 1
%42 = load i32, i32* %41
%43 = load i8*, i8** %4
%44 = bitcast i8* %43 to i32*
%45 = call i32 @_mm_load_si128(i32* %44)
%46 = call i32 @_mm_xor_si128(i32 %42, i32 %45)
%47 = load i32*, i32** %6
%48 = getelementptr inbounds i32, i32* %47, i64 1
store i32 %46, i32* %48
ret void
}

LLVM IR (-O2):
define void @morus_initialization(i8* %0, i8* %1, i32* %2) {
%4 = tail call i32 (...) @_mm_setzero_si128()
%5 = bitcast i8* %1 to i32*
%6 = tail call i32 @_mm_load_si128(i32* %5)
store i32 %6, i32* %2
%7 = bitcast i8* %0 to i32*
%8 = tail call i32 @_mm_load_si128(i32* %7)
%9 = getelementptr inbounds i32, i32* %2, i64 1
store i32 %8, i32* %9
%10 = tail call i32 @_mm_set_epi32(i32 -1, i32 -1, i32 -1, i32 -1)
%11 = getelementptr inbounds i32, i32* %2, i64 2
store i32 %10, i32* %11
%12 = tail call i32 @_mm_set_epi8(i32 98, i32 121, i32 233, i32 144, i32 89, i32 55, i32 34, i32 21, i32 13, i32 8, i32 5, i32 3, i32 2, i32 1, i32 1, i32 0)
%13 = getelementptr inbounds i32, i32* %2, i64 3
store i32 %12, i32* %13
%14 = tail call i32 @_mm_set_epi8(i32 221, i32 40, i32 181, i32 115, i32 66, i32 49, i32 17, i32 32, i32 241, i32 47, i32 194, i32 109, i32 85, i32 24, i32 61, i32 219)
%15 = getelementptr inbounds i32, i32* %2, i64 4
store i32 %14, i32* %15
%16 = tail call i32 @morus_stateupdate(i32 %4, i32* %2)
%17 = tail call i32 @morus_stateupdate(i32 %4, i32* %2)
%18 = tail call i32 @morus_stateupdate(i32 %4, i32* %2)
%19 = tail call i32 @morus_stateupdate(i32 %4, i32* %2)
%20 = tail call i32 @morus_stateupdate(i32 %4, i32* %2)
%21 = tail call i32 @morus_stateupdate(i32 %4, i32* %2)
%22 = tail call i32 @morus_stateupdate(i32 %4, i32* %2)
%23 = tail call i32 @morus_stateupdate(i32 %4, i32* %2)
%24 = tail call i32 @morus_stateupdate(i32 %4, i32* %2)
%25 = tail call i32 @morus_stateupdate(i32 %4, i32* %2)
%26 = tail call i32 @morus_stateupdate(i32 %4, i32* %2)
%27 = tail call i32 @morus_stateupdate(i32 %4, i32* %2)
%28 = tail call i32 @morus_stateupdate(i32 %4, i32* %2)
%29 = tail call i32 @morus_stateupdate(i32 %4, i32* %2)
%30 = tail call i32 @morus_stateupdate(i32 %4, i32* %2)
%31 = tail call i32 @morus_stateupdate(i32 %4, i32* %2)
%32 = load i32, i32* %9
%33 = tail call i32 @_mm_load_si128(i32* %7)
%34 = tail call i32 @_mm_xor_si128(i32 %32, i32 %33)
store i32 %34, i32* %9
ret void
}