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

/* Variables and functions */
int /*<<< orphan*/ _mm_load_si128(int /*<<< orphan*/ *);
int /*<<< orphan*/ _mm_store_si128(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_xor_si128(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ morus_stateupdate(int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ **);
void morus_tag_generation(uint64_t msglen, uint64_t adlen, uint8_t *c,
                          __m128i (*state)[2]) {
  int i;
  uint8_t t[32];
  __m128i tmp[2];
  _mm_store_si128((__m128i *)t, state[3][0]);
  ((uint64_t *)t)[0] ^= (adlen << 3);
  ((uint64_t *)t)[1] ^= (msglen << 3);
  tmp[0] = _mm_load_si128((__m128i *)t);
  tmp[1] = state[3][1];
  state[4][0] = _mm_xor_si128((state[4][0]), (state[0][0]));
  state[4][1] = _mm_xor_si128((state[4][1]), (state[0][1]));
  for (i = 0; i < 8; i++)
    morus_stateupdate(tmp, state);
  for (i = 2; i < 5; i++) {
    state[1][0] = _mm_xor_si128((state[1][0]), (state[i][0]));
    state[1][1] = _mm_xor_si128((state[1][1]), (state[i][1]));
  }
  _mm_store_si128((__m128i *)t, state[1][0]);
  memcpy(c + msglen, t, 16);
}


x86 assembly (clang, -O0):
<morus_tag_generation>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%esi
call   1040 <_mm_store_si128@plt>
mov    -0x8(%rbp),%eax
shl    $0x3,%eax
xor    -0xa0(%rbp),%eax
mov    %eax,-0xa0(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x3,%eax
xor    -0x9c(%rbp),%eax
mov    %eax,-0x9c(%rbp)
lea    -0xa0(%rbp),%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,-0xa8(%rbp)
mov    -0x18(%rbp),%rax
mov    0x1c(%rax),%eax
mov    %eax,-0xa4(%rbp)
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x20(%rax)
mov    -0x18(%rbp),%rax
mov    0x24(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x24(%rax)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jge    1225 <morus_tag_generation+0xd5>
lea    -0xa8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <morus_stateupdate@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11fd <morus_tag_generation+0xad>
movl   $0x2,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jge    1285 <morus_tag_generation+0x135>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%edi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    122c <morus_tag_generation+0xdc>
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%esi
call   1040 <_mm_store_si128@plt>
mov    -0x10(%rbp),%rdi
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
lea    -0xa0(%rbp),%rsi
mov    $0x10,%edx
call   1050 <memcpy@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<morus_tag_generation>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %esi,%ebp
mov    %edi,%r12d
mov    0x18(%rcx),%esi
lea    0x10(%rsp),%r15
mov    %r15,%rdi
call   1040 <_mm_store_si128@plt>
shl    $0x3,%ebp
xor    %ebp,0x10(%rsp)
lea    0x0(,%r12,8),%eax
xor    %eax,0x14(%rsp)
mov    %r15,%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,0x8(%rsp)
mov    0x1c(%rbx),%eax
mov    %eax,0xc(%rsp)
mov    (%rbx),%esi
mov    0x20(%rbx),%edi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x20(%rbx)
mov    0x4(%rbx),%esi
mov    0x24(%rbx),%edi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x24(%rbx)
lea    0x8(%rsp),%r13
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <morus_stateupdate@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <morus_stateupdate@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <morus_stateupdate@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <morus_stateupdate@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <morus_stateupdate@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <morus_stateupdate@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <morus_stateupdate@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <morus_stateupdate@plt>
mov    0x8(%rbx),%edi
mov    0x10(%rbx),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x8(%rbx)
mov    0xc(%rbx),%edi
mov    0x14(%rbx),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0xc(%rbx)
mov    0x8(%rbx),%edi
mov    0x18(%rbx),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x8(%rbx)
mov    0xc(%rbx),%edi
mov    0x1c(%rbx),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0xc(%rbx)
mov    0x8(%rbx),%edi
mov    0x20(%rbx),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x8(%rbx)
mov    0xc(%rbx),%edi
mov    0x24(%rbx),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0xc(%rbx)
mov    0x8(%rbx),%esi
mov    %r15,%rdi
call   1040 <_mm_store_si128@plt>
movslq %r12d,%rax
lea    (%r14,%rax,4),%rdi
mov    %r15,%rsi
mov    $0x10,%edx
call   1050 <memcpy@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @morus_tag_generation(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 i32
%10 = alloca [32 x i32]
%11 = 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
%12 = getelementptr inbounds [32 x i32], [32 x i32]* %10, i64 0, i64 0
%13 = load [2 x i32]*, [2 x i32]** %8
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 3
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%16 = load i32, i32* %15
%17 = call i32 @_mm_store_si128(i32* %12, i32 %16)
%18 = load i32, i32* %6
%19 = shl i32 %18, 3
%20 = getelementptr inbounds [32 x i32], [32 x i32]* %10, i64 0, i64 0
%21 = getelementptr inbounds i32, i32* %20, i64 0
%22 = load i32, i32* %21
%23 = xor i32 %22, %19
store i32 %23, i32* %21
%24 = load i32, i32* %5
%25 = shl i32 %24, 3
%26 = getelementptr inbounds [32 x i32], [32 x i32]* %10, i64 0, i64 0
%27 = getelementptr inbounds i32, i32* %26, i64 1
%28 = load i32, i32* %27
%29 = xor i32 %28, %25
store i32 %29, i32* %27
%30 = getelementptr inbounds [32 x i32], [32 x i32]* %10, i64 0, i64 0
%31 = call i32 @_mm_load_si128(i32* %30)
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
store i32 %31, i32* %32
%33 = load [2 x i32]*, [2 x i32]** %8
%34 = getelementptr inbounds [2 x i32], [2 x i32]* %33, i64 3
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %34, i64 0, i64 1
%36 = load i32, i32* %35
%37 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
store i32 %36, i32* %37
%38 = load [2 x i32]*, [2 x i32]** %8
%39 = getelementptr inbounds [2 x i32], [2 x i32]* %38, i64 4
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %39, i64 0, i64 0
%41 = load i32, i32* %40
%42 = load [2 x i32]*, [2 x i32]** %8
%43 = getelementptr inbounds [2 x i32], [2 x i32]* %42, i64 0
%44 = getelementptr inbounds [2 x i32], [2 x i32]* %43, i64 0, i64 0
%45 = load i32, i32* %44
%46 = call i32 @_mm_xor_si128(i32 %41, i32 %45)
%47 = load [2 x i32]*, [2 x i32]** %8
%48 = getelementptr inbounds [2 x i32], [2 x i32]* %47, i64 4
%49 = getelementptr inbounds [2 x i32], [2 x i32]* %48, i64 0, i64 0
store i32 %46, i32* %49
%50 = load [2 x i32]*, [2 x i32]** %8
%51 = getelementptr inbounds [2 x i32], [2 x i32]* %50, i64 4
%52 = getelementptr inbounds [2 x i32], [2 x i32]* %51, i64 0, i64 1
%53 = load i32, i32* %52
%54 = load [2 x i32]*, [2 x i32]** %8
%55 = getelementptr inbounds [2 x i32], [2 x i32]* %54, i64 0
%56 = getelementptr inbounds [2 x i32], [2 x i32]* %55, i64 0, i64 1
%57 = load i32, i32* %56
%58 = call i32 @_mm_xor_si128(i32 %53, i32 %57)
%59 = load [2 x i32]*, [2 x i32]** %8
%60 = getelementptr inbounds [2 x i32], [2 x i32]* %59, i64 4
%61 = getelementptr inbounds [2 x i32], [2 x i32]* %60, i64 0, i64 1
store i32 %58, i32* %61
store i32 0, i32* %9
br label %62
62: ; preds = %70, %4
%63 = load i32, i32* %9
%64 = icmp slt i32 %63, 8
br i1 %64, label %65, label %73
65: ; preds = %62
%66 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%67 = load [2 x i32]*, [2 x i32]** %8
%68 = bitcast [2 x i32]* %67 to i32**
%69 = call i32 @morus_stateupdate(i32* %66, i32** %68)
br label %70
70: ; preds = %65
%71 = load i32, i32* %9
%72 = add nsw i32 %71, 1
store i32 %72, i32* %9
br label %62
73: ; preds = %62
store i32 2, i32* %9
br label %74
74: ; preds = %106, %73
%75 = load i32, i32* %9
%76 = icmp slt i32 %75, 5
br i1 %76, label %77, label %109
77: ; preds = %74
%78 = load [2 x i32]*, [2 x i32]** %8
%79 = getelementptr inbounds [2 x i32], [2 x i32]* %78, i64 1
%80 = getelementptr inbounds [2 x i32], [2 x i32]* %79, i64 0, i64 0
%81 = load i32, i32* %80
%82 = load [2 x i32]*, [2 x i32]** %8
%83 = load i32, i32* %9
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [2 x i32], [2 x i32]* %82, i64 %84
%86 = getelementptr inbounds [2 x i32], [2 x i32]* %85, i64 0, i64 0
%87 = load i32, i32* %86
%88 = call i32 @_mm_xor_si128(i32 %81, i32 %87)
%89 = load [2 x i32]*, [2 x i32]** %8
%90 = getelementptr inbounds [2 x i32], [2 x i32]* %89, i64 1
%91 = getelementptr inbounds [2 x i32], [2 x i32]* %90, i64 0, i64 0
store i32 %88, i32* %91
%92 = load [2 x i32]*, [2 x i32]** %8
%93 = getelementptr inbounds [2 x i32], [2 x i32]* %92, i64 1
%94 = getelementptr inbounds [2 x i32], [2 x i32]* %93, i64 0, i64 1
%95 = load i32, i32* %94
%96 = load [2 x i32]*, [2 x i32]** %8
%97 = load i32, i32* %9
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [2 x i32], [2 x i32]* %96, i64 %98
%100 = getelementptr inbounds [2 x i32], [2 x i32]* %99, i64 0, i64 1
%101 = load i32, i32* %100
%102 = call i32 @_mm_xor_si128(i32 %95, i32 %101)
%103 = load [2 x i32]*, [2 x i32]** %8
%104 = getelementptr inbounds [2 x i32], [2 x i32]* %103, i64 1
%105 = getelementptr inbounds [2 x i32], [2 x i32]* %104, i64 0, i64 1
store i32 %102, i32* %105
br label %106
106: ; preds = %77
%107 = load i32, i32* %9
%108 = add nsw i32 %107, 1
store i32 %108, i32* %9
br label %74
109: ; preds = %74
%110 = getelementptr inbounds [32 x i32], [32 x i32]* %10, i64 0, i64 0
%111 = load [2 x i32]*, [2 x i32]** %8
%112 = getelementptr inbounds [2 x i32], [2 x i32]* %111, i64 1
%113 = getelementptr inbounds [2 x i32], [2 x i32]* %112, i64 0, i64 0
%114 = load i32, i32* %113
%115 = call i32 @_mm_store_si128(i32* %110, i32 %114)
%116 = load i32*, i32** %7
%117 = load i32, i32* %5
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds i32, i32* %116, i64 %118
%120 = getelementptr inbounds [32 x i32], [32 x i32]* %10, i64 0, i64 0
%121 = call i32 @memcpy(i32* %119, i32* %120, i32 16)
ret void
}

LLVM IR (-O2):
define void @morus_tag_generation(i32 %0, i32 %1, i32* %2, [2 x i32]* %3) {
%5 = alloca [32 x i32]
%6 = alloca [2 x i32]
%7 = bitcast [32 x i32]* %5 to i8*
%8 = bitcast [2 x i32]* %6 to i8*
%9 = getelementptr inbounds [32 x i32], [32 x i32]* %5, i64 0, i64 0
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 3, i64 0
%11 = load i32, i32* %10
%12 = call i32 @_mm_store_si128(i32* %9, i32 %11)
%13 = shl i32 %1, 3
%14 = load i32, i32* %9
%15 = xor i32 %14, %13
store i32 %15, i32* %9
%16 = shl i32 %0, 3
%17 = getelementptr inbounds [32 x i32], [32 x i32]* %5, i64 0, i64 1
%18 = load i32, i32* %17
%19 = xor i32 %18, %16
store i32 %19, i32* %17
%20 = call i32 @_mm_load_si128(i32* %9)
%21 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
store i32 %20, i32* %21
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 3, i64 1
%23 = load i32, i32* %22
%24 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 %23, i32* %24
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 4, i64 0
%26 = load i32, i32* %25
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%28 = load i32, i32* %27
%29 = call i32 @_mm_xor_si128(i32 %26, i32 %28)
store i32 %29, i32* %25
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 4, i64 1
%31 = load i32, i32* %30
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%33 = load i32, i32* %32
%34 = call i32 @_mm_xor_si128(i32 %31, i32 %33)
store i32 %34, i32* %30
%35 = bitcast [2 x i32]* %3 to i32**
%36 = call i32 @morus_stateupdate(i32* %21, i32** %35)
%37 = call i32 @morus_stateupdate(i32* %21, i32** %35)
%38 = call i32 @morus_stateupdate(i32* %21, i32** %35)
%39 = call i32 @morus_stateupdate(i32* %21, i32** %35)
%40 = call i32 @morus_stateupdate(i32* %21, i32** %35)
%41 = call i32 @morus_stateupdate(i32* %21, i32** %35)
%42 = call i32 @morus_stateupdate(i32* %21, i32** %35)
%43 = call i32 @morus_stateupdate(i32* %21, i32** %35)
%44 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 1, i64 0
%45 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 1, i64 1
%46 = load i32, i32* %44
%47 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 2, i64 0
%48 = load i32, i32* %47
%49 = call i32 @_mm_xor_si128(i32 %46, i32 %48)
store i32 %49, i32* %44
%50 = load i32, i32* %45
%51 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 2, i64 1
%52 = load i32, i32* %51
%53 = call i32 @_mm_xor_si128(i32 %50, i32 %52)
store i32 %53, i32* %45
%54 = load i32, i32* %44
%55 = load i32, i32* %10
%56 = call i32 @_mm_xor_si128(i32 %54, i32 %55)
store i32 %56, i32* %44
%57 = load i32, i32* %45
%58 = load i32, i32* %22
%59 = call i32 @_mm_xor_si128(i32 %57, i32 %58)
store i32 %59, i32* %45
%60 = load i32, i32* %44
%61 = load i32, i32* %25
%62 = call i32 @_mm_xor_si128(i32 %60, i32 %61)
store i32 %62, i32* %44
%63 = load i32, i32* %45
%64 = load i32, i32* %30
%65 = call i32 @_mm_xor_si128(i32 %63, i32 %64)
store i32 %65, i32* %45
%66 = load i32, i32* %44
%67 = call i32 @_mm_store_si128(i32* %9, i32 %66)
%68 = sext i32 %0 to i64
%69 = getelementptr inbounds i32, i32* %2, i64 %68
%70 = call i32 @memcpy(i32* %69, i32* %9, i32 16)
ret void
}