#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 */

/* Variables and functions */
int /*<<< orphan*/ memcpy(unsigned int *, unsigned char const *, int);
int /*<<< orphan*/ memset(unsigned int *, int, int);
int /*<<< orphan*/ morus_stateupdate(unsigned int *, unsigned int **);
void morus_initialization(const unsigned char *key, const unsigned char *iv,
                          unsigned int state[][4]) {
  int i;
  unsigned int temp[4] = {0, 0, 0, 0};
  unsigned char con0[16] = {0x0,  0x1,  0x01, 0x02, 0x03, 0x05, 0x08, 0x0d,
                            0x15, 0x22, 0x37, 0x59, 0x90, 0xe9, 0x79, 0x62};
  unsigned char con1[16] = {0xdb, 0x3d, 0x18, 0x55, 0x6d, 0xc2, 0x2f, 0xf1,
                            0x20, 0x11, 0x31, 0x42, 0x73, 0xb5, 0x28, 0xdd};
  memcpy(state[0], iv, 16);
  memcpy(state[1], key, 16);
  memset(state[2], 0xff, 16);
  memcpy(state[3], con0, 16);
  memcpy(state[4], con1, 16);
  for (i = 0; i < 4; i++)
    temp[i] = 0;
  for (i = 0; i < 16; i++)
    morus_stateupdate(temp, state);
  for (i = 0; i < 4; i++)
    state[1][i] ^= ((unsigned int *)key)[i];
}


x86 assembly (clang, -O0):
<morus_initialization>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
mov    0xea5(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xea2(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe9f(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe9c(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x10,%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rdi
add    $0x10,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x10,%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rdi
add    $0x20,%rdi
mov    $0xff,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
mov    -0x18(%rbp),%rdi
add    $0x30,%rdi
lea    -0x40(%rbp),%rsi
mov    $0x10,%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rdi
add    $0x40,%rdi
lea    -0x50(%rbp),%rsi
mov    $0x10,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    1216 <morus_initialization+0xe6>
movslq -0x1c(%rbp),%rax
movl   $0x0,-0x30(%rbp,%rax,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f2 <morus_initialization+0xc2>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    1242 <morus_initialization+0x112>
lea    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <morus_stateupdate@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    121d <morus_initialization+0xed>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    127c <morus_initialization+0x14c>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
xor    0x10(%rax,%rcx,4),%edx
mov    %edx,0x10(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1249 <morus_initialization+0x119>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<morus_initialization>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdx,%rbx
mov    %rdi,%r14
movaps 0xeba(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xebe(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rdx,%rdi
mov    $0x10,%edx
call   1040 <memcpy@plt>
lea    0x10(%rbx),%rdi
mov    %r14,%rsi
mov    $0x10,%edx
call   1040 <memcpy@plt>
lea    0x20(%rbx),%rdi
mov    $0xff,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
lea    0x30(%rbx),%rdi
lea    0x10(%rsp),%rsi
mov    $0x10,%edx
call   1040 <memcpy@plt>
lea    0x40(%rbx),%rdi
mov    %rsp,%rsi
mov    $0x10,%edx
call   1040 <memcpy@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
lea    0x20(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <morus_stateupdate@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <morus_stateupdate@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <morus_stateupdate@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <morus_stateupdate@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <morus_stateupdate@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <morus_stateupdate@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <morus_stateupdate@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <morus_stateupdate@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <morus_stateupdate@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <morus_stateupdate@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <morus_stateupdate@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <morus_stateupdate@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <morus_stateupdate@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <morus_stateupdate@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <morus_stateupdate@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <morus_stateupdate@plt>
mov    (%r14),%eax
xor    %eax,0x10(%rbx)
mov    0x4(%r14),%eax
xor    %eax,0x14(%rbx)
mov    0x8(%r14),%eax
xor    %eax,0x18(%rbx)
mov    0xc(%r14),%eax
xor    %eax,0x1c(%rbx)
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.morus_initialization.con0 = [16 x i8] c"\00\01\01\02\03\05\08\0D\15\227Y\90\E9yb"
@__const.morus_initialization.con1 = [16 x i8] c"\DB=\18Um\C2/\F1 \111Bs\B5(\DD"
define void @morus_initialization(i8* %0, i8* %1, [4 x i32]* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [4 x i32]*
%7 = alloca i32
%8 = alloca [4 x i32]
%9 = alloca [16 x i8]
%10 = alloca [16 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store [4 x i32]* %2, [4 x i32]** %6
%11 = bitcast [4 x i32]* %8 to i8*
%12 = bitcast [16 x i8]* %9 to i8*
%13 = bitcast [16 x i8]* %10 to i8*
%14 = load [4 x i32]*, [4 x i32]** %6
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %15, i64 0, i64 0
%17 = load i8*, i8** %5
%18 = call i32 @memcpy(i32* %16, i8* %17, i32 16)
%19 = load [4 x i32]*, [4 x i32]** %6
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %19, i64 1
%21 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 0
%22 = load i8*, i8** %4
%23 = call i32 @memcpy(i32* %21, i8* %22, i32 16)
%24 = load [4 x i32]*, [4 x i32]** %6
%25 = getelementptr inbounds [4 x i32], [4 x i32]* %24, i64 2
%26 = getelementptr inbounds [4 x i32], [4 x i32]* %25, i64 0, i64 0
%27 = call i32 @memset(i32* %26, i32 255, i32 16)
%28 = load [4 x i32]*, [4 x i32]** %6
%29 = getelementptr inbounds [4 x i32], [4 x i32]* %28, i64 3
%30 = getelementptr inbounds [4 x i32], [4 x i32]* %29, i64 0, i64 0
%31 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%32 = call i32 @memcpy(i32* %30, i8* %31, i32 16)
%33 = load [4 x i32]*, [4 x i32]** %6
%34 = getelementptr inbounds [4 x i32], [4 x i32]* %33, i64 4
%35 = getelementptr inbounds [4 x i32], [4 x i32]* %34, i64 0, i64 0
%36 = getelementptr inbounds [16 x i8], [16 x i8]* %10, i64 0, i64 0
%37 = call i32 @memcpy(i32* %35, i8* %36, i32 16)
store i32 0, i32* %7
br label %38
38: ; preds = %45, %3
%39 = load i32, i32* %7
%40 = icmp slt i32 %39, 4
br i1 %40, label %41, label %48
41: ; preds = %38
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 %43
store i32 0, i32* %44
br label %45
45: ; preds = %41
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %38
48: ; preds = %38
store i32 0, i32* %7
br label %49
49: ; preds = %57, %48
%50 = load i32, i32* %7
%51 = icmp slt i32 %50, 16
br i1 %51, label %52, label %60
52: ; preds = %49
%53 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 0
%54 = load [4 x i32]*, [4 x i32]** %6
%55 = bitcast [4 x i32]* %54 to i32**
%56 = call i32 @morus_stateupdate(i32* %53, i32** %55)
br label %57
57: ; preds = %52
%58 = load i32, i32* %7
%59 = add nsw i32 %58, 1
store i32 %59, i32* %7
br label %49
60: ; preds = %49
store i32 0, i32* %7
br label %61
61: ; preds = %78, %60
%62 = load i32, i32* %7
%63 = icmp slt i32 %62, 4
br i1 %63, label %64, label %81
64: ; preds = %61
%65 = load i8*, i8** %4
%66 = bitcast i8* %65 to i32*
%67 = load i32, i32* %7
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i32, i32* %66, i64 %68
%70 = load i32, i32* %69
%71 = load [4 x i32]*, [4 x i32]** %6
%72 = getelementptr inbounds [4 x i32], [4 x i32]* %71, i64 1
%73 = load i32, i32* %7
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [4 x i32], [4 x i32]* %72, i64 0, i64 %74
%76 = load i32, i32* %75
%77 = xor i32 %76, %70
store i32 %77, i32* %75
br label %78
78: ; preds = %64
%79 = load i32, i32* %7
%80 = add nsw i32 %79, 1
store i32 %80, i32* %7
br label %61
81: ; preds = %61
ret void
}

LLVM IR (-O2):
@__const.morus_initialization.con0 = [16 x i8] c"\00\01\01\02\03\05\08\0D\15\227Y\90\E9yb"
@__const.morus_initialization.con1 = [16 x i8] c"\DB=\18Um\C2/\F1 \111Bs\B5(\DD"
define void @morus_initialization(i8* %0, i8* %1, [4 x i32]* %2) {
%4 = alloca [4 x i32]
%5 = bitcast [4 x i32]* %4 to i8*
%6 = alloca [16 x i8]
%7 = alloca [16 x i8]
%8 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%11 = tail call i32 @memcpy(i32* %10, i8* %1, i32 16)
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 1, i64 0
%13 = tail call i32 @memcpy(i32* %12, i8* %0, i32 16)
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 2, i64 0
%15 = tail call i32 @memset(i32* %14, i32 255, i32 16)
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 3, i64 0
%17 = call i32 @memcpy(i32* %16, i8* %8, i32 16)
%18 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 4, i64 0
%19 = call i32 @memcpy(i32* %18, i8* %9, i32 16)
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%21 = bitcast [4 x i32]* %2 to i32**
%22 = call i32 @morus_stateupdate(i32* %20, i32** %21)
%23 = call i32 @morus_stateupdate(i32* %20, i32** %21)
%24 = call i32 @morus_stateupdate(i32* %20, i32** %21)
%25 = call i32 @morus_stateupdate(i32* %20, i32** %21)
%26 = call i32 @morus_stateupdate(i32* %20, i32** %21)
%27 = call i32 @morus_stateupdate(i32* %20, i32** %21)
%28 = call i32 @morus_stateupdate(i32* %20, i32** %21)
%29 = call i32 @morus_stateupdate(i32* %20, i32** %21)
%30 = call i32 @morus_stateupdate(i32* %20, i32** %21)
%31 = call i32 @morus_stateupdate(i32* %20, i32** %21)
%32 = call i32 @morus_stateupdate(i32* %20, i32** %21)
%33 = call i32 @morus_stateupdate(i32* %20, i32** %21)
%34 = call i32 @morus_stateupdate(i32* %20, i32** %21)
%35 = call i32 @morus_stateupdate(i32* %20, i32** %21)
%36 = call i32 @morus_stateupdate(i32* %20, i32** %21)
%37 = call i32 @morus_stateupdate(i32* %20, i32** %21)
%38 = bitcast i8* %0 to i32*
%39 = load i32, i32* %38
%40 = load i32, i32* %12
%41 = xor i32 %40, %39
store i32 %41, i32* %12
%42 = getelementptr inbounds i8, i8* %0, i64 4
%43 = bitcast i8* %42 to i32*
%44 = load i32, i32* %43
%45 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 1, i64 1
%46 = load i32, i32* %45
%47 = xor i32 %46, %44
store i32 %47, i32* %45
%48 = getelementptr inbounds i8, i8* %0, i64 8
%49 = bitcast i8* %48 to i32*
%50 = load i32, i32* %49
%51 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 1, i64 2
%52 = load i32, i32* %51
%53 = xor i32 %52, %50
store i32 %53, i32* %51
%54 = getelementptr inbounds i8, i8* %0, i64 12
%55 = bitcast i8* %54 to i32*
%56 = load i32, i32* %55
%57 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 1, i64 3
%58 = load i32, i32* %57
%59 = xor i32 %58, %56
store i32 %59, i32* %57
ret void
}